Class KeyGeneratorTypeHandlerShort

java.lang.Object
org.castor.cpa.persistence.sql.keygen.typehandler.KeyGeneratorTypeHandlerShort
All Implemented Interfaces:
KeyGeneratorTypeHandler<Short>

public final class KeyGeneratorTypeHandlerShort extends Object implements KeyGeneratorTypeHandler<Short>
Class implementing the KeyGeneratorTypeHandler for Short type.
Since:
1.3.2
Author:
Werner Guttmann
  • Constructor Details

    • KeyGeneratorTypeHandlerShort

      public KeyGeneratorTypeHandlerShort(boolean fail)
      Construct an type handler for Short values.
      Parameters:
      fail - true if the type handler should fail when current row of the record set is not valid, false otherwise.
    • KeyGeneratorTypeHandlerShort

      public KeyGeneratorTypeHandlerShort(boolean fail, int allocationSize)
  • Method Details

    • getNextValue

      public Short getNextValue(ResultSet rs) throws PersistenceException, SQLException
      Gets the value from resultset by calling getValue method and then calls the increment method to increment the extracted value.
      Specified by:
      getNextValue in interface KeyGeneratorTypeHandler<Short>
      Parameters:
      rs - A ResultSet object.
      Returns:
      Returns the new value after incrementing it.
      Throws:
      PersistenceException - If ResultSet is empty or if the type handler should fail when current row of the record set is not valid,
      SQLException - If database error occurs.
    • getValue

      public Short getValue(ResultSet rs) throws PersistenceException, SQLException
      Reads the resultset and return the extracted typehandler value from the resultset.
      Specified by:
      getValue in interface KeyGeneratorTypeHandler<Short>
      Parameters:
      rs - ResultSet object
      Returns:
      Value extracted from the ResultSet.
      Throws:
      PersistenceException - If ResultSet is empty or if the type handler should fail when current row of the record set is not valid,
      SQLException - If database error occurs.
    • increment

      public Short increment(Short value)
      Increments the provided value by ONE.
      Specified by:
      increment in interface KeyGeneratorTypeHandler<Short>
      Parameters:
      value - value to be incremented.
      Returns:
      Modified TypeHandler object with incremented value..
    • add

      public Short add(Short value, int offset)
      Adds the new Type Handler of type T to the provided handler instance at the provided offset.
      Specified by:
      add in interface KeyGeneratorTypeHandler<Short>
      Parameters:
      value - Handler instance in which new value will be added
      offset - Offset location. *
      Returns:
      Modified object.
    • bindValue

      public void bindValue(PreparedStatement stmt, int index, Short value) throws SQLException
      Binds the value in the sql preparedstatement at the provided index location.
      Specified by:
      bindValue in interface KeyGeneratorTypeHandler<Short>
      Parameters:
      stmt - A SQL PreparedStatement.
      index - Index location for binding parameter to statement.
      value - Value to be binded
      Throws:
      SQLException - If SQL error occurs in binding param to sql statement.