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 replaceAndOperator(String sql, boolean andOperator) {
71          return _instance._customSQL.replaceAndOperator(
72              sql, andOperator);
73      }
74  
75      public static String replaceIsNull(String sql) {
76          return _instance._customSQL.replaceIsNull(sql);
77      }
78  
79      public static String replaceKeywords(
80          String sql, String field, String operator, boolean last,
81          String[] values) {
82  
83          return _instance._customSQL.replaceKeywords(
84              sql, field, operator, last, values);
85      }
86  
87      public static String removeOrderBy(String sql) {
88          return _instance._customSQL.removeOrderBy(sql);
89      }
90  
91      public static String replaceOrderBy(String sql, OrderByComparator obc) {
92          return _instance._customSQL.replaceOrderBy(sql, obc);
93      }
94  
95      private CustomSQLUtil() {
96          try {
97              _customSQL = new CustomSQL();
98          }
99          catch (Exception e) {
100             _log.error(e, e);
101         }
102     }
103 
104     private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
105 
106     private static CustomSQLUtil _instance = new CustomSQLUtil();
107 
108     private CustomSQL _customSQL;
109 
110 }