View Javadoc
1   /**
2    *    Copyright 2009-2015 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.jdbc;
17  
18  import org.apache.ibatis.type.BigDecimalTypeHandler;
19  import org.apache.ibatis.type.BlobTypeHandler;
20  import org.apache.ibatis.type.BooleanTypeHandler;
21  import org.apache.ibatis.type.ByteArrayTypeHandler;
22  import org.apache.ibatis.type.ByteTypeHandler;
23  import org.apache.ibatis.type.ClobTypeHandler;
24  import org.apache.ibatis.type.DateOnlyTypeHandler;
25  import org.apache.ibatis.type.DateTypeHandler;
26  import org.apache.ibatis.type.DoubleTypeHandler;
27  import org.apache.ibatis.type.FloatTypeHandler;
28  import org.apache.ibatis.type.IntegerTypeHandler;
29  import org.apache.ibatis.type.JdbcType;
30  import org.apache.ibatis.type.LongTypeHandler;
31  import org.apache.ibatis.type.ObjectTypeHandler;
32  import org.apache.ibatis.type.ShortTypeHandler;
33  import org.apache.ibatis.type.SqlDateTypeHandler;
34  import org.apache.ibatis.type.SqlTimeTypeHandler;
35  import org.apache.ibatis.type.SqlTimestampTypeHandler;
36  import org.apache.ibatis.type.StringTypeHandler;
37  import org.apache.ibatis.type.TimeOnlyTypeHandler;
38  import org.apache.ibatis.type.TypeHandler;
39  
40  /**
41   * @author Clinton Begin
42   * @author Adam Gent
43   */
44  public enum Null {
45    BOOLEAN(new BooleanTypeHandler(), JdbcType.BOOLEAN),
46  
47    BYTE(new ByteTypeHandler(), JdbcType.TINYINT),
48    SHORT(new ShortTypeHandler(), JdbcType.SMALLINT),
49    INTEGER(new IntegerTypeHandler(), JdbcType.INTEGER),
50    LONG(new LongTypeHandler(), JdbcType.BIGINT),
51    FLOAT(new FloatTypeHandler(), JdbcType.FLOAT),
52    DOUBLE(new DoubleTypeHandler(), JdbcType.DOUBLE),
53    BIGDECIMAL(new BigDecimalTypeHandler(), JdbcType.DECIMAL),
54  
55    STRING(new StringTypeHandler(), JdbcType.VARCHAR),
56    CLOB(new ClobTypeHandler(), JdbcType.CLOB),
57    LONGVARCHAR(new ClobTypeHandler(), JdbcType.LONGVARCHAR),
58  
59    BYTEARRAY(new ByteArrayTypeHandler(), JdbcType.LONGVARBINARY),
60    BLOB(new BlobTypeHandler(), JdbcType.BLOB),
61    LONGVARBINARY(new BlobTypeHandler(), JdbcType.LONGVARBINARY),
62  
63    OBJECT(new ObjectTypeHandler(), JdbcType.OTHER),
64    OTHER(new ObjectTypeHandler(), JdbcType.OTHER),
65    TIMESTAMP(new DateTypeHandler(), JdbcType.TIMESTAMP),
66    DATE(new DateOnlyTypeHandler(), JdbcType.DATE),
67    TIME(new TimeOnlyTypeHandler(), JdbcType.TIME),
68    SQLTIMESTAMP(new SqlTimestampTypeHandler(), JdbcType.TIMESTAMP),
69    SQLDATE(new SqlDateTypeHandler(), JdbcType.DATE),
70    SQLTIME(new SqlTimeTypeHandler(), JdbcType.TIME);
71  
72    private TypeHandler<?> typeHandler;
73    private JdbcType jdbcType;
74  
75    private Null(TypeHandler<?> typeHandler, JdbcType jdbcType) {
76      this.typeHandler = typeHandler;
77      this.jdbcType = jdbcType;
78    }
79  
80    public TypeHandler<?> getTypeHandler() {
81      return typeHandler;
82    }
83  
84    public JdbcType getJdbcType() {
85      return jdbcType;
86    }
87  }