1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  public class CustomSQLUtil {
36  
37      public static String get(String id) {
38          return _instance._customSQL.get(id);
39      }
40  
41      public static boolean isVendorDB2() {
42          return _instance._customSQL.isVendorDB2();
43      }
44  
45      public static boolean isVendorInformix() {
46          return _instance._customSQL.isVendorInformix();
47      }
48  
49      public static boolean isVendorMySQL() {
50          return _instance._customSQL.isVendorMySQL();
51      }
52  
53      public static boolean isVendorOracle() {
54          return _instance._customSQL.isVendorOracle();
55      }
56  
57      public static boolean isVendorSybase() {
58          return _instance._customSQL.isVendorSybase();
59      }
60  
61      public static String[] keywords(String keywords) {
62          return _instance._customSQL.keywords(keywords);
63      }
64  
65      public static String[] keywords(String keywords, boolean lowerCase) {
66          return _instance._customSQL.keywords(keywords, lowerCase);
67      }
68  
69      public static String[] keywords(String[] keywordsArray) {
70          return _instance._customSQL.keywords(keywordsArray);
71      }
72  
73      public static String[] keywords(String[] keywordsArray, boolean lowerCase) {
74          return _instance._customSQL.keywords(
75              keywordsArray, lowerCase);
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, String operator, boolean last,
89          String[] values) {
90  
91          return _instance._customSQL.replaceKeywords(
92              sql, field, operator, last, values);
93      }
94  
95      public static String removeOrderBy(String sql) {
96          return _instance._customSQL.removeOrderBy(sql);
97      }
98  
99      public static String replaceOrderBy(String sql, OrderByComparator obc) {
100         return _instance._customSQL.replaceOrderBy(sql, obc);
101     }
102 
103     private CustomSQLUtil() {
104         try {
105             _customSQL = new CustomSQL();
106         }
107         catch (Exception e) {
108             _log.error(e, e);
109         }
110     }
111 
112     private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
113 
114     private static CustomSQLUtil _instance = new CustomSQLUtil();
115 
116     private CustomSQL _customSQL;
117 
118 }