org.dbunit.dataset.datatype
Class DataType

java.lang.Object
  extended by org.dbunit.dataset.datatype.DataType
Direct Known Subclasses:
AbstractDataType

public abstract class DataType
extends java.lang.Object

Version:
$Revision: 461 $
Author:
Manuel Laflamme

Field Summary
static DataType BIGINT
           
static DataType BINARY
           
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 LONGVARBINARY
           
static DataType LONGVARCHAR
           
static DataType NUMERIC
           
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 Summary
DataType()
           
 
Method Summary
static java.lang.String asString(java.lang.Object value)
          Typecast the specified value to string.
abstract  int compare(java.lang.Object o1, java.lang.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(java.lang.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(java.lang.String sqlTypeName)
          Deprecated. Should not be used anymore
abstract  int getSqlType()
          Returns the coresponding Types.
abstract  java.lang.Object getSqlValue(int column, java.sql.ResultSet resultSet)
          Returns the specified column value from the specified resultset object.
abstract  java.lang.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(java.lang.Object value, int column, java.sql.PreparedStatement statement)
          Set the specified value to the specified prepared statement object.
abstract  java.lang.Object typeCast(java.lang.Object value)
          Returns the specified value typecasted to this DataType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final DataType UNKNOWN

CHAR

public static final DataType CHAR

VARCHAR

public static final DataType VARCHAR

LONGVARCHAR

public static final DataType LONGVARCHAR

CLOB

public static final DataType CLOB

NUMERIC

public static final DataType NUMERIC

DECIMAL

public static final DataType DECIMAL

BOOLEAN

public static final DataType BOOLEAN

TINYINT

public static final DataType TINYINT

SMALLINT

public static final DataType SMALLINT

INTEGER

public static final DataType INTEGER

BIGINT

public static final DataType BIGINT

REAL

public static final DataType REAL

FLOAT

public static final DataType FLOAT

DOUBLE

public static final DataType DOUBLE

DATE

public static final DataType DATE

TIME

public static final DataType TIME

TIMESTAMP

public static final DataType TIMESTAMP

BINARY

public static final DataType BINARY

VARBINARY

public static final DataType VARBINARY

LONGVARBINARY

public static final DataType LONGVARBINARY

BLOB

public static final DataType BLOB
Constructor Detail

DataType

public DataType()
Method Detail

typeCast

public abstract java.lang.Object typeCast(java.lang.Object value)
                                   throws TypeCastException
Returns the specified value typecasted to this DataType

Throws:
TypeCastException

compare

public abstract int compare(java.lang.Object o1,
                            java.lang.Object o2)
                     throws TypeCastException
Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The two values are typecast to this DataType before being compared.

Throws:
TypeCastException - if the arguments' types prevent them from being compared by this Comparator.

getSqlType

public abstract int getSqlType()
Returns the coresponding Types.


getTypeClass

public abstract java.lang.Class getTypeClass()
Returns the runtime class of the typecast result.


isNumber

public abstract boolean isNumber()
Returns true if this DataType represents a number.


isDateTime

public abstract boolean isDateTime()
Returns true if this DataType represents a date and/or time.


getSqlValue

public abstract java.lang.Object getSqlValue(int column,
                                             java.sql.ResultSet resultSet)
                                      throws java.sql.SQLException,
                                             TypeCastException
Returns the specified column value from the specified resultset object.

Throws:
java.sql.SQLException
TypeCastException

setSqlValue

public abstract void setSqlValue(java.lang.Object value,
                                 int column,
                                 java.sql.PreparedStatement statement)
                          throws java.sql.SQLException,
                                 TypeCastException
Set the specified value to the specified prepared statement object.

Throws:
java.sql.SQLException
TypeCastException

asString

public static java.lang.String asString(java.lang.Object value)
                                 throws TypeCastException
Typecast the specified value to string.

Throws:
TypeCastException

forSqlType

public static DataType forSqlType(int sqlType)
                           throws DataTypeException
Returns the DataType corresponding to the specified Sql type. See Types.

Throws:
DataTypeException

forSqlTypeName

public static DataType forSqlTypeName(java.lang.String sqlTypeName)
                               throws DataTypeException
Deprecated. Should not be used anymore

Returns the DataType corresponding to the specified Sql type name.

Throws:
DataTypeException

forObject

public static DataType forObject(java.lang.Object value)
Returns the DataType corresponding to the specified value runtime class. This method returns DataType.UNKNOWN if the value is null or runtime class not recognized.



Copyright © 2002-2006. All Rights Reserved.