1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.util.dao.orm;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.OrderByComparator;
25  
26  /**
27   * <a href="CustomSQLUtil.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   * @author Bruno Farache
31   *
32   */
33  public class CustomSQLUtil {
34  
35      public static String get(String id) {
36          return _instance._customSQL.get(id);
37      }
38  
39      public static boolean isVendorDB2() {
40          return _instance._customSQL.isVendorDB2();
41      }
42  
43      public static boolean isVendorInformix() {
44          return _instance._customSQL.isVendorInformix();
45      }
46  
47      public static boolean isVendorMySQL() {
48          return _instance._customSQL.isVendorMySQL();
49      }
50  
51      public static boolean isVendorOracle() {
52          return _instance._customSQL.isVendorOracle();
53      }
54  
55      public static boolean isVendorSybase() {
56          return _instance._customSQL.isVendorSybase();
57      }
58  
59      public static String[] keywords(String keywords) {
60          return _instance._customSQL.keywords(keywords);
61      }
62  
63      public static String[] keywords(String keywords, boolean lowerCase) {
64          return _instance._customSQL.keywords(keywords, lowerCase);
65      }
66  
67      public static String[] keywords(String[] keywordsArray) {
68          return _instance._customSQL.keywords(keywordsArray);
69      }
70  
71      public static String[] keywords(String[] keywordsArray, boolean lowerCase) {
72          return _instance._customSQL.keywords(
73              keywordsArray, lowerCase);
74      }
75  
76      public static String replaceAndOperator(String sql, boolean andOperator) {
77          return _instance._customSQL.replaceAndOperator(
78              sql, andOperator);
79      }
80  
81      public static String replaceIsNull(String sql) {
82          return _instance._customSQL.replaceIsNull(sql);
83      }
84  
85      public static String replaceKeywords(
86          String sql, String field, String operator, boolean last,
87          String[] values) {
88  
89          return _instance._customSQL.replaceKeywords(
90              sql, field, operator, last, values);
91      }
92  
93      public static String removeOrderBy(String sql) {
94          return _instance._customSQL.removeOrderBy(sql);
95      }
96  
97      public static String replaceOrderBy(String sql, OrderByComparator obc) {
98          return _instance._customSQL.replaceOrderBy(sql, obc);
99      }
100 
101     private CustomSQLUtil() {
102         try {
103             _customSQL = new CustomSQL();
104         }
105         catch (Exception e) {
106             _log.error(e, e);
107         }
108     }
109 
110     private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
111 
112     private static CustomSQLUtil _instance = new CustomSQLUtil();
113 
114     private CustomSQL _customSQL;
115 
116 }