001    /**
002     * Copyright (c) 2000-2011 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.portal.dao.db;
016    
017    import com.liferay.portal.kernel.dao.db.DB;
018    import com.liferay.portal.kernel.util.StringUtil;
019    
020    import java.io.IOException;
021    
022    /**
023     * @author Alexander Chow
024     * @author Sandeep Soni
025     * @author Ganesh Ram
026     */
027    public class JDataStoreDB extends FirebirdDB {
028    
029            public static DB getInstance() {
030                    return _instance;
031            }
032    
033            public String buildSQL(String template) throws IOException {
034                    template = convertTimestamp(template);
035                    template = replaceTemplate(template, getTemplate());
036    
037                    template = reword(template);
038                    template = StringUtil.replace(
039                            template,
040                            new String[] {"\\'", "\\\"", "\\\\",  "\\n", "\\r"},
041                            new String[] {"''", "\"", "\\", "\n", "\r"});
042    
043                    return template;
044            }
045    
046            protected JDataStoreDB() {
047                    super(TYPE_JDATASTORE);
048            }
049    
050            protected String getServerName() {
051                    return "jdatastore";
052            }
053    
054            protected String[] getTemplate() {
055                    return _JDATASTORE;
056            }
057    
058            private static String[] _JDATASTORE = {
059                    "--", "TRUE", "FALSE",
060                    "'1970-01-01'", "current_timestamp",
061                    " binary", " boolean", " date",
062                    " double", " integer", " bigint",
063                    " long varchar", " long varchar", " varchar",
064                    "", "commit"
065            };
066    
067            private static JDataStoreDB _instance = new JDataStoreDB();
068    
069    }