001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.sql.framework.codegen.base;
020:
021: import java.util.Map;
022:
023: import org.netbeans.modules.sql.framework.codegen.AbstractDB;
024: import org.netbeans.modules.sql.framework.codegen.AbstractGeneratorFactory;
025: import org.netbeans.modules.sql.framework.codegen.SQLOperatorFactory;
026: import org.netbeans.modules.sql.framework.codegen.Statements;
027: import org.netbeans.modules.sql.framework.codegen.TypeGenerator;
028:
029: import com.sun.sql.framework.jdbc.DBConstants;
030:
031: /**
032: * @author Ritesh Adval
033: * @version $Revision$
034: */
035: public class BaseDB extends AbstractDB {
036:
037: private static final String BASE_TEMPLATE_FILE = "/org/netbeans/modules/sql/framework/codegen/base/config/templates.xml";
038:
039: private static final String BASE_OPERATOR_DEFINITION_FILE = "org/netbeans/modules/sql/framework/codegen/base/config/operator-script.xml";
040:
041: protected SQLOperatorFactory factory;
042:
043: public int getCastingRule(int sourceType, int targetType) {
044: return 0;
045: }
046:
047: public String getDefaultDateFormat() {
048: return null;
049: }
050:
051: public String getEscapedName(String name) {
052: return name;
053: }
054:
055: public String getUnescapedName(String name) {
056: return name;
057: }
058:
059: /**
060: * get the name after applying DB specfic escaping.
061: *
062: * @param name name which needs to be escaped.
063: * @return name after escaping it.
064: */
065: public String getEscapedCatalogName(String name) {
066: return this .getEscapedName(name);
067: }
068:
069: /**
070: * get the name after applying DB specfic escaping.
071: *
072: * @param name name which needs to be escaped.
073: * @return name after escaping it.
074: */
075: public String getEscapedSchemaName(String name) {
076: return this .getEscapedName(name);
077: }
078:
079: public int getMaxTableNameLength() {
080: return 0;
081: }
082:
083: public boolean isAnsiJoinSyntaxSupported() {
084: return true;
085: }
086:
087: public AbstractGeneratorFactory createGeneratorFactory() {
088: return new BaseGeneratorFactory(this );
089: }
090:
091: public Statements createStatements() {
092: return new BaseStatements(this );
093: }
094:
095: public TypeGenerator createTypeGenerator() {
096: return new BaseTypeGenerator();
097: }
098:
099: /**
100: * Override this method in a concrete vendor-specific class to load the localized
101: * template file and override any desired template mappings.
102: */
103: protected Map loadTemplates() {
104: templateMaps = loadTemplates(BASE_TEMPLATE_FILE);
105: return templateMaps;
106: }
107:
108: /**
109: * get the operator factory for this data base
110: *
111: * @return operator factory
112: */
113: public SQLOperatorFactory getOperatorFactory() {
114: if (factory == null) {
115: factory = new SQLOperatorFactory(
116: BASE_OPERATOR_DEFINITION_FILE, null);
117: }
118: return factory;
119: }
120:
121: public int getDBType() {
122: return DBConstants.ANSI92;
123: }
124: }
|