com.interface21.jdbc.core.support
Class AbstractDataFieldMaxValueIncrementer

java.lang.Object
  |
  +--com.interface21.jdbc.core.support.AbstractDataFieldMaxValueIncrementer
All Implemented Interfaces:
DataFieldMaxValueIncrementer, InitializingBean
Direct Known Subclasses:
HsqlMaxValueIncrementer, MySQLMaxValueIncrementer, OracleSequenceMaxValueIncrementer

public abstract class AbstractDataFieldMaxValueIncrementer
extends java.lang.Object
implements DataFieldMaxValueIncrementer, InitializingBean

Implementation of DataFieldMaxValueIncrementer Uses Template Method design pattern Subclasses should provide implementations of protected abstract methods.

History:

  • 17/04/2003 : donated to Spring by Dmitriy Kopylenko
  • 19/04/2003 : modified by Isabelle Muszynski, added nextDoubleValue
  • 09/05/2003 : modified by JPP, added nextLongValue
  • 17/06/2003 : modified by Ken Krebs, added common functionality form subclasses

    Version:
    $Id: AbstractDataFieldMaxValueIncrementer.java,v 1.14 2003/06/20 15:47:26 dkopylenko Exp $
    Author:
    Dmitriy Kopylenko, Isabelle Muszynski, Jean-Pierre Pawlak, Ken Krebs

    Constructor Summary
    AbstractDataFieldMaxValueIncrementer()
              Default constructor
    AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds, java.lang.String incrementerName)
              Constructor
    AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds, java.lang.String incrementerName, int cacheSize)
              Constructor
    AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds, java.lang.String incrementerName, java.lang.String columnName)
              Constructor
    AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds, java.lang.String incrementerName, java.lang.String columnName, int cacheSize)
              Constructor
     
    Method Summary
     void afterPropertiesSet()
              Invoked by a BeanFactory after it has set all bean properties supplied.
     int getCacheSize()
              Gets the cacheSize.
     java.lang.String getColumnName()
              Gets the columnName.
     javax.sql.DataSource getDataSource()
              Gets the data source.
     java.lang.String getIncrementerName()
              Gets the incrementerName.
    protected abstract  double incrementDoubleValue()
              Template method implementation to be provided by concrete subclasses
    protected abstract  int incrementIntValue()
              Template method implementation to be provided by concrete subclasses
    protected abstract  long incrementLongValue()
              Template method implementation to be provided by concrete subclasses
    protected abstract  java.lang.String incrementStringValue()
              Template method implementation to be provided by concrete subclasses
     boolean isDirty()
              Gets the state of the dirty flag
     double nextDoubleValue()
              Template method
     int nextIntValue()
              Template method
     long nextLongValue()
              Template method
     java.lang.String nextStringValue()
              Template method
     java.lang.Object nextValue(java.lang.Class keyClass)
              Template method
     void setCacheSize(int cacheSize)
              Sets the cacheSize.
     void setColumnName(java.lang.String columnName)
              Sets the columnName.
     void setDataSource(javax.sql.DataSource dataSource)
              Sets the data source.
     void setDirty(boolean dirty)
              Sets the state of the dirty flag
     void setIncrementerName(java.lang.String incrementerName)
              Sets the incrementerName.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    AbstractDataFieldMaxValueIncrementer

    public AbstractDataFieldMaxValueIncrementer()
    Default constructor

    AbstractDataFieldMaxValueIncrementer

    public AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds,
                                                java.lang.String incrementerName)
    Constructor
    Parameters:
    ds - the datasource to use
    incrementerName - the name of the sequence/table to use

    AbstractDataFieldMaxValueIncrementer

    public AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds,
                                                java.lang.String incrementerName,
                                                java.lang.String columnName)
    Constructor
    Parameters:
    ds - the datasource to use
    incrementerName - the name of the sequence/table to use
    columnName - the name of the column in the sequence table to use

    AbstractDataFieldMaxValueIncrementer

    public AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds,
                                                java.lang.String incrementerName,
                                                int cacheSize)
    Constructor
    Parameters:
    ds - the datasource to use
    incrementerName - the name of the sequence/table to use
    cacheSize - the number of buffered keys

    AbstractDataFieldMaxValueIncrementer

    public AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource ds,
                                                java.lang.String incrementerName,
                                                java.lang.String columnName,
                                                int cacheSize)
    Constructor
    Parameters:
    ds - the datasource to use
    incrementerName - the name of the sequence/table to use
    columnName - the name of the column in the sequence table to use
    cacheSize - the number of buffered keys
    Method Detail

    isDirty

    public boolean isDirty()
    Gets the state of the dirty flag

    setDirty

    public void setDirty(boolean dirty)
    Sets the state of the dirty flag

    getDataSource

    public javax.sql.DataSource getDataSource()
    Gets the data source.
    Returns:
    ds The data source to return

    setDataSource

    public void setDataSource(javax.sql.DataSource dataSource)
    Sets the data source.
    Parameters:
    ds - The data source to set

    getIncrementerName

    public java.lang.String getIncrementerName()
    Gets the incrementerName.
    Returns:
    incrementerName The incrementerName to return

    setIncrementerName

    public void setIncrementerName(java.lang.String incrementerName)
    Sets the incrementerName.
    Parameters:
    incrementerName - The incrementerName to set

    getColumnName

    public java.lang.String getColumnName()
    Gets the columnName.
    Returns:
    columnName The columnName to return

    setColumnName

    public void setColumnName(java.lang.String columnName)
    Sets the columnName.
    Parameters:
    columnName - The columnName to set

    getCacheSize

    public int getCacheSize()
    Gets the cacheSize.
    Returns:
    cacheSize The cacheSize to return

    setCacheSize

    public void setCacheSize(int cacheSize)
    Sets the cacheSize.
    Parameters:
    cacheSize - The number of buffered keys

    nextIntValue

    public final int nextIntValue()
                           throws DataAccessException
    Template method
    Specified by:
    nextIntValue in interface DataFieldMaxValueIncrementer
    See Also:
    DataFieldMaxValueIncrementer.nextIntValue()

    nextLongValue

    public final long nextLongValue()
                             throws DataAccessException
    Template method
    Specified by:
    nextLongValue in interface DataFieldMaxValueIncrementer
    See Also:
    DataFieldMaxValueIncrementer.nextLongValue()

    nextDoubleValue

    public final double nextDoubleValue()
                                 throws DataAccessException
    Template method
    Specified by:
    nextDoubleValue in interface DataFieldMaxValueIncrementer
    See Also:
    DataFieldMaxValueIncrementer.nextDoubleValue()

    nextStringValue

    public final java.lang.String nextStringValue()
                                           throws DataAccessException
    Template method
    Specified by:
    nextStringValue in interface DataFieldMaxValueIncrementer
    See Also:
    DataFieldMaxValueIncrementer.nextStringValue()

    nextValue

    public final java.lang.Object nextValue(java.lang.Class keyClass)
                                     throws DataAccessException
    Template method
    Specified by:
    nextValue in interface DataFieldMaxValueIncrementer
    See Also:
    DataFieldMaxValueIncrementer.nextValue(java.lang.Class)

    incrementIntValue

    protected abstract int incrementIntValue()
                                      throws DataAccessException
    Template method implementation to be provided by concrete subclasses
    See Also:
    nextIntValue()

    incrementLongValue

    protected abstract long incrementLongValue()
                                        throws DataAccessException
    Template method implementation to be provided by concrete subclasses
    See Also:
    nextLongValue()

    incrementDoubleValue

    protected abstract double incrementDoubleValue()
                                            throws DataAccessException
    Template method implementation to be provided by concrete subclasses
    See Also:
    nextDoubleValue()

    incrementStringValue

    protected abstract java.lang.String incrementStringValue()
                                                      throws DataAccessException
    Template method implementation to be provided by concrete subclasses
    See Also:
    nextStringValue()

    afterPropertiesSet

    public void afterPropertiesSet()
                            throws DataAccessException
    Description copied from interface: InitializingBean
    Invoked by a BeanFactory after it has set all bean properties supplied.
    This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
    Specified by:
    afterPropertiesSet in interface InitializingBean
    See Also:
    InitializingBean.afterPropertiesSet()


    Rod Johnson and Spring contributors 2001-2003.