1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.util.dao.orm;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.OrderByComparator;
20  
21  /**
22   * <a href="CustomSQLUtil.java.html"><b><i>View Source</i></b></a>
23   *
24   * @author Brian Wing Shun Chan
25   * @author Bruno Farache
26   */
27  public class CustomSQLUtil {
28  
29      public static String get(String id) {
30          return _instance._customSQL.get(id);
31      }
32  
33      public static boolean isVendorDB2() {
34          return _instance._customSQL.isVendorDB2();
35      }
36  
37      public static boolean isVendorInformix() {
38          return _instance._customSQL.isVendorInformix();
39      }
40  
41      public static boolean isVendorMySQL() {
42          return _instance._customSQL.isVendorMySQL();
43      }
44  
45      public static boolean isVendorOracle() {
46          return _instance._customSQL.isVendorOracle();
47      }
48  
49      public static boolean isVendorSybase() {
50          return _instance._customSQL.isVendorSybase();
51      }
52  
53      public static String[] keywords(String keywords) {
54          return _instance._customSQL.keywords(keywords);
55      }
56  
57      public static String[] keywords(String keywords, boolean lowerCase) {
58          return _instance._customSQL.keywords(keywords, lowerCase);
59      }
60  
61      public static String[] keywords(String[] keywordsArray) {
62          return _instance._customSQL.keywords(keywordsArray);
63      }
64  
65      public static String[] keywords(String[] keywordsArray, boolean lowerCase) {
66          return _instance._customSQL.keywords(
67              keywordsArray, lowerCase);
68      }
69  
70      public static String removeGroupBy(String sql) {
71          return _instance._customSQL.removeGroupBy(sql);
72      }
73  
74      public static String removeOrderBy(String sql) {
75          return _instance._customSQL.removeOrderBy(sql);
76      }
77  
78      public static String replaceAndOperator(String sql, boolean andOperator) {
79          return _instance._customSQL.replaceAndOperator(
80              sql, andOperator);
81      }
82  
83      public static String replaceIsNull(String sql) {
84          return _instance._customSQL.replaceIsNull(sql);
85      }
86  
87      public static String replaceKeywords(
88          String sql, String field, boolean last, int[] values) {
89  
90          return _instance._customSQL.replaceKeywords(sql, field, last, values);
91      }
92  
93      public static String replaceKeywords(
94          String sql, String field, boolean last, long[] values) {
95  
96          return _instance._customSQL.replaceKeywords(sql, field, last, values);
97      }
98  
99      public static String replaceKeywords(
100         String sql, String field, String operator, boolean last,
101         String[] values) {
102 
103         return _instance._customSQL.replaceKeywords(
104             sql, field, operator, last, values);
105     }
106 
107     public static String replaceGroupBy(String sql, String groupBy) {
108         return _instance._customSQL.replaceGroupBy(sql, groupBy);
109     }
110 
111     public static String replaceOrderBy(String sql, OrderByComparator obc) {
112         return _instance._customSQL.replaceOrderBy(sql, obc);
113     }
114 
115     private CustomSQLUtil() {
116         try {
117             _customSQL = new CustomSQL();
118         }
119         catch (Exception e) {
120             _log.error(e, e);
121         }
122     }
123 
124     private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
125 
126     private static CustomSQLUtil _instance = new CustomSQLUtil();
127 
128     private CustomSQL _customSQL;
129 
130 }