Package org.dbunit.ext.postgresql
Class GenericEnumType
java.lang.Object
org.dbunit.dataset.datatype.DataType
org.dbunit.dataset.datatype.AbstractDataType
org.dbunit.ext.postgresql.GenericEnumType
Adapter to handle conversion between Postgresql
native Enum type and Strings.
- Since:
- 2.4.6
- Version:
- $Revision$ $Date$
- Author:
- Jarvis Cochrane (jarvis@cochrane.com.au), gommma (gommma AT users.sourceforge.net), Last changed by: $Author$
-
Field Summary
Fields inherited from class org.dbunit.dataset.datatype.DataType
BIGINT, BIGINT_AUX_LONG, BINARY, BIT, BLOB, BOOLEAN, CHAR, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER, LONGNVARCHAR, LONGVARBINARY, LONGVARCHAR, NCHAR, NUMERIC, NVARCHAR, REAL, RELATIVE_DATE_TIME_PARSER, SMALLINT, TIME, TIMESTAMP, TINYINT, UNKNOWN, VARBINARY, VARCHAR -
Constructor Summary
ConstructorsConstructorDescriptionGenericEnumType(String sqlTypeName) Creates a data type adapter for the given Postgres enum type. -
Method Summary
Modifier and TypeMethodDescriptionReturns the SQL type name for user types (null for basic SQL types)getSqlValue(int column, ResultSet resultSet) Returns the specified column value from the specified resultset object.voidsetSqlValue(Object enumObject, int column, PreparedStatement statement) Set the specified value to the specified prepared statement object.Returns the specified value typecasted to thisDataTypeMethods inherited from class org.dbunit.dataset.datatype.AbstractDataType
areObjectsEqual, compare, compareNonNulls, getSqlType, getTypeClass, isDateTime, isNumber, loadClass, loadClass, toStringMethods inherited from class org.dbunit.dataset.datatype.DataType
asString, forObject, forSqlType, forSqlTypeName, isExtendedSyntax
-
Constructor Details
-
GenericEnumType
Creates a data type adapter for the given Postgres enum type.- Parameters:
sqlTypeName- The name of the enum type needed to invoke the "setType()" method on the PGObject class.
-
-
Method Details
-
getSqlValue
Description copied from class:DataTypeReturns the specified column value from the specified resultset object.- Overrides:
getSqlValuein classAbstractDataType- Parameters:
column- the column index to read, starting at 1.resultSet- the result set to read the column value from.- Returns:
- the column value.
- Throws:
SQLException- if a database access error occurs.TypeCastException- if the value cannot be typecast to thisDataType.
-
setSqlValue
public void setSqlValue(Object enumObject, int column, PreparedStatement statement) throws SQLException, TypeCastException Set the specified value to the specified prepared statement object. Binds sqlNULLwhenenumObjectisnull, instead of dereferencing it while building the PGobject.- Overrides:
setSqlValuein classAbstractDataType- Parameters:
enumObject- the value to bind.column- the parameter index to bind to, starting at 1.statement- the prepared statement to bind the value on.- Throws:
SQLException- if a database access error occurs.TypeCastException- if the value cannot be typecast to thisDataType.
-
typeCast
Returns the specified value typecasted to thisDataTypeReturnsnullwhenarg0isnull, instead of throwingNullPointerException.- Specified by:
typeCastin classDataType- Parameters:
arg0- the value to typecast.- Returns:
- the typecast value.
- Throws:
TypeCastException- if the value cannot be typecast to thisDataType.
-
getSqlTypeName
Description copied from class:DataTypeReturns the SQL type name for user types (null for basic SQL types)- Overrides:
getSqlTypeNamein classDataType- Returns:
- the SQL type name for user types, or
nullfor basic SQL types.
-