|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.text.ObjectIdGenerator
org.pfsw.db.util.ObjectIdentifierGenerator
org.pfsw.db.util.ObjectIdentifierDB
public class ObjectIdentifierDB
Instances of this class provide generation of unique identifiers backed by a specific database table. That means the next available id will be always updated in the database.
Field Summary | |
---|---|
protected java.lang.Integer |
blockSize
|
protected static int |
INITIAL_BLOCKSIZE
|
protected static java.lang.String |
OID_CN_BLOCKSIZE
|
protected static java.lang.String |
OID_CN_CATEGORY
|
protected static java.lang.String |
OID_CN_NEXTID
|
protected static java.lang.String |
OID_TABLE_NAME
|
protected boolean |
tableInitialized
|
Fields inherited from class org.pfsw.text.ObjectIdGenerator |
---|
bufferLen, DEFAULT_LENGTH, DEFAULT_PAD_CHAR, DEFAULT_START_ID |
Constructor Summary | |
---|---|
ObjectIdentifierDB(javax.sql.DataSource ds)
Initialize the new instance with the given data source. |
|
ObjectIdentifierDB(javax.sql.DataSource ds,
java.lang.String categoryName)
Initialize the new instance with the data source. |
|
ObjectIdentifierDB(java.lang.String tableQualifier,
javax.sql.DataSource ds)
Initialize the new instance with the given data source. |
|
ObjectIdentifierDB(java.lang.String tableQualifier,
javax.sql.DataSource ds,
java.lang.String categoryName)
Initialize the new instance with the data source. |
Method Summary | |
---|---|
protected boolean |
anyRowExists(java.sql.Connection conn,
java.lang.String sql)
|
protected java.lang.String |
categoryString()
|
protected boolean |
checkCategoryRowExists(java.sql.Connection conn)
|
protected boolean |
checkTableExists(java.sql.Connection conn)
|
protected void |
closeConnection(java.sql.Connection conn)
|
protected void |
closeStatement(java.sql.Statement stmt)
|
protected void |
createOidTable(java.sql.Connection conn)
|
protected void |
createRowForCategory(java.sql.Connection conn)
|
int |
getBlockSize()
Returns the block size this generator is using. |
protected java.lang.String |
getCategory()
|
protected javax.sql.DataSource |
getDataSource()
|
protected java.sql.Connection |
getDbConnection()
|
protected long |
getLastPrefetchedId()
|
protected long |
getNextId()
|
protected java.lang.String |
getQualifier()
|
protected java.lang.String |
getSelect()
|
protected java.lang.String |
getSelectAny()
|
protected java.lang.String |
getSelectCategory()
|
protected java.lang.String |
getTableName()
|
protected java.lang.String |
getUpdate()
|
protected long |
idFromDB()
|
protected void |
loadNextIdFromDB()
|
protected org.pfsw.logging.Logger |
logger()
|
protected void |
reportSQLException(java.lang.String msg,
java.sql.SQLException ex)
|
void |
setBlockSize(int newValue)
Set the block size this generator is using. |
protected void |
setCategory(java.lang.String newValue)
|
protected void |
setDataSource(javax.sql.DataSource newValue)
|
protected void |
setLastPrefetchedId(long newValue)
|
protected void |
setNextId(long id)
|
protected void |
setNextIdInDB(java.sql.Connection conn,
long id)
|
protected void |
setQualifier(java.lang.String newValue)
|
protected void |
setSelect(java.lang.String newValue)
|
protected void |
setSelectAny(java.lang.String newValue)
|
protected void |
setSelectCategory(java.lang.String newValue)
|
protected void |
setUpdate(java.lang.String newValue)
|
protected java.lang.String |
sqlCreateOidTable()
|
protected java.lang.String |
sqlInsertCategoryRow(java.lang.String cat)
|
protected java.lang.String |
sqlSelectAny()
|
protected java.lang.String |
sqlSelectCategory()
|
protected java.lang.String |
sqlSelectNextId()
|
protected java.lang.String |
sqlUpdateNextId()
|
protected boolean |
tableInitialized()
|
Methods inherited from class org.pfsw.text.ObjectIdGenerator |
---|
calcBufferLength, generateString, generateString, getDefaultLength, getDefaultPadChar, getDefaultStartId, getFullLength, getLength, getNextAvailableId, getPadChar, getPrefix, getPrefixLength, hasPrefix, leftPad, newIdentifier, nextIdentifier, setLength, setNextAvailableId, setPadChar, setPrefix, str |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.pfsw.db.util.ObjectIdentifierProducer |
---|
nextIdentifier |
Methods inherited from interface org.pfsw.bif.identifier.IObjectIdGenerator |
---|
newIdentifier |
Field Detail |
---|
protected static final java.lang.String OID_TABLE_NAME
protected static final java.lang.String OID_CN_CATEGORY
protected static final java.lang.String OID_CN_NEXTID
protected static final java.lang.String OID_CN_BLOCKSIZE
protected static final int INITIAL_BLOCKSIZE
protected boolean tableInitialized
protected java.lang.Integer blockSize
Constructor Detail |
---|
public ObjectIdentifierDB(javax.sql.DataSource ds)
ds
- A valid data source that allows connection to a databasepublic ObjectIdentifierDB(java.lang.String tableQualifier, javax.sql.DataSource ds)
tableQualifier
- A qualifier that is put in front of the table nameds
- A valid data source that allows connection to a databasepublic ObjectIdentifierDB(javax.sql.DataSource ds, java.lang.String categoryName)
ds
- A valid data source that allows connection to a databasecategoryName
- The name of the OID's categorypublic ObjectIdentifierDB(java.lang.String tableQualifier, javax.sql.DataSource ds, java.lang.String categoryName)
tableQualifier
- A qualifier that is put in front of the table nameds
- A valid data source that allows connection to a databasecategoryName
- The name of the OID's categoryMethod Detail |
---|
public int getBlockSize()
public void setBlockSize(int newValue)
protected long getNextId()
getNextId
in class org.pfsw.text.ObjectIdGenerator
protected void loadNextIdFromDB()
protected void setNextId(long id)
setNextId
in class org.pfsw.text.ObjectIdGenerator
protected void setNextIdInDB(java.sql.Connection conn, long id) throws java.sql.SQLException
java.sql.SQLException
protected boolean tableInitialized()
protected long idFromDB()
protected java.lang.String sqlCreateOidTable()
protected java.lang.String sqlInsertCategoryRow(java.lang.String cat)
protected java.lang.String sqlUpdateNextId()
protected java.lang.String sqlSelectNextId()
protected java.lang.String sqlSelectCategory()
protected java.lang.String sqlSelectAny()
protected java.lang.String categoryString()
protected void createOidTable(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
protected void createRowForCategory(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
protected boolean checkTableExists(java.sql.Connection conn)
protected boolean checkCategoryRowExists(java.sql.Connection conn)
protected boolean anyRowExists(java.sql.Connection conn, java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
protected void reportSQLException(java.lang.String msg, java.sql.SQLException ex)
protected java.lang.String getTableName()
protected java.sql.Connection getDbConnection() throws java.sql.SQLException
java.sql.SQLException
protected void closeConnection(java.sql.Connection conn)
protected void closeStatement(java.sql.Statement stmt)
protected org.pfsw.logging.Logger logger()
protected javax.sql.DataSource getDataSource()
protected void setDataSource(javax.sql.DataSource newValue)
protected java.lang.String getCategory()
protected void setCategory(java.lang.String newValue)
protected java.lang.String getSelect()
protected void setSelect(java.lang.String newValue)
protected java.lang.String getSelectCategory()
protected void setSelectCategory(java.lang.String newValue)
protected java.lang.String getSelectAny()
protected void setSelectAny(java.lang.String newValue)
protected java.lang.String getUpdate()
protected void setUpdate(java.lang.String newValue)
protected java.lang.String getQualifier()
protected void setQualifier(java.lang.String newValue)
protected long getLastPrefetchedId()
protected void setLastPrefetchedId(long newValue)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |