001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.util.dao.orm;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.OrderByComparator;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     * @author Bruno Farache
024     * @author Raymond Augé
025     */
026    public class CustomSQLUtil {
027    
028            public static String appendCriteria(String sql, String criteria) {
029                    return _instance._customSQL.appendCriteria(sql, criteria);
030            }
031    
032            public static String get(String id) {
033                    return _instance._customSQL.get(id);
034            }
035    
036            public static boolean isVendorDB2() {
037                    return _instance._customSQL.isVendorDB2();
038            }
039    
040            public static boolean isVendorInformix() {
041                    return _instance._customSQL.isVendorInformix();
042            }
043    
044            public static boolean isVendorMySQL() {
045                    return _instance._customSQL.isVendorMySQL();
046            }
047    
048            public static boolean isVendorOracle() {
049                    return _instance._customSQL.isVendorOracle();
050            }
051    
052            public static boolean isVendorSybase() {
053                    return _instance._customSQL.isVendorSybase();
054            }
055    
056            public static String[] keywords(String keywords) {
057                    return _instance._customSQL.keywords(keywords);
058            }
059    
060            public static String[] keywords(String keywords, boolean lowerCase) {
061                    return _instance._customSQL.keywords(keywords, lowerCase);
062            }
063    
064            public static String[] keywords(String[] keywordsArray) {
065                    return _instance._customSQL.keywords(keywordsArray);
066            }
067    
068            public static String[] keywords(String[] keywordsArray, boolean lowerCase) {
069                    return _instance._customSQL.keywords(
070                            keywordsArray, lowerCase);
071            }
072    
073            public static String removeGroupBy(String sql) {
074                    return _instance._customSQL.removeGroupBy(sql);
075            }
076    
077            public static String removeOrderBy(String sql) {
078                    return _instance._customSQL.removeOrderBy(sql);
079            }
080    
081            public static String replaceAndOperator(String sql, boolean andOperator) {
082                    return _instance._customSQL.replaceAndOperator(
083                            sql, andOperator);
084            }
085    
086            public static String replaceIsNull(String sql) {
087                    return _instance._customSQL.replaceIsNull(sql);
088            }
089    
090            public static String replaceKeywords(
091                    String sql, String field, boolean last, int[] values) {
092    
093                    return _instance._customSQL.replaceKeywords(sql, field, last, values);
094            }
095    
096            public static String replaceKeywords(
097                    String sql, String field, boolean last, long[] values) {
098    
099                    return _instance._customSQL.replaceKeywords(sql, field, last, values);
100            }
101    
102            public static String replaceKeywords(
103                    String sql, String field, String operator, boolean last,
104                    String[] values) {
105    
106                    return _instance._customSQL.replaceKeywords(
107                            sql, field, operator, last, values);
108            }
109    
110            public static String replaceGroupBy(String sql, String groupBy) {
111                    return _instance._customSQL.replaceGroupBy(sql, groupBy);
112            }
113    
114            public static String replaceOrderBy(String sql, OrderByComparator obc) {
115                    return _instance._customSQL.replaceOrderBy(sql, obc);
116            }
117    
118            private CustomSQLUtil() {
119                    try {
120                            _customSQL = new CustomSQL();
121                    }
122                    catch (Exception e) {
123                            _log.error(e, e);
124                    }
125            }
126    
127            private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
128    
129            private static CustomSQLUtil _instance = new CustomSQLUtil();
130    
131            private CustomSQL _customSQL;
132    
133    }