View Javadoc

    1   /*
    2    * joey-gen and its relative products are published under the terms
    3    * of the Apache Software License.
    4    *
    5    * Created on 2004/08/16 2:10:45
    6    */
    7   package org.asyrinx.joey.gen.model.rdb;
    8
    9   import java.sql.Types;
    10
    11  import org.apache.commons.lang.enum.Enum;
    12  import org.apache.commons.lang.enum.ValuedEnum;
    13
    14  /***
    15   * @author akima
    16   */
    17  public class ColumnType extends ValuedEnum {
    18
    19      /***
    20       * @param name
    21       * @param value
    22       */
    23      public ColumnType(int value, String name) {
    24          this(value, name, false);
    25      }
    26
    27      /***
    28       * @param name
    29       * @param value
    30       */
    31      public ColumnType(int value, String name, boolean requiredSize) {
    32          super(name, value);
    33          this.requiredSize = requiredSize;
    34      }
    35
    36      private final boolean requiredSize;
    37
    38      public int toJdbcType() {
    39          return getValue();
    40      }
    41
    42      public boolean isRequiredSize() {
    43          return this.requiredSize;
    44      }
    45
    46      public static ColumnType get(String name) {
    47          return (ColumnType) Enum.getEnum(ColumnType.class, name);
    48      }
    49
    50      public static ColumnType get(int value) {
    51          return (ColumnType) ValuedEnum.getEnum(ColumnType.class, value);
    52      }
    53
    54      public static ColumnType get(Number value) {
    55          return get(value.intValue());
    56      }
    57
    58      public static final ColumnType BIT = new ColumnType(Types.BIT, "BIT");
    59
    60      public static final ColumnType TINYINT = new ColumnType(Types.TINYINT, "TINYINT");
    61
    62      public static final ColumnType SMALLINT = new ColumnType(Types.SMALLINT, "SMALLINT");
    63
    64      public static final ColumnType INTEGER = new ColumnType(Types.INTEGER, "INTEGER");
    65
    66      public static final ColumnType BIGINT = new ColumnType(Types.BIGINT, "BIGINT");
    67
    68      public static final ColumnType FLOAT = new ColumnType(Types.FLOAT, "FLOAT");
    69
    70      public static final ColumnType REAL = new ColumnType(Types.REAL, "REAL");
    71
    72      public static final ColumnType DOUBLE = new ColumnType(Types.DOUBLE, "DOUBLE");
    73
    74      public static final ColumnType NUMERIC = new ColumnType(Types.NUMERIC, "NUMERIC");
    75
    76      public static final ColumnType DECIMAL = new ColumnType(Types.DECIMAL, "DECIMAL");
    77
    78      public static final ColumnType CHAR = new ColumnType(Types.CHAR, "CHAR", true);
    79
    80      public static final ColumnType VARCHAR = new ColumnType(Types.VARCHAR, "VARCHAR", true);
    81
    82      public static final ColumnType LONGVARCHAR = new ColumnType(Types.LONGVARCHAR, "LONGVARCHAR");
    83
    84      public static final ColumnType DATE = new ColumnType(Types.DATE, "DATE");
    85
    86      public static final ColumnType TIME = new ColumnType(Types.TIME, "TIME");
    87
    88      public static final ColumnType TIMESTAMP = new ColumnType(Types.TIMESTAMP, "TIMESTAMP");
    89
    90      public static final ColumnType BINARY = new ColumnType(Types.BINARY, "BINARY");
    91
    92      public static final ColumnType VARBINARY = new ColumnType(Types.VARBINARY, "VARBINARY");
    93
    94      public static final ColumnType LONGVARBINARY = new ColumnType(Types.LONGVARBINARY, "LONGVARBINARY");
    95
    96      public static final ColumnType NULL = new ColumnType(Types.NULL, "NULL");
    97
    98      public static final ColumnType JAVA_OBJECT = new ColumnType(Types.JAVA_OBJECT, "JAVA_OBJECT");
    99
    100     public static final ColumnType DISTINCT = new ColumnType(Types.DISTINCT, "DISTINCT");
    101
    102     public static final ColumnType STRUCT = new ColumnType(Types.STRUCT, "STRUCT");
    103
    104     public static final ColumnType ARRAY = new ColumnType(Types.ARRAY, "ARRAY");
    105
    106     public static final ColumnType BLOB = new ColumnType(Types.BLOB, "BLOB");
    107
    108     public static final ColumnType CLOB = new ColumnType(Types.CLOB, "CLOB");
    109
    110     public static final ColumnType REF = new ColumnType(Types.REF, "REF");
    111
    112     public static final ColumnType DATALINK = new ColumnType(Types.DATALINK, "DATALINK");
    113
    114     public static final ColumnType BOOLEAN = new ColumnType(Types.BOOLEAN, "BOOLEAN");
    115     //    	public final static int BIT = -7;
    116     //    	public final static int TINYINT = -6;
    117     //    	public final static int SMALLINT = 5;
    118     //    	public final static int INTEGER = 4;
    119     //    	public final static int BIGINT = -5;
    120     //    	public final static int FLOAT = 6;
    121     //    	public final static int REAL = 7;
    122     //    	public final static int DOUBLE = 8;
    123     //    	public final static int NUMERIC = 2;
    124     //    	public final static int DECIMAL = 3;
    125     //    	public final static int CHAR = 1;
    126     //    	public final static int VARCHAR = 12;
    127     //    	public final static int LONGVARCHAR = -1;
    128     //    	public final static int DATE = 91;
    129     //    	public final static int TIME = 92;
    130     //    	public final static int TIMESTAMP = 93;
    131     //    	public final static int BINARY = -2;
    132     //    	public final static int VARBINARY = -3;
    133     //    	public final static int LONGVARBINARY = -4;
    134     //    	public final static int NULL = 0;
    135     //    	public final static int OTHER = 1111;
    136     //            public final static int JAVA_OBJECT = 2000;
    137     //            public final static int DISTINCT = 2001;
    138     //            public final static int STRUCT = 2002;
    139     //            public final static int ARRAY = 2003;
    140     //            public final static int BLOB = 2004;
    141     //            public final static int CLOB = 2005;
    142     //            public final static int REF = 2006;
    143     //        public final static int DATALINK = 70;
    144     //        public final static int BOOLEAN = 16;
    145
    146 }