public abstract class AbstractDataFieldMaxValueIncrementer extends java.lang.Object implements DataFieldMaxValueIncrementer, InitializingBean
DataFieldMaxValueIncrementer
that delegates
to a single getNextKey()
template method that returns a long
.
Uses longs for String values, padding with zeroes if required.Modifier and Type | Field and Description |
---|---|
protected int |
paddingLength
The length to which a string result should be pre-pended with zeroes
|
Constructor and Description |
---|
AbstractDataFieldMaxValueIncrementer()
Default constructor for bean property style usage.
|
AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource dataSource,
java.lang.String incrementerName)
Convenience constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
javax.sql.DataSource |
getDataSource()
Return the data source to retrieve the value from.
|
java.lang.String |
getIncrementerName()
Return the name of the sequence/table.
|
protected abstract long |
getNextKey()
Determine the next key to use, as a long.
|
int |
getPaddingLength()
Return the padding length for String values.
|
int |
nextIntValue()
Increment the data store field's max value as int.
|
long |
nextLongValue()
Increment the data store field's max value as long.
|
java.lang.String |
nextStringValue()
Increment the data store field's max value as String.
|
void |
setDataSource(javax.sql.DataSource dataSource)
Set the data source to retrieve the value from.
|
void |
setIncrementerName(java.lang.String incrementerName)
Set the name of the sequence/table.
|
void |
setPaddingLength(int paddingLength)
Set the padding length, i.e.
|
protected int paddingLength
public AbstractDataFieldMaxValueIncrementer()
public AbstractDataFieldMaxValueIncrementer(javax.sql.DataSource dataSource, java.lang.String incrementerName)
dataSource
- the DataSource to useincrementerName
- the name of the sequence/table to usepublic void setDataSource(javax.sql.DataSource dataSource)
public javax.sql.DataSource getDataSource()
public void setIncrementerName(java.lang.String incrementerName)
public java.lang.String getIncrementerName()
public void setPaddingLength(int paddingLength)
public int getPaddingLength()
public void afterPropertiesSet()
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, ApplicationContextAware
etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet
in interface InitializingBean
public int nextIntValue() throws DataAccessException
DataFieldMaxValueIncrementer
nextIntValue
in interface DataFieldMaxValueIncrementer
DataAccessException
- in case of errorspublic long nextLongValue() throws DataAccessException
DataFieldMaxValueIncrementer
nextLongValue
in interface DataFieldMaxValueIncrementer
DataAccessException
- in case of errorspublic java.lang.String nextStringValue() throws DataAccessException
DataFieldMaxValueIncrementer
nextStringValue
in interface DataFieldMaxValueIncrementer
DataAccessException
- in case of errorsprotected abstract long getNextKey()