Class AbstractDataFieldMaxValueIncrementer
- java.lang.Object
- org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
- All Implemented Interfaces:
InitializingBean,DataFieldMaxValueIncrementer
- Direct Known Subclasses:
AbstractColumnMaxValueIncrementer,AbstractSequenceMaxValueIncrementer
public abstract class AbstractDataFieldMaxValueIncrementer extends Object implements DataFieldMaxValueIncrementer, InitializingBean
Base implementation ofDataFieldMaxValueIncrementerthat delegates to a singlegetNextKey()template method that returns along. Uses longs for String values, padding with zeroes if required.- Author:
- Dmitriy Kopylenko, Juergen Hoeller, Jean-Pierre Pawlak, Juergen Hoeller
Field Summary
Fields Modifier and Type Field Description protected intpaddingLengthThe length to which a string result should be pre-pended with zeroes
Constructor Summary
Constructors Constructor Description AbstractDataFieldMaxValueIncrementer()Default constructor for bean property style usage.AbstractDataFieldMaxValueIncrementer(DataSource dataSource, String incrementerName)Convenience constructor.
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.DataSourcegetDataSource()Return the data source to retrieve the value from.StringgetIncrementerName()Return the name of the sequence/table.protected abstract longgetNextKey()Determine the next key to use, as a long.intgetPaddingLength()Return the padding length for String values.intnextIntValue()Increment the data store field's max value as int.longnextLongValue()Increment the data store field's max value as long.StringnextStringValue()Increment the data store field's max value as String.voidsetDataSource(DataSource dataSource)Set the data source to retrieve the value from.voidsetIncrementerName(String incrementerName)Set the name of the sequence/table.voidsetPaddingLength(int paddingLength)Set the padding length, i.e.
Field Detail
paddingLength
protected int paddingLength
The length to which a string result should be pre-pended with zeroes
Constructor Detail
AbstractDataFieldMaxValueIncrementer
public AbstractDataFieldMaxValueIncrementer()
Default constructor for bean property style usage.
AbstractDataFieldMaxValueIncrementer
public AbstractDataFieldMaxValueIncrementer(DataSource dataSource, String incrementerName)
Convenience constructor.- Parameters:
dataSource- the DataSource to useincrementerName- the name of the sequence/table to use
Method Detail
setDataSource
public void setDataSource(DataSource dataSource)
Set the data source to retrieve the value from.
getDataSource
public DataSource getDataSource()
Return the data source to retrieve the value from.
setIncrementerName
public void setIncrementerName(String incrementerName)
Set the name of the sequence/table.
getIncrementerName
public String getIncrementerName()
Return the name of the sequence/table.
setPaddingLength
public void setPaddingLength(int paddingLength)
Set the padding length, i.e. the length to which a string result should be pre-pended with zeroes.
getPaddingLength
public int getPaddingLength()
Return the padding length for String values.
afterPropertiesSet
public void afterPropertiesSet()
Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean
nextIntValue
public int nextIntValue() throws DataAccessException
Description copied from interface:DataFieldMaxValueIncrementerIncrement the data store field's max value as int.- Specified by:
nextIntValuein interfaceDataFieldMaxValueIncrementer- Returns:
- int next data store value such as max + 1
- Throws:
DataAccessException- in case of errors
nextLongValue
public long nextLongValue() throws DataAccessException
Description copied from interface:DataFieldMaxValueIncrementerIncrement the data store field's max value as long.- Specified by:
nextLongValuein interfaceDataFieldMaxValueIncrementer- Returns:
- int next data store value such as max + 1
- Throws:
DataAccessException- in case of errors
nextStringValue
public String nextStringValue() throws DataAccessException
Description copied from interface:DataFieldMaxValueIncrementerIncrement the data store field's max value as String.- Specified by:
nextStringValuein interfaceDataFieldMaxValueIncrementer- Returns:
- next data store value such as max + 1
- Throws:
DataAccessException- in case of errors
getNextKey
protected abstract long getNextKey()
Determine the next key to use, as a long.- Returns:
- the key to use as a long. It will eventually be converted later in another format by the public concrete methods of this class.