01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19: package org.netbeans.modules.sql.framework.codegen.derby;
20:
21: import java.util.Map;
22: import org.netbeans.modules.sql.framework.codegen.AbstractGeneratorFactory;
23: import org.netbeans.modules.sql.framework.codegen.SQLOperatorFactory;
24: import org.netbeans.modules.sql.framework.codegen.Statements;
25: import org.netbeans.modules.sql.framework.codegen.TypeGenerator;
26: import org.netbeans.modules.sql.framework.codegen.base.BaseDB;
27:
28: /**
29: * For Derby Database code generations using from JDBC Code generation.
30: * @author karthik
31: */
32: public class DerbyDB extends BaseDB {
33:
34: /* Defines relative location of vendor-specific template configuration resource file. */
35: private static final String TEMPLATE_FILE = "/org/netbeans/modules/sql/framework/codegen/derby/config/templates.xml";
36: /* Reference to JDBC operatordef info file. */
37: private static final String DERBY_OPERATOR_DEFINITION_FILE = "org/netbeans/modules/sql/framework/codegen/derby/config/operator-script.xml";
38:
39: @Override
40: public Statements createStatements() {
41: return new DerbyStatements(this );
42: }
43:
44: @Override
45: public String getEscapedName(String name) {
46: StringBuffer escapedName = new StringBuffer(50);
47:
48: escapedName.append("\"");
49: escapedName.append(name);
50: escapedName.append("\"");
51:
52: return escapedName.toString();
53: }
54:
55: @Override
56: public TypeGenerator createTypeGenerator() {
57: return new DerbyTypeGenerator();
58: }
59:
60: @Override
61: @SuppressWarnings(value="unchecked")
62: protected Map loadTemplates() {
63: super .loadTemplates();
64:
65: Map localMap = loadTemplates(TEMPLATE_FILE);
66: this .templateMaps.putAll(localMap);
67:
68: return this .templateMaps;
69: }
70:
71: @Override
72: public SQLOperatorFactory getOperatorFactory() {
73: if (factory == null) {
74: factory = new SQLOperatorFactory(
75: DERBY_OPERATOR_DEFINITION_FILE, super
76: .getOperatorFactory());
77: }
78: return factory;
79: }
80:
81: @Override
82: public AbstractGeneratorFactory createGeneratorFactory() {
83: return new DerbyGeneratorFactory(this );
84: }
85:
86: @Override
87: public int getDBType() {
88: return DERBYDB;
89: }
90: }
|