You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2010/04/13 19:41:48 UTC

svn commit: r933717 - /db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java

Author: tfischer
Date: Tue Apr 13 17:41:47 2010
New Revision: 933717

URL: http://svn.apache.org/viewvc?rev=933717&view=rev
Log:
added a reference to the corresponding jdbc types

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java?rev=933717&r1=933716&r2=933717&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java Tue Apr 13 17:41:47 2010
@@ -1,5 +1,7 @@
 package org.apache.torque.templates.typemapping;
 
+import java.sql.Types;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -28,34 +30,80 @@ package org.apache.torque.templates.type
  */
 public enum SchemaType
 {
-    BIT,
-    TINYINT,
-    SMALLINT,
-    INTEGER,
-    BIGINT,
-    FLOAT,
-    REAL,
-    NUMERIC,
-    DECIMAL,
-    CHAR,
-    VARCHAR,
-    LONGVARCHAR,
-    DATE,
-    TIME,
-    TIMESTAMP,
-    BINARY,
-    VARBINARY,
-    LONGVARBINARY,
-    NULL,
-    OTHER,
-    JAVA_OBJECT,
-    DISTINCT,
-    STRUCT,
-    ARRAY,
-    BLOB,
-    CLOB,
-    REF,
-    BOOLEANINT,
-    BOOLEANCHAR,
-    DOUBLE;
+    BIT(Types.BIT),
+    TINYINT(Types.TINYINT),
+    SMALLINT(Types.SMALLINT),
+    INTEGER(Types.INTEGER),
+    BIGINT(Types.BIGINT),
+    FLOAT(Types.FLOAT),
+    REAL(Types.REAL),
+    NUMERIC(Types.NUMERIC),
+    DECIMAL(Types.DECIMAL),
+    CHAR(Types.CHAR),
+    VARCHAR(Types.VARCHAR),
+    LONGVARCHAR(Types.LONGVARCHAR),
+    DATE(Types.DATE),
+    TIME(Types.TIME),
+    TIMESTAMP(Types.TIMESTAMP),
+    BINARY(Types.BINARY),
+    VARBINARY(Types.VARBINARY),
+    LONGVARBINARY(Types.LONGVARBINARY),
+    NULL(Types.NULL),
+    OTHER(Types.OTHER),
+    JAVA_OBJECT(Types.JAVA_OBJECT),
+    DISTINCT(Types.DISTINCT),
+    STRUCT(Types.STRUCT),
+    ARRAY(Types.ARRAY),
+    BLOB(Types.BLOB),
+    CLOB(Types.CLOB),
+    REF(Types.REF),
+    BOOLEANINT(null),
+    BOOLEANCHAR(null),
+    DOUBLE(Types.DOUBLE);
+    
+    /** 
+     * The corresponding jdbc type,
+     * may be null if no corresponding type exists.
+     */
+    private Integer jdbcType;
+    
+    private SchemaType(Integer jdbcType)
+    {
+        this.jdbcType = jdbcType;
+    }
+    
+    /**
+     * Returns the corresponding jdbc type.
+     *
+     * @return the corresponding jdbc type, or null if no corresponding 
+     *         type exists.
+     */
+    public Integer getJdbcType()
+    {
+        return jdbcType;
+    }
+
+    /**
+     * Returns the schema type which corresponds to the given jdbc type.
+     * 
+     * @param jdbcType the jdbc type.
+     * 
+     * @return the corresponding schema type, or null if no schema type
+     *         corresponds to the jdbc type.
+     */
+    public static SchemaType getByJdbcType(Integer jdbcType)
+    {
+        if (jdbcType == null)
+        {
+            return null;
+        }
+        for (SchemaType schemaType : values())            
+        {
+            if (jdbcType.equals(schemaType.jdbcType))
+            {
+                return schemaType;
+            }
+        }
+        return null;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org