db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/generator/src/test/org/apache/torque/engine/database/model TypeMapTest.java
Date Tue, 25 Nov 2003 19:19:06 GMT
mpoeschl    2003/11/25 11:19:06

  Modified:    src/generator/src/java/org/apache/torque/task
                        TorqueJDBCTransformTask.java
               src/generator/src/java/org/apache/torque/engine/database/model
                        TypeMap.java Domain.java Column.java
               xdocs    changes.xml
  Added:       src/generator/src/test/org/apache/torque/engine/database/model
                        TypeMapTest.java
  Log:
  use Domain in Column
  replace String with SchemaType
  
  Revision  Changes    Path
  1.7       +2 -2      db-torque/src/generator/src/java/org/apache/torque/task/TorqueJDBCTransformTask.java
  
  Index: TorqueJDBCTransformTask.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/task/TorqueJDBCTransformTask.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TorqueJDBCTransformTask.java	22 Aug 2003 17:01:42 -0000	1.6
  +++ TorqueJDBCTransformTask.java	25 Nov 2003 19:19:06 -0000	1.7
  @@ -312,7 +312,7 @@
                   {
                       column.setAttribute("javaName", name);
                   }
  -                column.setAttribute("type", TypeMap.getTorqueType(type));
  +                column.setAttribute("type", TypeMap.getTorqueType(type).getName());
   
                   if (size > 0 && (type.intValue() == Types.CHAR
                           || type.intValue() == Types.VARCHAR
  
  
  
  1.3       +169 -220  db-torque/src/generator/src/java/org/apache/torque/engine/database/model/TypeMap.java
  
  Index: TypeMap.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/TypeMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeMap.java	24 Jun 2003 11:10:32 -0000	1.2
  +++ TypeMap.java	25 Nov 2003 19:19:06 -0000	1.3
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -55,6 +55,7 @@
    */
   
   import java.util.Hashtable;
  +import java.util.Iterator;
   import java.sql.Types;
   
   // I don't know if the peer system deals
  @@ -104,36 +105,16 @@
    * </pre>
    *
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  + * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
    * @version $Id$
    */
   public class TypeMap
   {
  -    public static final String CHAR = "CHAR";
  -    public static final String VARCHAR = "VARCHAR";
  -    public static final String LONGVARCHAR = "LONGVARCHAR";
  -    public static final String CLOB = "CLOB";
  -    public static final String NUMERIC = "NUMERIC";
  -    public static final String DECIMAL = "DECIMAL";
  -    public static final String BIT = "BIT";
  -    public static final String TINYINT = "TINYINT";
  -    public static final String SMALLINT = "SMALLINT";
  -    public static final String INTEGER = "INTEGER";
  -    public static final String BIGINT = "BIGINT";
  -    public static final String REAL = "REAL";
  -    public static final String FLOAT = "FLOAT";
  -    public static final String DOUBLE = "DOUBLE";
  -    public static final String BINARY = "BINARY";
  -    public static final String VARBINARY = "VARBINARY";
  -    public static final String LONGVARBINARY = "LONGVARBINARY";
  -    public static final String BLOB = "BLOB";
  -    public static final String DATE = "DATE";
  -    public static final String TIME = "TIME";
  -    public static final String TIMESTAMP = "TIMESTAMP";
  -    public static final String BOOLEANCHAR = "BOOLEANCHAR";
  -    public static final String BOOLEANINT = "BOOLEANINT";
  -    private static final String[] TEXT_TYPES =
  +    private static final SchemaType[] TEXT_TYPES =
       {
  -        CHAR, VARCHAR, LONGVARCHAR, CLOB, DATE, TIME, TIMESTAMP, BOOLEANCHAR
  +        SchemaType.CHAR, SchemaType.VARCHAR, SchemaType.LONGVARCHAR, 
  +        SchemaType.CLOB, SchemaType.DATE, SchemaType.TIME, 
  +        SchemaType.TIMESTAMP, SchemaType.BOOLEANCHAR
       };
   
       public static final String CHAR_OBJECT_TYPE = "new String()";
  @@ -270,214 +251,182 @@
       {
           if (!isInitialized)
           {
  -            /*
  -             * Create JDBC -> Java object mappings.
  -             */
  -
  +            // Create JDBC -> Java object mappings.
               jdbcToJavaObjectMap = new Hashtable();
   
  -            jdbcToJavaObjectMap.put(CHAR, CHAR_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(VARCHAR, VARCHAR_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(LONGVARCHAR, LONGVARCHAR_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(CLOB, CLOB_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(NUMERIC, NUMERIC_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(DECIMAL, DECIMAL_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(BIT, BIT_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(TINYINT, TINYINT_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(SMALLINT, SMALLINT_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(INTEGER, INTEGER_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(BIGINT, BIGINT_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(REAL, REAL_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(FLOAT, FLOAT_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(DOUBLE, DOUBLE_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(BINARY, BINARY_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(VARBINARY, VARBINARY_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(LONGVARBINARY, LONGVARBINARY_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(BLOB, BLOB_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(DATE, DATE_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(TIME, TIME_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(TIMESTAMP, TIMESTAMP_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(BOOLEANCHAR, BOOLEANCHAR_OBJECT_TYPE);
  -            jdbcToJavaObjectMap.put(BOOLEANINT, BOOLEANINT_OBJECT_TYPE);
  -
  -            /*
  -             * Create JDBC -> native Java type mappings.
  -             */
  +            jdbcToJavaObjectMap.put(SchemaType.CHAR, CHAR_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.VARCHAR, VARCHAR_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.LONGVARCHAR, LONGVARCHAR_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.CLOB, CLOB_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.NUMERIC, NUMERIC_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.DECIMAL, DECIMAL_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.BIT, BIT_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.TINYINT, TINYINT_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.SMALLINT, SMALLINT_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.INTEGER, INTEGER_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.BIGINT, BIGINT_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.REAL, REAL_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.FLOAT, FLOAT_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.DOUBLE, DOUBLE_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.BINARY, BINARY_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.VARBINARY, VARBINARY_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.LONGVARBINARY, LONGVARBINARY_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.BLOB, BLOB_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.DATE, DATE_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.TIME, TIME_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.TIMESTAMP, TIMESTAMP_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.BOOLEANCHAR, BOOLEANCHAR_OBJECT_TYPE);
  +            jdbcToJavaObjectMap.put(SchemaType.BOOLEANINT, BOOLEANINT_OBJECT_TYPE);
   
  +            // Create JDBC -> native Java type mappings.
               jdbcToJavaNativeMap = new Hashtable();
   
  -            jdbcToJavaNativeMap.put(CHAR, CHAR_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(VARCHAR, VARCHAR_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(LONGVARCHAR, LONGVARCHAR_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(CLOB, CLOB_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(NUMERIC, NUMERIC_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(DECIMAL, DECIMAL_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(BIT, BIT_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(TINYINT, TINYINT_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(SMALLINT, SMALLINT_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(INTEGER, INTEGER_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(BIGINT, BIGINT_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(REAL, REAL_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(FLOAT, FLOAT_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(DOUBLE, DOUBLE_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(BINARY, BINARY_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(VARBINARY, VARBINARY_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(LONGVARBINARY, LONGVARBINARY_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(BLOB, BLOB_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(DATE, DATE_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(TIME, TIME_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(TIMESTAMP, TIMESTAMP_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(BOOLEANCHAR, BOOLEANCHAR_NATIVE_TYPE);
  -            jdbcToJavaNativeMap.put(BOOLEANINT, BOOLEANINT_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.CHAR, CHAR_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.VARCHAR, VARCHAR_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.LONGVARCHAR, LONGVARCHAR_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.CLOB, CLOB_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.NUMERIC, NUMERIC_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.DECIMAL, DECIMAL_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.BIT, BIT_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.TINYINT, TINYINT_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.SMALLINT, SMALLINT_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.INTEGER, INTEGER_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.BIGINT, BIGINT_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.REAL, REAL_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.FLOAT, FLOAT_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.DOUBLE, DOUBLE_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.BINARY, BINARY_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.VARBINARY, VARBINARY_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.LONGVARBINARY, LONGVARBINARY_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.BLOB, BLOB_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.DATE, DATE_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.TIME, TIME_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.TIMESTAMP, TIMESTAMP_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.BOOLEANCHAR, BOOLEANCHAR_NATIVE_TYPE);
  +            jdbcToJavaNativeMap.put(SchemaType.BOOLEANINT, BOOLEANINT_NATIVE_TYPE);
   
               jdbcToJavaNativeObjectMap = new Hashtable();
  -            jdbcToJavaNativeObjectMap.put(BIT, BIT_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(TINYINT, TINYINT_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(SMALLINT, SMALLINT_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(INTEGER, INTEGER_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(BIGINT, BIGINT_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(REAL, REAL_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(FLOAT, FLOAT_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(DOUBLE, DOUBLE_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(BOOLEANCHAR,
  +            jdbcToJavaNativeObjectMap.put(SchemaType.BIT, BIT_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.TINYINT, TINYINT_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.SMALLINT, SMALLINT_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.INTEGER, INTEGER_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.BIGINT, BIGINT_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.REAL, REAL_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.FLOAT, FLOAT_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.DOUBLE, DOUBLE_NATIVE_OBJECT_TYPE);
  +            jdbcToJavaNativeObjectMap.put(SchemaType.BOOLEANCHAR,
                                             BOOLEANCHAR_NATIVE_OBJECT_TYPE);
  -            jdbcToJavaNativeObjectMap.put(BOOLEANINT,
  +            jdbcToJavaNativeObjectMap.put(SchemaType.BOOLEANINT,
                                             BOOLEANINT_NATIVE_OBJECT_TYPE);
   
  -            /*
  -             * Create JDBC -> Village asX() mappings.
  -             */
  -
  +            // Create JDBC -> Village asX() mappings.
               jdbcToVillageMethodMap = new Hashtable();
   
  -            jdbcToVillageMethodMap.put(CHAR, CHAR_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(VARCHAR, VARCHAR_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(LONGVARCHAR, LONGVARCHAR_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(CLOB, CLOB_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(NUMERIC, NUMERIC_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(DECIMAL, DECIMAL_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(BIT, BIT_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(TINYINT, TINYINT_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(SMALLINT, SMALLINT_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(INTEGER, INTEGER_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(BIGINT, BIGINT_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(REAL, REAL_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(FLOAT, FLOAT_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(DOUBLE, DOUBLE_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(BINARY, BINARY_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(VARBINARY, VARBINARY_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(LONGVARBINARY, LONGVARBINARY_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(BLOB, BLOB_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(DATE, DATE_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(TIME, TIME_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(TIMESTAMP, TIMESTAMP_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(BOOLEANCHAR, BOOLEANCHAR_VILLAGE_METHOD);
  -            jdbcToVillageMethodMap.put(BOOLEANINT, BOOLEANINT_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.CHAR, CHAR_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.VARCHAR, VARCHAR_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.LONGVARCHAR, LONGVARCHAR_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.CLOB, CLOB_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.NUMERIC, NUMERIC_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.DECIMAL, DECIMAL_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.BIT, BIT_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.TINYINT, TINYINT_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.SMALLINT, SMALLINT_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.INTEGER, INTEGER_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.BIGINT, BIGINT_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.REAL, REAL_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.FLOAT, FLOAT_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.DOUBLE, DOUBLE_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.BINARY, BINARY_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.VARBINARY, VARBINARY_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.LONGVARBINARY, LONGVARBINARY_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.BLOB, BLOB_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.DATE, DATE_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.TIME, TIME_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.TIMESTAMP, TIMESTAMP_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.BOOLEANCHAR, BOOLEANCHAR_VILLAGE_METHOD);
  +            jdbcToVillageMethodMap.put(SchemaType.BOOLEANINT, BOOLEANINT_VILLAGE_METHOD);
   
   
               jdbcToVillageObjectMethodMap = new Hashtable();
  -            jdbcToVillageObjectMethodMap.put(BIT, BIT_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(TINYINT,
  +            jdbcToVillageObjectMethodMap.put(SchemaType.BIT, BIT_VILLAGE_OBJECT_METHOD);
  +            jdbcToVillageObjectMethodMap.put(SchemaType.TINYINT,
                                                TINYINT_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(SMALLINT,
  +            jdbcToVillageObjectMethodMap.put(SchemaType.SMALLINT,
                                                SMALLINT_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(INTEGER,
  +            jdbcToVillageObjectMethodMap.put(SchemaType.INTEGER,
                                                INTEGER_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(BIGINT,
  +            jdbcToVillageObjectMethodMap.put(SchemaType.BIGINT,
                                                BIGINT_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(REAL, REAL_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(FLOAT, FLOAT_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(DOUBLE,
  +            jdbcToVillageObjectMethodMap.put(SchemaType.REAL, REAL_VILLAGE_OBJECT_METHOD);
  +            jdbcToVillageObjectMethodMap.put(SchemaType.FLOAT, FLOAT_VILLAGE_OBJECT_METHOD);
  +            jdbcToVillageObjectMethodMap.put(SchemaType.DOUBLE,
                                                DOUBLE_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(BOOLEANCHAR,
  +            jdbcToVillageObjectMethodMap.put(SchemaType.BOOLEANCHAR,
                                                BOOLEANCHAR_VILLAGE_OBJECT_METHOD);
  -            jdbcToVillageObjectMethodMap.put(BOOLEANINT,
  +            jdbcToVillageObjectMethodMap.put(SchemaType.BOOLEANINT,
                                                BOOLEANINT_VILLAGE_OBJECT_METHOD);
   
  -            /*
  -             * Create JDBC -> ParameterParser getX() mappings.
  -             */
  -
  +            // Create JDBC -> ParameterParser getX() mappings.
               jdbcToPPMethodMap = new Hashtable();
   
  -            jdbcToPPMethodMap.put(CHAR, CHAR_PP_METHOD);
  -            jdbcToPPMethodMap.put(VARCHAR, VARCHAR_PP_METHOD);
  -            jdbcToPPMethodMap.put(LONGVARCHAR, LONGVARCHAR_PP_METHOD);
  -            jdbcToPPMethodMap.put(NUMERIC, NUMERIC_PP_METHOD);
  -            jdbcToPPMethodMap.put(DECIMAL, DECIMAL_PP_METHOD);
  -            jdbcToPPMethodMap.put(BIT, BIT_PP_METHOD);
  -            jdbcToPPMethodMap.put(TINYINT, TINYINT_PP_METHOD);
  -            jdbcToPPMethodMap.put(SMALLINT, SMALLINT_PP_METHOD);
  -            jdbcToPPMethodMap.put(INTEGER, INTEGER_PP_METHOD);
  -            jdbcToPPMethodMap.put(BIGINT, BIGINT_PP_METHOD);
  -            jdbcToPPMethodMap.put(REAL, REAL_PP_METHOD);
  -            jdbcToPPMethodMap.put(FLOAT, FLOAT_PP_METHOD);
  -            jdbcToPPMethodMap.put(DOUBLE, DOUBLE_PP_METHOD);
  -            jdbcToPPMethodMap.put(BINARY, BINARY_PP_METHOD);
  -            jdbcToPPMethodMap.put(VARBINARY, VARBINARY_PP_METHOD);
  -            jdbcToPPMethodMap.put(LONGVARBINARY, LONGVARBINARY_PP_METHOD);
  -            jdbcToPPMethodMap.put(DATE, DATE_PP_METHOD);
  -            jdbcToPPMethodMap.put(TIME, TIME_PP_METHOD);
  -            jdbcToPPMethodMap.put(TIMESTAMP, TIMESTAMP_PP_METHOD);
  -            jdbcToPPMethodMap.put(BOOLEANCHAR, BOOLEANCHAR_PP_METHOD);
  -            jdbcToPPMethodMap.put(BOOLEANINT, BOOLEANINT_PP_METHOD);
  -
  -            /*
  -             * Create JDBC -> Java object mappings.
  -             */
  +            jdbcToPPMethodMap.put(SchemaType.CHAR, CHAR_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.VARCHAR, VARCHAR_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.LONGVARCHAR, LONGVARCHAR_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.NUMERIC, NUMERIC_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.DECIMAL, DECIMAL_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.BIT, BIT_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.TINYINT, TINYINT_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.SMALLINT, SMALLINT_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.INTEGER, INTEGER_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.BIGINT, BIGINT_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.REAL, REAL_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.FLOAT, FLOAT_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.DOUBLE, DOUBLE_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.BINARY, BINARY_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.VARBINARY, VARBINARY_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.LONGVARBINARY, LONGVARBINARY_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.DATE, DATE_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.TIME, TIME_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.TIMESTAMP, TIMESTAMP_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.BOOLEANCHAR, BOOLEANCHAR_PP_METHOD);
  +            jdbcToPPMethodMap.put(SchemaType.BOOLEANINT, BOOLEANINT_PP_METHOD);
   
  +            // Create JDBC -> Java object mappings.
               torqueTypeToJdbcTypeMap = new Hashtable();
   
  -            torqueTypeToJdbcTypeMap.put(CHAR, CHAR);
  -            torqueTypeToJdbcTypeMap.put(VARCHAR, VARCHAR);
  -            torqueTypeToJdbcTypeMap.put(LONGVARCHAR, LONGVARCHAR);
  -            torqueTypeToJdbcTypeMap.put(CLOB, CLOB);
  -            torqueTypeToJdbcTypeMap.put(NUMERIC, NUMERIC);
  -            torqueTypeToJdbcTypeMap.put(DECIMAL, DECIMAL);
  -            torqueTypeToJdbcTypeMap.put(BIT, BIT);
  -            torqueTypeToJdbcTypeMap.put(TINYINT, TINYINT);
  -            torqueTypeToJdbcTypeMap.put(SMALLINT, SMALLINT);
  -            torqueTypeToJdbcTypeMap.put(INTEGER, INTEGER);
  -            torqueTypeToJdbcTypeMap.put(BIGINT, BIGINT);
  -            torqueTypeToJdbcTypeMap.put(REAL, REAL);
  -            torqueTypeToJdbcTypeMap.put(FLOAT, FLOAT);
  -            torqueTypeToJdbcTypeMap.put(DOUBLE, DOUBLE);
  -            torqueTypeToJdbcTypeMap.put(BINARY, BINARY);
  -            torqueTypeToJdbcTypeMap.put(VARBINARY, VARBINARY);
  -            torqueTypeToJdbcTypeMap.put(LONGVARBINARY, LONGVARBINARY);
  -            torqueTypeToJdbcTypeMap.put(BLOB, BLOB);
  -            torqueTypeToJdbcTypeMap.put(DATE, DATE);
  -            torqueTypeToJdbcTypeMap.put(TIME, TIME);
  -            torqueTypeToJdbcTypeMap.put(TIMESTAMP, TIMESTAMP);
  -            torqueTypeToJdbcTypeMap.put(BOOLEANCHAR, CHAR);
  -            torqueTypeToJdbcTypeMap.put(BOOLEANINT, INTEGER);
  -
  -            /*
  -             * Create JDBC type code to torque type map.
  -             */
  +            Iterator iter = SchemaType.iterator();
  +            while (iter.hasNext()) 
  +            {
  +                SchemaType type = (SchemaType) iter.next();
  +                torqueTypeToJdbcTypeMap.put(type, type);
  +            }
  +            torqueTypeToJdbcTypeMap.put(SchemaType.BOOLEANCHAR, SchemaType.CHAR);
  +            torqueTypeToJdbcTypeMap.put(SchemaType.BOOLEANINT, SchemaType.INTEGER);
  +
  +            // Create JDBC type code to torque type map.
               jdbcToTorqueTypeMap = new Hashtable();
   
  -            jdbcToTorqueTypeMap.put(new Integer(Types.CHAR), CHAR);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.VARCHAR), VARCHAR);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.LONGVARCHAR), LONGVARCHAR);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.CLOB), CLOB);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.NUMERIC), NUMERIC);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.DECIMAL), DECIMAL);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.BIT), BIT);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.TINYINT), TINYINT);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.SMALLINT), SMALLINT);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.INTEGER), INTEGER);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.BIGINT), BIGINT);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.REAL), REAL);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.FLOAT), FLOAT);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.DOUBLE), DOUBLE);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.BINARY), BINARY);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.VARBINARY), VARBINARY);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.LONGVARBINARY), LONGVARBINARY);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.BLOB), BLOB);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.DATE), DATE);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.TIME), TIME);
  -            jdbcToTorqueTypeMap.put(new Integer(Types.TIMESTAMP), TIMESTAMP);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.CHAR), SchemaType.CHAR);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.VARCHAR), SchemaType.VARCHAR);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.LONGVARCHAR), SchemaType.LONGVARCHAR);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.CLOB), SchemaType.CLOB);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.NUMERIC), SchemaType.NUMERIC);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.DECIMAL), SchemaType.DECIMAL);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.BIT), SchemaType.BIT);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.TINYINT), SchemaType.TINYINT);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.SMALLINT), SchemaType.SMALLINT);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.INTEGER), SchemaType.INTEGER);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.BIGINT), SchemaType.BIGINT);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.REAL), SchemaType.REAL);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.FLOAT), SchemaType.FLOAT);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.DOUBLE), SchemaType.DOUBLE);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.BINARY), SchemaType.BINARY);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.VARBINARY), SchemaType.VARBINARY);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.LONGVARBINARY), SchemaType.LONGVARBINARY);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.BLOB), SchemaType.BLOB);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.DATE), SchemaType.DATE);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.TIME), SchemaType.TIME);
  +            jdbcToTorqueTypeMap.put(new Integer(Types.TIMESTAMP), SchemaType.TIMESTAMP);
   
               isInitialized = true;
           }
  @@ -500,7 +449,7 @@
        * @param jdbcType the JDBC type
        * @return name of the Object
        */
  -    public static String getJavaObject(String jdbcType)
  +    public static String getJavaObject(SchemaType jdbcType)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
  @@ -517,7 +466,7 @@
        * @param jdbcType the JDBC type
        * @return name of the native java type
        */
  -    public static String getJavaNative(String jdbcType)
  +    public static String getJavaNative(SchemaType jdbcType)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
  @@ -534,7 +483,7 @@
        * @param jdbcType the JDBC type
        * @return name of the Object
        */
  -    public static String getJavaNativeObject(String jdbcType)
  +    public static String getJavaNativeObject(SchemaType jdbcType)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
  @@ -556,7 +505,7 @@
        * @param jdbcType the JDBC type
        * @return name of the Village asX() method
        */
  -    public static String getVillageMethod(String jdbcType)
  +    public static String getVillageMethod(SchemaType jdbcType)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
  @@ -573,7 +522,7 @@
        * @param jdbcType the JDBC type
        * @return name of the Village asX() method
        */
  -    public static String getVillageObjectMethod(String jdbcType)
  +    public static String getVillageObjectMethod(SchemaType jdbcType)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
  @@ -595,7 +544,7 @@
        * @param jdbcType the JDBC type
        * @return name of the ParameterParser getX() method
        */
  -    public static String getPPMethod(String jdbcType)
  +    public static String getPPMethod(SchemaType jdbcType)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
  @@ -611,14 +560,14 @@
        * @param type the torque added type
        * @return name of the the correct jdbc type
        */
  -    public static String getJdbcType(String type)
  +    public static SchemaType getJdbcType(SchemaType type)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
           {
               initialize();
           }
  -        return (String) torqueTypeToJdbcTypeMap.get(type);
  +        return (SchemaType) torqueTypeToJdbcTypeMap.get(type);
       }
   
       /**
  @@ -628,14 +577,14 @@
        * @param sqlType the SQL type
        * @return Torque type constant
        */
  -    public static String getTorqueType(Integer sqlType)
  +    public static SchemaType getTorqueType(Integer sqlType)
       {
           // Make sure the we are initialized.
           if (!isInitialized)
           {
               initialize();
           }
  -        return (String) jdbcToTorqueTypeMap.get(sqlType);
  +        return (SchemaType) jdbcToTorqueTypeMap.get(sqlType);
       }
   
       /**
  @@ -645,9 +594,9 @@
        * @param type The type to check.
        * @return true if the type is BOOLEANINT
        */
  -    public static boolean isBooleanInt(String type)
  +    public static boolean isBooleanInt(SchemaType type)
       {
  -        return BOOLEANINT.equals(type);
  +        return SchemaType.BOOLEANINT.equals(type);
       }
   
       /**
  @@ -657,9 +606,9 @@
        * @param type The type to check.
        * @return true if the type is BOOLEANCHAR
        */
  -    public static boolean isBooleanChar(String type)
  +    public static boolean isBooleanChar(SchemaType type)
       {
  -        return BOOLEANCHAR.equals(type);
  +        return SchemaType.BOOLEANCHAR.equals(type);
       }
   
       /**
  @@ -668,7 +617,7 @@
        * @param type The type to check.
        * @return true if values for the type need to be quoted.
        */
  -    public static final boolean isTextType(String type)
  +    public static final boolean isTextType(SchemaType type)
       {
           for (int i = 0; i < TEXT_TYPES.length; i++)
           {
  
  
  
  1.4       +76 -1     db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Domain.java
  
  Index: Domain.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Domain.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Domain.java	16 Nov 2003 20:16:54 -0000	1.3
  +++ Domain.java	25 Nov 2003 19:19:06 -0000	1.4
  @@ -54,6 +54,7 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.commons.lang.StringUtils;
   import org.xml.sax.Attributes;
   
   /**
  @@ -135,6 +136,17 @@
           this.size = size;
       }
       
  +    public Domain(Domain domain)
  +    {
  +        this.defaultValue = domain.getDefaultValue();
  +        this.description = domain.getDescription();
  +        this.name = domain.getName();
  +        this.scale = domain.getScale();
  +        this.size = domain.getSize();
  +        this.sqlType = domain.getSqlType();
  +        this.torqueType = domain.getType();
  +    }
  +    
       /**
        * Imports a column from an XML specification
        */
  @@ -199,6 +211,16 @@
       {
           this.scale = scale;
       }
  +    
  +    /**
  +     * Replaces the size if the new value is not null.
  +     * 
  +     * @param value The size to set.
  +     */
  +    public void replaceScale(String value)
  +    {
  +        this.scale = StringUtils.defaultString(value, getScale());
  +    }
   
       /**
        * @return Returns the size.
  @@ -215,6 +237,16 @@
       {
           this.size = size;
       }
  +    
  +    /**
  +     * Replaces the size if the new value is not null.
  +     * 
  +     * @param value The size to set.
  +     */
  +    public void replaceSize(String value)
  +    {
  +        this.size = StringUtils.defaultString(value, getSize());
  +    }
   
       /**
        * @return Returns the torqueType.
  @@ -241,6 +273,17 @@
       }
       
       /**
  +     * Replaces the default value if the new value is not null.
  +     * 
  +     * @param value The defaultValue to set.
  +     */
  +    public void replaceType(String value)
  +    {
  +        this.torqueType = SchemaType.getEnum(
  +                StringUtils.defaultString(value, getType().getName()));
  +    }
  +    
  +    /**
        * @return Returns the defaultValue.
        */
       public String getDefaultValue()
  @@ -255,6 +298,16 @@
       {
           this.defaultValue = defaultValue;
       }
  +    
  +    /**
  +     * Replaces the default value if the new value is not null.
  +     * 
  +     * @param value The defaultValue to set.
  +     */
  +    public void replaceDefaultValue(String value)
  +    {
  +        this.defaultValue = StringUtils.defaultString(value, getDefaultValue());
  +    }
   
       /**
        * @return Returns the sqlType.
  @@ -272,4 +325,26 @@
           this.sqlType = sqlType;
       }
   
  +    /**
  +     * Return the size and scale in brackets for use in an sql schema.
  +     * 
  +     * @return size and scale or an empty String if there are no values 
  +     *         available.
  +     */
  +    public String printSize()
  +    {
  +        if (size != null && scale != null) 
  +        {
  +            return '(' + size + ',' + scale + ')';
  +        }
  +        else if (size != null) 
  +        {
  +            return '(' + size + ')';
  +        }
  +        else
  +        {
  +            return "";
  +        }
  +    }
  +    
   }
  
  
  
  1.14      +52 -71    db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java
  
  Index: Column.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Column.java	25 Nov 2003 16:57:13 -0000	1.13
  +++ Column.java	25 Nov 2003 19:19:06 -0000	1.14
  @@ -84,20 +84,16 @@
       private static Log log = LogFactory.getLog(Column.class);
       private String name;
       private String description;
  +    private Domain domain = new Domain();
       private String javaName = null;
       private String javaNamingMethod;
       private boolean isNotNull = false;
  -    private String size;
  -    private String scale;
  -    /** type as defined in schema.xml */
  -    private String torqueType;
       private String javaType;
       private Table parentTable;
       private int position;
       private boolean isPrimaryKey = false;
       private boolean isUnique = false;
       private boolean isAutoIncrement = false;
  -    private String defaultValue;
       private List referrers;
       // only one type is supported currently, which assumes the
       // column either contains the classnames or a key to
  @@ -165,15 +161,12 @@
           String dom = attrib.getValue("domain");
           if (StringUtils.isNotEmpty(dom)) 
           {
  -            Domain domain = getTable().getDatabase().getDomain(dom);
  -            size = domain.getSize();
  -            scale = domain.getScale();
  -            setType(domain.getType().getName());
  -            defaultValue = domain.getDefaultValue();
  +            domain = new Domain(getTable().getDatabase().getDomain(dom));
           } 
           else
           {
  -            setType(DEFAULT_TYPE);
  +            domain = new Domain();
  +            domain.setType(DEFAULT_TYPE);
           }
           //Name
           name = attrib.getValue("name");
  @@ -197,10 +190,10 @@
           //Primary Key
           String primaryKey = attrib.getValue("primaryKey");
           //Avoid NullPointerExceptions on string comparisons.
  -        isPrimaryKey = ("true".equals (primaryKey));
  +        isPrimaryKey = ("true".equals(primaryKey));
   
           // If this column is a primary key then it can't be null.
  -        if ("true".equals (primaryKey))
  +        if ("true".equals(primaryKey))
           {
               isNotNull = true;
           }
  @@ -215,13 +208,12 @@
           isAutoIncrement = ("true".equals(autoIncrement));
   
           //Default column value.
  -        defaultValue = StringUtils.defaultString(
  -                attrib.getValue("default"), defaultValue);
  +        domain.replaceDefaultValue(attrib.getValue("default"));
   
  -        size = StringUtils.defaultString(attrib.getValue("size"), size);
  -        scale = StringUtils.defaultString(attrib.getValue("scale"), scale);
  +        domain.replaceSize(attrib.getValue("size"));
  +        domain.replaceScale(attrib.getValue("scale"));
   
  -        setType(StringUtils.defaultString(attrib.getValue("type"), torqueType));
  +        domain.replaceType(attrib.getValue("type"));
   
           inheritanceType = attrib.getValue("inheritance");
           isInheritance = (inheritanceType != null
  @@ -523,7 +515,7 @@
        */
       public ForeignKey getForeignKey()
       {
  -        return parentTable.getForeignKey (this.name);
  +        return parentTable.getForeignKey(this.name);
       }
   
       /**
  @@ -536,7 +528,6 @@
           return (fk == null ? null : fk.getForeignTableName());
       }
   
  -
       /**
        * Utility method to get the related column of this local column if this
        * column is a foreign key or part of a foreign key.
  @@ -583,7 +574,7 @@
        */
       public void setType(String torqueType)
       {
  -        this.torqueType = torqueType;
  +        domain.setType(torqueType);
           if (torqueType.equals("VARBINARY") || torqueType.equals("BLOB"))
           {
               needsTransactionInPostgres = true;
  @@ -595,7 +586,7 @@
        */
       public Object getType()
       {
  -        return TypeMap.getJdbcType(torqueType);
  +        return TypeMap.getJdbcType(domain.getType()).getName();
       }
   
       /**
  @@ -603,7 +594,7 @@
        */
       public Object getTorqueType()
       {
  -        return torqueType;
  +        return domain.getType().getName();
       }
   
       /**
  @@ -613,7 +604,7 @@
        */
       public boolean isString()
       {
  -        return (torqueType.indexOf ("CHAR") != -1);
  +        return (domain.getType().getName().indexOf ("CHAR") != -1);
       }
   
       /**
  @@ -622,6 +613,7 @@
        */
       public boolean needEscapedValue()
       {
  +        String torqueType = domain.getType().getName();
           return (torqueType != null) &&
                   ( torqueType.equals("VARCHAR")
                           || torqueType.equals("LONGVARCHAR")
  @@ -661,21 +653,21 @@
               result.append(" required=\"false\"");
           }
   
  -        result.append(" type=\"").append(torqueType).append('"');
  +        result.append(" type=\"").append(domain.getType().getName()).append('"');
   
  -        if (size != null)
  +        if (domain.getSize() != null)
           {
  -            result.append(" size=\"").append(size).append('"');
  +            result.append(" size=\"").append(domain.getSize()).append('"');
           }
   
  -        if (scale != null)
  +        if (domain.getScale() != null)
           {
  -            result.append(" scale=\"").append(scale).append('"');
  +            result.append(" scale=\"").append(domain.getScale()).append('"');
           }
           
  -        if (defaultValue != null)
  +        if (domain.getDefaultValue() != null)
           {
  -            result.append(" default=\"").append(defaultValue).append('"');
  +            result.append(" default=\"").append(domain.getDefaultValue()).append('"');
           }
   
           if (isInheritance())
  @@ -695,7 +687,7 @@
        */
       public String getSize()
       {
  -        return size;
  +        return domain.getSize();
       }
   
       /**
  @@ -703,7 +695,7 @@
        */
       public void setSize(String newSize)
       {
  -        size = newSize;
  +        domain.setSize(newSize);
       }
   
       /**
  @@ -711,7 +703,7 @@
        */
       public String getScale()
       {
  -        return scale;
  +        return domain.getScale();
       }
   
       /**
  @@ -719,7 +711,7 @@
        */
       public void setScale(String newScale)
       {
  -        scale = newScale;
  +        domain.setScale(newScale);
       }
       
       /**
  @@ -730,18 +722,7 @@
        */
       public String printSize()
       {
  -        if (size != null && scale != null) 
  -        {
  -            return '(' + size + ',' + scale + ')';
  -        }
  -        else if (size != null) 
  -        {
  -            return '(' + size + ')';
  -        }
  -        else
  -        {
  -            return "";
  -        }
  +        return domain.printSize();
       }
   
       /**
  @@ -752,17 +733,17 @@
        public String getDefaultSetting()
        {
            StringBuffer dflt = new StringBuffer(0);
  -         if (defaultValue != null)
  +         if (domain.getDefaultValue() != null)
            {
                dflt.append("default ");
  -             if (TypeMap.isTextType(torqueType))
  +             if (TypeMap.isTextType(domain.getType()))
                {
                    // TODO: Properly SQL-escape the text.
  -                 dflt.append('\'').append(defaultValue).append('\'');
  +                 dflt.append('\'').append(domain.getDefaultValue()).append('\'');
                }
                else
                {
  -                 dflt.append(defaultValue);
  +                 dflt.append(domain.getDefaultValue());
                }
            }
            return dflt.toString();
  @@ -773,7 +754,7 @@
        */
       public void setDefaultValue(String def)
       {
  -        defaultValue = def;
  +        domain.setDefaultValue(def);
       }
   
       /**
  @@ -781,7 +762,7 @@
        */
       public String getDefaultValue()
       {
  -        return defaultValue;
  +        return domain.getDefaultValue();
       }
   
       /**
  @@ -821,36 +802,36 @@
   
           if (size != null)
           {
  -            this.size = size;
  +            domain.setSize(size);
           }
   
           if (tn.indexOf ("CHAR") != -1)
           {
  -            torqueType = "VARCHAR";
  +            domain.setType(SchemaType.VARCHAR);
           }
           else if (tn.indexOf ("INT") != -1)
           {
  -            torqueType = "INTEGER";
  +            domain.setType(SchemaType.INTEGER);
           }
           else if (tn.indexOf ("FLOAT") != -1)
           {
  -            torqueType = "FLOAT";
  +            domain.setType(SchemaType.FLOAT);
           }
           else if (tn.indexOf ("DATE") != -1)
           {
  -            torqueType = "DATE";
  +            domain.setType(SchemaType.DATE);
           }
           else if (tn.indexOf ("TIME") != -1)
           {
  -            torqueType = "TIMESTAMP";
  +            domain.setType(SchemaType.TIMESTAMP);
           }
           else if (tn.indexOf ("BINARY") != -1)
           {
  -            torqueType = "LONGVARBINARY";
  +            domain.setType(SchemaType.LONGVARBINARY);
           }
           else
           {
  -            torqueType = "VARCHAR";
  +            domain.setType(SchemaType.VARCHAR);
           }
       }
   
  @@ -862,7 +843,7 @@
        */
       public String getJavaObject()
       {
  -        return TypeMap.getJavaObject(torqueType);
  +        return TypeMap.getJavaObject(domain.getType());
       }
   
       /**
  @@ -873,7 +854,7 @@
        */
       public String getJavaPrimitive()
       {
  -        return TypeMap.getJavaNative(torqueType);
  +        return TypeMap.getJavaNative(domain.getType());
       }
   
       /**
  @@ -886,10 +867,10 @@
        */
       public String getJavaNative()
       {
  -        String jtype = TypeMap.getJavaNativeObject(torqueType);
  +        String jtype = TypeMap.getJavaNativeObject(domain.getType());
           if (isUsePrimitive())
           {
  -            jtype = TypeMap.getJavaNative(torqueType);
  +            jtype = TypeMap.getJavaNative(domain.getType());
           }
   
           return jtype;
  @@ -901,10 +882,10 @@
        */
       public String getVillageMethod()
       {
  -        String vmethod = TypeMap.getVillageObjectMethod(torqueType);
  +        String vmethod = TypeMap.getVillageObjectMethod(domain.getType());
           if (isUsePrimitive())
           {
  -            vmethod = TypeMap.getVillageMethod(torqueType);
  +            vmethod = TypeMap.getVillageMethod(domain.getType());
           }
   
           return vmethod;
  @@ -916,7 +897,7 @@
        */
       public String getParameterParserMethod()
       {
  -        return TypeMap.getPPMethod(torqueType);
  +        return TypeMap.getPPMethod(domain.getType());
       }
   
       /**
  @@ -925,7 +906,7 @@
        */
       public boolean isBooleanInt()
       {
  -        return TypeMap.isBooleanInt(torqueType);
  +        return TypeMap.isBooleanInt(domain.getType());
       }
   
       /**
  @@ -934,7 +915,7 @@
        */
       public boolean isBooleanChar()
       {
  -        return TypeMap.isBooleanChar(torqueType);
  +        return TypeMap.isBooleanChar(domain.getType());
       }
   
       /**
  
  
  
  1.118     +3 -0      db-torque/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/xdocs/changes.xml,v
  retrieving revision 1.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- changes.xml	3 Nov 2003 06:39:05 -0000	1.117
  +++ changes.xml	25 Nov 2003 19:19:06 -0000	1.118
  @@ -9,6 +9,9 @@
   
       <release version="3.2-alpha" date="in CVS">
   
  +      <action dev='mpoeschl' type='remove'>
  +        Remove support for idMethod=sequence and autoincrement.
  +      </action>
         <action dev='mpoeschl' type='add'>
           TRQS146: Support for scale.
         </action>
  
  
  
  1.1                  db-torque/src/generator/src/test/org/apache/torque/engine/database/model/TypeMapTest.java
  
  Index: TypeMapTest.java
  ===================================================================
  package org.apache.torque.engine.database.model;
  
  import java.sql.Types;
  
  import junit.framework.TestCase;
  
  /**
   * Tests for TypeMap.
   * 
   * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
   */
  public class TypeMapTest extends TestCase {
  
      public void testGetJavaObject() {
          assertEquals(TypeMap.getJavaObject(SchemaType.INTEGER), "new Integer(0)");
      }
  
      public void testGetJavaNative() {
          assertEquals(TypeMap.getJavaNative(SchemaType.INTEGER), "int");
      }
  
      public void testGetJavaNativeObject() {
          assertEquals(TypeMap.getJavaNativeObject(SchemaType.INTEGER), "Integer");
      }
  
      public void testGetVillageMethod() {
          assertEquals(TypeMap.getVillageMethod(SchemaType.INTEGER), "asInt()");
      }
  
      public void testGetVillageObjectMethod() {
          assertEquals(TypeMap.getVillageObjectMethod(SchemaType.INTEGER), "asIntegerObj()");
      }
  
      public void testGetPPMethod() {
          assertEquals(TypeMap.getPPMethod(SchemaType.INTEGER), "getInt(ppKey)");
      }
  
      public void testGetJdbcType() {
          assertEquals(TypeMap.getJdbcType(SchemaType.INTEGER), SchemaType.INTEGER);
          assertEquals(TypeMap.getJdbcType(SchemaType.BOOLEANINT), SchemaType.INTEGER);
      }
  
      public void testGetTorqueType() {
          assertEquals(TypeMap.getTorqueType(new Integer(Types.FLOAT)), 
                  SchemaType.FLOAT);
          assertEquals(TypeMap.getTorqueType(new Integer(Types.CHAR)), 
                  SchemaType.CHAR);
      }
  
      public void testIsBooleanInt() {
          assertFalse(TypeMap.isBooleanInt(SchemaType.FLOAT));
          assertTrue(TypeMap.isBooleanInt(SchemaType.BOOLEANINT));
      }
  
      public void testIsBooleanChar() {
          assertFalse(TypeMap.isBooleanChar(SchemaType.FLOAT));
          assertTrue(TypeMap.isBooleanChar(SchemaType.BOOLEANCHAR));
      }
  
      public void testIsTextType() {
          assertFalse(TypeMap.isTextType(SchemaType.FLOAT));
          assertTrue(TypeMap.isTextType(SchemaType.CHAR));
      }
  
  }
  
  
  

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


Mime
View raw message