org.pfsw.db.util
Class ObjectIdentifierDBBuilder

java.lang.Object
  extended by org.pfsw.db.util.ObjectIdentifierDBBuilder

public class ObjectIdentifierDBBuilder
extends java.lang.Object

Builder for ObjectIdentifierDB that supports fluent API.


Constructor Summary
protected ObjectIdentifierDBBuilder(javax.sql.DataSource ds)
           
 
Method Summary
 ObjectIdentifierDB build()
           
 ObjectIdentifierDBBuilder configureCategory(IdGeneratorCategorySpec categorySpec)
          Sets the values for the category from the given specification.
static ObjectIdentifierDBBuilder create(javax.sql.DataSource ds)
          Creates a new builder instance with the given data source.
static ObjectIdentifierDBBuilder create(javax.sql.DataSource ds, IdGeneratorTableSpec tableSpec)
          Creates a new builder instance with the given data source.
protected  ObjectIdentifierDB getObjectIdentifierDB()
           
 ObjectIdentifierDBBuilder noPadding()
          Configures the ID generator to not do any (left) padding on the generated identifiers.
 ObjectIdentifierDBBuilder setBlockSize(int blockSize)
          Sets how many IDs are reserved in-memory per read of the category from the database.
 ObjectIdentifierDBBuilder setBlockSizeColumn(java.lang.String columnName)
           
 ObjectIdentifierDBBuilder setCategory(java.lang.String category)
          Sets the category name for the identifiers.
 ObjectIdentifierDBBuilder setCategoryColumn(java.lang.String columnName)
           
 ObjectIdentifierDBBuilder setLength(int length)
          Sets the length of the resulting identifiers.
 ObjectIdentifierDBBuilder setNextIdColumn(java.lang.String columnName)
           
 ObjectIdentifierDBBuilder setPaddingChar(char ch)
          Sets the padding character to the given values.
 ObjectIdentifierDBBuilder setPrefix(java.lang.String prefix)
          Sets a prefix string for all IDs to be generated.
 ObjectIdentifierDBBuilder setStartId(long startValue)
          Sets the first value of the IDs to be generated.
 ObjectIdentifierDBBuilder setTableName(java.lang.String tableName)
           
 ObjectIdentifierDBBuilder setTableQualifier(java.lang.String tableQualifier)
           
 ObjectIdentifierDBBuilder setTableSpec(IdGeneratorTableSpec tableSpec)
          Sets the whole table specification.
 ObjectIdentifierDBBuilder tableAlreadyCreated()
          This method should be invoked to prevent automatic table creation which makes sense if the table has been create already externally.
 ObjectIdentifierDBBuilder tableAlreadyCreated(boolean isCreated)
          This method can be invoked to prevent automatic table creation which makes sense if the table has been create already externally.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectIdentifierDBBuilder

protected ObjectIdentifierDBBuilder(javax.sql.DataSource ds)
Method Detail

create

public static ObjectIdentifierDBBuilder create(javax.sql.DataSource ds)
Creates a new builder instance with the given data source.

Parameters:
ds - A valid data source that allows connection to a database (must not be null).

create

public static ObjectIdentifierDBBuilder create(javax.sql.DataSource ds,
                                               IdGeneratorTableSpec tableSpec)
Creates a new builder instance with the given data source.

Parameters:
ds - A valid data source that allows connection to a database (must not be null).
tableSpec - The definition of the table and column names (must not be null).

setCategory

public ObjectIdentifierDBBuilder setCategory(java.lang.String category)
Sets the category name for the identifiers.


setTableSpec

public ObjectIdentifierDBBuilder setTableSpec(IdGeneratorTableSpec tableSpec)
Sets the whole table specification.


configureCategory

public ObjectIdentifierDBBuilder configureCategory(IdGeneratorCategorySpec categorySpec)
Sets the values for the category from the given specification.


setPrefix

public ObjectIdentifierDBBuilder setPrefix(java.lang.String prefix)
Sets a prefix string for all IDs to be generated. By default no prefix is set.


setStartId

public ObjectIdentifierDBBuilder setStartId(long startValue)
Sets the first value of the IDs to be generated. Be aware that this value will be ignored if there is already a table entry in the database for the category and it contains a different value.


setBlockSize

public ObjectIdentifierDBBuilder setBlockSize(int blockSize)
Sets how many IDs are reserved in-memory per read of the category from the database. The default block size is 1.


setLength

public ObjectIdentifierDBBuilder setLength(int length)
Sets the length of the resulting identifiers. This implies that padding is activated and the identifiers will be filled up with leading padding characters.

See Also:
setPaddingChar(char), noPadding()

noPadding

public ObjectIdentifierDBBuilder noPadding()
Configures the ID generator to not do any (left) padding on the generated identifiers. Padding is activated by default!


setPaddingChar

public ObjectIdentifierDBBuilder setPaddingChar(char ch)
Sets the padding character to the given values. The default padding character is '0'.


tableAlreadyCreated

public ObjectIdentifierDBBuilder tableAlreadyCreated()
This method should be invoked to prevent automatic table creation which makes sense if the table has been create already externally.


tableAlreadyCreated

public ObjectIdentifierDBBuilder tableAlreadyCreated(boolean isCreated)
This method can be invoked to prevent automatic table creation which makes sense if the table has been create already externally.


setTableQualifier

public ObjectIdentifierDBBuilder setTableQualifier(java.lang.String tableQualifier)

setTableName

public ObjectIdentifierDBBuilder setTableName(java.lang.String tableName)

setCategoryColumn

public ObjectIdentifierDBBuilder setCategoryColumn(java.lang.String columnName)

setNextIdColumn

public ObjectIdentifierDBBuilder setNextIdColumn(java.lang.String columnName)

setBlockSizeColumn

public ObjectIdentifierDBBuilder setBlockSizeColumn(java.lang.String columnName)

build

public ObjectIdentifierDB build()

getObjectIdentifierDB

protected ObjectIdentifierDB getObjectIdentifierDB()