001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.sql.framework.codegen;
042:
043: import java.sql.Types;
044:
045: /**
046: * A class to represents jdbc type and actual keyword for that jdbc type in the database
047: *
048: * @author Ritesh Adval
049: * @author Ahimanikya Satapathy
050: * @version $Revision$
051: * @link http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html
052: */
053: public class DataType {
054:
055: public static final DataType BIT = new DataType(Types.BIT, "bit");
056: public static final DataType BOOLEAN = new DataType(Types.BOOLEAN,
057: "boolean");
058: public static final DataType INTEGER = new DataType(Types.INTEGER,
059: "integer");
060: public static final DataType BIGINT = new DataType(Types.BIGINT,
061: "bigint");
062: public static final DataType TINYINT = new DataType(Types.TINYINT,
063: "tinyint");
064: public static final DataType SMALLINT = new DataType(
065: Types.SMALLINT, "smallint");
066: public static final DataType DOUBLE = new DataType(Types.DOUBLE,
067: "double");
068: public static final DataType DOUBLE_PRECISION = new DataType(
069: Types.DOUBLE, "double precision");
070: public static final DataType FLOAT = new DataType(Types.FLOAT,
071: "float");
072: public static final DataType DECIMAL = new DataType(Types.DECIMAL,
073: "decimal");
074: public static final DataType NUMERIC = new DataType(Types.NUMERIC,
075: "numeric");
076: public static final DataType NUMEBER = new DataType(Types.NUMERIC,
077: "number");
078: public static final DataType REAL = new DataType(Types.REAL, "real");
079: public static final DataType DATE = new DataType(Types.DATE, "date");
080: public static final DataType TIME = new DataType(Types.TIME, "time");
081: public static final DataType TIMESTAMP = new DataType(
082: Types.TIMESTAMP, "timestamp");
083: public static final DataType LONGVARCHAR = new DataType(
084: Types.LONGVARCHAR, "longvarchar");
085: public static final DataType LONG_VARCHAR = new DataType(
086: Types.LONGVARCHAR, "long varchar");
087: public static final DataType VARCHAR = new DataType(Types.VARCHAR,
088: "varchar");
089: public static final DataType CHAR = new DataType(Types.CHAR, "char");
090: public static final DataType JAVA_OBJECT = new DataType(
091: Types.JAVA_OBJECT, "java_object");
092: public static final DataType BINARY = new DataType(Types.BINARY,
093: "binary");
094: public static final DataType VARBINARY = new DataType(
095: Types.VARBINARY, "varbinary");
096: public static final DataType LONGVARBINARY = new DataType(
097: Types.LONGVARBINARY, "longvarbinary");
098: public static final DataType LONG_VARBINARY = new DataType(
099: Types.LONGVARBINARY, "long varbinary");
100: public static final DataType BLOB = new DataType(Types.BLOB, "blob");
101: public static final DataType CLOB = new DataType(Types.CLOB, "clob");
102: public static final DataType ARRAY = new DataType(Types.ARRAY,
103: "array");
104: public static final DataType DISTINCT = new DataType(
105: Types.DISTINCT, "distinct");
106: public static final DataType REF = new DataType(Types.REF, "ref");
107: public static final DataType STRUCT = new DataType(Types.STRUCT,
108: "struct");
109: public static final DataType DATALINK = new DataType(
110: Types.DATALINK, "datalink");
111: public static final DataType NULL = new DataType(Types.NULL, "null");
112: public static final DataType SYBASE_IMAGE = new DataType(
113: Types.LONGVARBINARY, "image");
114: public static final DataType SYBASE_TEXT = new DataType(
115: Types.LONGVARCHAR, "text");
116: public static final DataType SYBASE_DATETIME = new DataType(
117: Types.TIMESTAMP, "datetime");
118: public static final DataType ORACLE_RAW = new DataType(
119: Types.VARBINARY, "raw");
120: public static final DataType ORACLE_LONGRAW = new DataType(
121: Types.LONGVARBINARY, "long raw");
122: public static final DataType ORACLE_VARRAY = new DataType(
123: Types.ARRAY, "varray");
124: public static final DataType ORACLE_OBJECT = new DataType(
125: Types.STRUCT, "object");
126: public static final DataType ORACLE_LONG = new DataType(
127: Types.LONGVARCHAR, "long");
128: private String dataTypeName = null;
129: private int jdbcType = -1;
130:
131: public DataType(int newJdbcType, String dTypeName) {
132: this .jdbcType = newJdbcType;
133: this .dataTypeName = dTypeName;
134: }
135:
136: public int getJdbcType() {
137: return this .jdbcType;
138: }
139:
140: public void setJdbcType(int newJdbcType) {
141: this .jdbcType = newJdbcType;
142: }
143:
144: public String getDataTypeName() {
145: return this .dataTypeName;
146: }
147:
148: public void setDataTypeName(String dTypeName) {
149: this .dataTypeName = dTypeName;
150: }
151:
152: @Override
153: public String toString() {
154: return dataTypeName;
155: }
156: }
|