1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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, int[] values, boolean last) {
89  
90          return _instance._customSQL.replaceKeywords(sql, field, values, last);
91      }
92  
93      public static String replaceKeywords(
94          String sql, String field, String operator, boolean last,
95          String[] values) {
96  
97          return _instance._customSQL.replaceKeywords(
98              sql, field, operator, last, values);
99      }
100 
101     public static String replaceGroupBy(String sql, String groupBy) {
102         return _instance._customSQL.replaceGroupBy(sql, groupBy);
103     }
104 
105     public static String replaceOrderBy(String sql, OrderByComparator obc) {
106         return _instance._customSQL.replaceOrderBy(sql, obc);
107     }
108 
109     private CustomSQLUtil() {
110         try {
111             _customSQL = new CustomSQL();
112         }
113         catch (Exception e) {
114             _log.error(e, e);
115         }
116     }
117 
118     private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
119 
120     private static CustomSQLUtil _instance = new CustomSQLUtil();
121 
122     private CustomSQL _customSQL;
123 
124 }