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.jdbc;
020:
021: import java.sql.Types;
022: import java.util.HashMap;
023: import java.util.Map;
024:
025: import org.netbeans.modules.sql.framework.codegen.AbstractTypeGenerator;
026: import org.netbeans.modules.sql.framework.codegen.DataType;
027:
028: /**
029: * For JDBC or ANSI standard Database code generations.
030: * @author Girish Patil
031: * @version $Revision$
032: */
033: public class JdbcTypeGenerator extends AbstractTypeGenerator {
034:
035: private static HashMap supportedDataTypes;
036:
037: public Map createSupportedDataTypesMap() {
038: if (supportedDataTypes == null) {
039: supportedDataTypes = new HashMap();
040: }
041: supportedDataTypes.put(new Integer(Types.BIT), DataType.BIT);
042: supportedDataTypes.put(new Integer(Types.BOOLEAN),
043: DataType.BOOLEAN);
044:
045: supportedDataTypes.put(new Integer(Types.BIGINT),
046: DataType.BIGINT);
047: supportedDataTypes.put(new Integer(Types.SMALLINT),
048: DataType.SMALLINT);
049: supportedDataTypes.put(new Integer(Types.TINYINT),
050: DataType.TINYINT);
051: supportedDataTypes.put(new Integer(Types.INTEGER),
052: DataType.INTEGER);
053:
054: supportedDataTypes.put(new Integer(Types.DECIMAL),
055: DataType.DECIMAL);
056: supportedDataTypes.put(new Integer(Types.DOUBLE),
057: DataType.DOUBLE_PRECISION);
058: supportedDataTypes
059: .put(new Integer(Types.FLOAT), DataType.FLOAT);
060: supportedDataTypes.put(new Integer(Types.NUMERIC),
061: DataType.NUMERIC);
062: supportedDataTypes.put(new Integer(Types.REAL), DataType.REAL);
063:
064: supportedDataTypes.put(new Integer(Types.DATE), DataType.DATE);
065: supportedDataTypes.put(new Integer(Types.TIME), DataType.TIME);
066: supportedDataTypes.put(new Integer(Types.TIMESTAMP),
067: DataType.TIMESTAMP);
068:
069: supportedDataTypes.put(new Integer(Types.CHAR), DataType.CHAR);
070: supportedDataTypes.put(new Integer(Types.LONGVARCHAR),
071: DataType.LONGVARCHAR);
072: supportedDataTypes.put(new Integer(Types.VARCHAR),
073: DataType.VARCHAR);
074:
075: supportedDataTypes.put(new Integer(Types.JAVA_OBJECT),
076: DataType.JAVA_OBJECT);
077: supportedDataTypes.put(new Integer(Types.OTHER),
078: DataType.VARCHAR);
079:
080: supportedDataTypes.put(new Integer(Types.BINARY),
081: DataType.BINARY);
082: supportedDataTypes.put(new Integer(Types.VARBINARY),
083: DataType.VARBINARY);
084: supportedDataTypes.put(new Integer(Types.LONGVARBINARY),
085: DataType.LONGVARBINARY);
086:
087: supportedDataTypes.put(new Integer(Types.BLOB), DataType.BLOB);
088: supportedDataTypes.put(new Integer(Types.CLOB), DataType.CLOB);
089: supportedDataTypes
090: .put(new Integer(Types.ARRAY), DataType.ARRAY);
091:
092: supportedDataTypes.put(new Integer(Types.DISTINCT),
093: DataType.DISTINCT);
094: supportedDataTypes.put(new Integer(Types.REF), DataType.REF);
095: supportedDataTypes.put(new Integer(Types.STRUCT),
096: DataType.STRUCT);
097: supportedDataTypes.put(new Integer(Types.DATALINK),
098: DataType.DATALINK);
099: supportedDataTypes.put(new Integer(Types.NULL), DataType.NULL);
100:
101: return supportedDataTypes;
102: }
103: }
|