public abstract class DataType extends Object
Types
objects to their
java counterparts. It also provides immutable constants for the most common data types.Modifier and Type | Field and Description |
---|---|
static DataType |
BIGINT |
static DataType |
BIGINT_AUX_LONG
Auxiliary for the BIGINT type using a long.
|
static DataType |
BINARY |
static DataType |
BIT |
static DataType |
BLOB |
static DataType |
BOOLEAN |
static DataType |
CHAR |
static DataType |
CLOB |
static DataType |
DATE |
static DataType |
DECIMAL |
static DataType |
DOUBLE |
static DataType |
FLOAT |
static DataType |
INTEGER |
static DataType |
LONGNVARCHAR |
static DataType |
LONGVARBINARY |
static DataType |
LONGVARCHAR |
static DataType |
NCHAR |
static DataType |
NUMERIC |
static DataType |
NVARCHAR |
static DataType |
REAL |
static DataType |
SMALLINT |
static DataType |
TIME |
static DataType |
TIMESTAMP |
static DataType |
TINYINT |
static DataType |
UNKNOWN |
static DataType |
VARBINARY |
static DataType |
VARCHAR |
Constructor and Description |
---|
DataType() |
Modifier and Type | Method and Description |
---|---|
static String |
asString(Object value)
Typecast the specified value to string.
|
abstract int |
compare(Object o1,
Object o2)
Returns a negative integer, zero, or a positive integer as the first
argument is less than, equal to, or greater than the second.
|
static DataType |
forObject(Object value)
Returns the
DataType corresponding to the specified value
runtime class. |
static DataType |
forSqlType(int sqlType)
Returns the
DataType corresponding to the specified Sql
type. |
static DataType |
forSqlTypeName(String sqlTypeName)
Deprecated.
Should not be used anymore
|
abstract int |
getSqlType()
Returns the corresponding
Types . |
abstract Object |
getSqlValue(int column,
ResultSet resultSet)
Returns the specified column value from the specified resultset object.
|
abstract Class |
getTypeClass()
Returns the runtime class of the typecast result.
|
abstract boolean |
isDateTime()
Returns
true if this DataType represents a
date and/or time. |
abstract boolean |
isNumber()
Returns
true if this DataType represents a
number. |
abstract void |
setSqlValue(Object value,
int column,
PreparedStatement statement)
Set the specified value to the specified prepared statement object.
|
abstract Object |
typeCast(Object value)
Returns the specified value typecasted to this
DataType |
public static final DataType UNKNOWN
public static final DataType CHAR
public static final DataType VARCHAR
public static final DataType LONGVARCHAR
public static final DataType CLOB
public static final DataType NUMERIC
public static final DataType DECIMAL
public static final DataType BOOLEAN
public static final DataType BIT
public static final DataType TINYINT
public static final DataType SMALLINT
public static final DataType INTEGER
public static final DataType BIGINT
public static final DataType BIGINT_AUX_LONG
forObject(Object)
.public static final DataType REAL
public static final DataType FLOAT
public static final DataType DOUBLE
public static final DataType DATE
public static final DataType TIME
public static final DataType TIMESTAMP
public static final DataType BINARY
public static final DataType VARBINARY
public static final DataType LONGVARBINARY
public static final DataType BLOB
public static final DataType NCHAR
public static final DataType NVARCHAR
public static final DataType LONGNVARCHAR
public abstract Object typeCast(Object value) throws TypeCastException
DataType
TypeCastException
public abstract int compare(Object o1, Object o2) throws TypeCastException
The two values are typecast to this DataType before being compared.
TypeCastException
- if the arguments' types prevent them from
being compared by this Comparator.public abstract int getSqlType()
Types
.public abstract Class getTypeClass()
public abstract boolean isNumber()
true
if this DataType
represents a
number.public abstract boolean isDateTime()
true
if this DataType
represents a
date and/or time.public abstract Object getSqlValue(int column, ResultSet resultSet) throws SQLException, TypeCastException
SQLException
TypeCastException
public abstract void setSqlValue(Object value, int column, PreparedStatement statement) throws SQLException, TypeCastException
SQLException
TypeCastException
public static String asString(Object value) throws TypeCastException
TypeCastException
public static DataType forSqlType(int sqlType) throws DataTypeException
DataType
corresponding to the specified Sql
type. See Types
.DataTypeException
public static DataType forSqlTypeName(String sqlTypeName) throws DataTypeException
DataType
corresponding to the specified Sql
type name.DataTypeException
Copyright © 2002–2020. All rights reserved.