Class GenericEnumType


public class GenericEnumType extends AbstractDataType
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$
  • Constructor Details

    • GenericEnumType

      public GenericEnumType(String sqlTypeName)
      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

      public Object getSqlValue(int column, ResultSet resultSet) throws SQLException, TypeCastException
      Description copied from class: DataType
      Returns the specified column value from the specified resultset object.
      Overrides:
      getSqlValue in class AbstractDataType
      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 this DataType.
    • setSqlValue

      public void setSqlValue(Object enumObject, int column, PreparedStatement statement) throws SQLException, TypeCastException
      Set the specified value to the specified prepared statement object. Binds sql NULL when enumObject is null, instead of dereferencing it while building the PGobject.
      Overrides:
      setSqlValue in class AbstractDataType
      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 this DataType.
    • typeCast

      public Object typeCast(Object arg0) throws TypeCastException
      Returns the specified value typecasted to this DataType Returns null when arg0 is null, instead of throwing NullPointerException.
      Specified by:
      typeCast in class DataType
      Parameters:
      arg0 - the value to typecast.
      Returns:
      the typecast value.
      Throws:
      TypeCastException - if the value cannot be typecast to this DataType.
    • getSqlTypeName

      public String getSqlTypeName()
      Description copied from class: DataType
      Returns the SQL type name for user types (null for basic SQL types)
      Overrides:
      getSqlTypeName in class DataType
      Returns:
      the SQL type name for user types, or null for basic SQL types.