1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.portal.spring.hibernate;
24  
25  import com.liferay.portal.kernel.util.OrderByComparator;
26  
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  
30  /**
31   * <a href="CustomSQLUtil.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   * @author Bruno Farache
35   *
36   */
37  public class CustomSQLUtil {
38  
39      public static String get(String id) {
40          return _instance._portalCustomSQLUtil.get(id);
41      }
42  
43      public static boolean isVendorDB2() {
44          return _instance._portalCustomSQLUtil.isVendorDB2();
45      }
46  
47      public static boolean isVendorInformix() {
48          return _instance._portalCustomSQLUtil.isVendorInformix();
49      }
50  
51      public static boolean isVendorMySQL() {
52          return _instance._portalCustomSQLUtil.isVendorMySQL();
53      }
54  
55      public static boolean isVendorOracle() {
56          return _instance._portalCustomSQLUtil.isVendorOracle();
57      }
58  
59      public static boolean isVendorSybase() {
60          return _instance._portalCustomSQLUtil.isVendorSybase();
61      }
62  
63      public static String[] keywords(String keywords) {
64          return _instance._portalCustomSQLUtil.keywords(keywords);
65      }
66  
67      public static String[] keywords(String keywords, boolean lowerCase) {
68          return _instance._portalCustomSQLUtil.keywords(keywords, lowerCase);
69      }
70  
71      public static String[] keywords(String[] keywordsArray) {
72          return _instance._portalCustomSQLUtil.keywords(keywordsArray);
73      }
74  
75      public static String[] keywords(String[] keywordsArray, boolean lowerCase) {
76          return _instance._portalCustomSQLUtil.keywords(
77              keywordsArray, lowerCase);
78      }
79  
80      public static String replaceAndOperator(String sql, boolean andOperator) {
81          return _instance._portalCustomSQLUtil.replaceAndOperator(
82              sql, andOperator);
83      }
84  
85      public static String replaceIsNull(String sql) {
86          return _instance._portalCustomSQLUtil.replaceIsNull(sql);
87      }
88  
89      public static String replaceKeywords(
90          String sql, String field, String operator, boolean last,
91          String[] values) {
92  
93          return _instance._portalCustomSQLUtil.replaceKeywords(
94              sql, field, operator, last, values);
95      }
96  
97      public static String removeOrderBy(String sql) {
98          return _instance._portalCustomSQLUtil.removeOrderBy(sql);
99      }
100 
101     public static String replaceOrderBy(String sql, OrderByComparator obc) {
102         return _instance._portalCustomSQLUtil.replaceOrderBy(sql, obc);
103     }
104 
105     private CustomSQLUtil() {
106         try {
107             _portalCustomSQLUtil = new PortalCustomSQLUtil();
108         }
109         catch (Exception e) {
110             _log.error(e, e);
111         }
112     }
113 
114     private static Log _log = LogFactory.getLog(CustomSQLUtil.class);
115 
116     private static CustomSQLUtil _instance = new CustomSQLUtil();
117 
118     private PortalCustomSQLUtil _portalCustomSQLUtil;
119 
120 }