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.axion;
020:
021: import java.util.Map;
022:
023: import org.netbeans.modules.sql.framework.codegen.AbstractGeneratorFactory;
024: import org.netbeans.modules.sql.framework.codegen.SQLOperatorFactory;
025: import org.netbeans.modules.sql.framework.codegen.Statements;
026: import org.netbeans.modules.sql.framework.codegen.TypeGenerator;
027: import org.netbeans.modules.sql.framework.codegen.base.BaseDB;
028: import org.netbeans.modules.sql.framework.codegen.base.BaseGeneratorFactory;
029:
030: /**
031: * @author Ritesh Adval
032: * @version $Revision$
033: */
034: public class AxionDB extends BaseDB {
035:
036: /* Defines relative location of vendor-specific template configuration resource file. */
037: private static final String TEMPLATE_FILE = "/org/netbeans/modules/sql/framework/codegen/axion/config/templates.xml";
038:
039: /* Reference to oracle8 operatordef info file. */
040: private static final String AXION_OPERATOR_DEFINITION_FILE = "org/netbeans/modules/sql/framework/codegen/axion/config/operator-script.xml";
041:
042: private static final String START_ESCAPE_CHAR = "\"";
043: private static final String END_ESCAPE_CHAR = "\"";
044:
045: private AxionPipelineStatements pipelineStatements;
046: private boolean columnsAreCaseSensitive = false;
047:
048: public String getEscapedName(String name) {
049: StringBuilder escapedName = new StringBuilder(50);
050:
051: escapedName.append(START_ESCAPE_CHAR);
052: escapedName.append(columnsAreCaseSensitive ? name : name
053: .toUpperCase());
054: escapedName.append(END_ESCAPE_CHAR);
055:
056: return escapedName.toString();
057: }
058:
059: public String getUnescapedName(String name) {
060: if (name.startsWith(START_ESCAPE_CHAR)) {
061: name = name.substring(START_ESCAPE_CHAR.length());
062: }
063:
064: if (name.endsWith(END_ESCAPE_CHAR)) {
065: name = name.substring(0, name.length()
066: - END_ESCAPE_CHAR.length());
067: }
068:
069: return name.toUpperCase();
070: }
071:
072: public Statements createStatements() {
073: return new AxionStatements(this );
074: }
075:
076: public AbstractGeneratorFactory createGeneratorFactory() {
077: return new BaseGeneratorFactory(this );
078: }
079:
080: public TypeGenerator createTypeGenerator() {
081: return new AxionTypeGenerator();
082: }
083:
084: protected Map loadTemplates() {
085: super .loadTemplates();
086:
087: Map localMap = loadTemplates(TEMPLATE_FILE);
088: this .templateMaps.putAll(localMap);
089:
090: return this .templateMaps;
091: }
092:
093: /**
094: * Gets Operator factory for Axion
095: *
096: * @return SQLOperatorFactory
097: */
098: public SQLOperatorFactory getOperatorFactory() {
099: if (factory == null) {
100: factory = new SQLOperatorFactory(
101: AXION_OPERATOR_DEFINITION_FILE, super
102: .getOperatorFactory());
103: }
104: return factory;
105: }
106:
107: public AxionPipelineStatements getAxionPipelineStatements() {
108: if (pipelineStatements == null) {
109: pipelineStatements = new AxionPipelineStatements(this );
110: }
111: return pipelineStatements;
112: }
113:
114: public void setColumnsAreCaseSensitive(boolean caseSensitive) {
115: this .columnsAreCaseSensitive = caseSensitive;
116: }
117:
118: public int getDBType() {
119: return AXIONDB;
120: }
121:
122: }
|