1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.util.dao.orm;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.OrderByComparator;
28  
29  /**
30   * <a href="CustomSQLUtil.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   * @author Bruno Farache
34   *
35   */
36  public class CustomSQLUtil {
37  
38      public static String get(String id) {
39          return _instance._customSQL.get(id);
40      }
41  
42      public static boolean isVendorDB2() {
43          return _instance._customSQL.isVendorDB2();
44      }
45  
46      public static boolean isVendorInformix() {
47          return _instance._customSQL.isVendorInformix();
48      }
49  
50      public static boolean isVendorMySQL() {
51          return _instance._customSQL.isVendorMySQL();
52      }
53  
54      public static boolean isVendorOracle() {
55          return _instance._customSQL.isVendorOracle();
56      }
57  
58      public static boolean isVendorSybase() {
59          return _instance._customSQL.isVendorSybase();
60      }
61  
62      public static String[] keywords(String keywords) {
63          return _instance._customSQL.keywords(keywords);
64      }
65  
66      public static String[] keywords(String keywords, boolean lowerCase) {
67          return _instance._customSQL.keywords(keywords, lowerCase);
68      }
69  
70      public static String[] keywords(String[] keywordsArray) {
71          return _instance._customSQL.keywords(keywordsArray);
72      }
73  
74      public static String[] keywords(String[] keywordsArray, boolean lowerCase) {
75          return _instance._customSQL.keywords(
76              keywordsArray, lowerCase);
77      }
78  
79      public static String replaceAndOperator(String sql, boolean andOperator) {
80          return _instance._customSQL.replaceAndOperator(
81              sql, andOperator);
82      }
83  
84      public static String replaceIsNull(String sql) {
85          return _instance._customSQL.replaceIsNull(sql);
86      }
87  
88      public static String replaceKeywords(
89          String sql, String field, String operator, boolean last,
90          String[] values) {
91  
92          return _instance._customSQL.replaceKeywords(
93              sql, field, operator, last, values);
94      }
95  
96      public static String removeOrderBy(String sql) {
97          return _instance._customSQL.removeOrderBy(sql);
98      }
99  
100     public static String replaceOrderBy(String sql, OrderByComparator obc) {
101         return _instance._customSQL.replaceOrderBy(sql, obc);
102     }
103 
104     private CustomSQLUtil() {
105         try {
106             _customSQL = new CustomSQL();
107         }
108         catch (Exception e) {
109             _log.error(e, e);
110         }
111     }
112 
113     private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
114 
115     private static CustomSQLUtil _instance = new CustomSQLUtil();
116 
117     private CustomSQL _customSQL;
118 
119 }