org.apache.derby.impl.sql.execute
Class AutoincrementCounter
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.AutoincrementCounter
-
public class AutoincrementCounter extends java.lang.ObjectAutoincrementCounter is a not so general counter for the specific purposes of autoincrement columns. It can be thought of as an in-memory autoincrement column. The counting or incrementing is done in fashion identical to the AUTOINCREMENTVALUE in SYSCOLUMNS.To create a counter, the user must call the constructor with a start value, increment and optionally a final value. In addition the caller must specify the schema name, table name and column name uniquely identifying the counter.
When a counter is created it is in an invalid state-- to initialize it, the user must call either update or reset(false). The value of a counter can be changed by either calling reset or update.
-
-
Constructor Summary
Constructors Constructor and Description AutoincrementCounter(java.lang.Long start, long increment, long finalValue, java.lang.String s, java.lang.String t, java.lang.String c, int position)constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidflushToDisk(TransactionController tc, DataDictionary dd, UUID tableUUID)flush a counter to disk; i.e write the current value of the counter into the row in SYSCOLUMNS.intgetColumnPosition()get the column position in the table for which this counter has been created.java.lang.LonggetCurrentValue()get the current value of the counter.java.lang.StringgetIdentity()return the identity of the counter.java.lang.LonggetStartValue()get the start valuestatic java.lang.StringmakeIdentity(java.lang.String s, java.lang.String t, java.lang.String c)make a unique key for the counter.static java.lang.StringmakeIdentity(TableDescriptor td, ColumnDescriptor cd)make a unique key for the counter.voidreset(boolean begin)reset to the counter to the beginning or the end.java.lang.StringtoString()longupdate()update the counter to its next value.longupdate(long t)update the counter.
-
-
-
Constructor Detail
-
AutoincrementCounter
public AutoincrementCounter(java.lang.Long start, long increment, long finalValue, java.lang.String s, java.lang.String t, java.lang.String c, int position)constructor- Parameters:
start- The start value of the counter; is a java object as it can also be null.increment- how much to increment the counter by.finalValue- the finalvalue of the counter. used by resets-t-c-
-
-
Method Detail
-
makeIdentity
public static java.lang.String makeIdentity(java.lang.String s, java.lang.String t, java.lang.String c)make a unique key for the counter.
-
makeIdentity
public static java.lang.String makeIdentity(TableDescriptor td, ColumnDescriptor cd)
make a unique key for the counter.
-
reset
public void reset(boolean begin)
reset to the counter to the beginning or the end.- Parameters:
begin- if TRUE reset to beginning and mark it uninitialized.
-
update
public long update(long t)
update the counter.- Parameters:
t- update the counter to this value.
-
update
public long update() throws StandardExceptionupdate the counter to its next value.- Throws:
StandardException- if the counter has not yet been initialized and the Start value is NULL.
-
getCurrentValue
public java.lang.Long getCurrentValue()
get the current value of the counter. An uninitialized counter means the current value is NULL.
-
getIdentity
public java.lang.String getIdentity()
return the identity of the counter.
-
flushToDisk
public void flushToDisk(TransactionController tc, DataDictionary dd, UUID tableUUID) throws StandardException
flush a counter to disk; i.e write the current value of the counter into the row in SYSCOLUMNS.- Parameters:
tc- TransactionController to usedd- DataDictionary to use.tableUUID- I might have the table name but I need more information- Throws:
StandardException- standard Derby exception.
-
getColumnPosition
public int getColumnPosition()
get the column position in the table for which this counter has been created.- Returns:
- the position of the corresponding column in the table (1-based)
-
getStartValue
public java.lang.Long getStartValue()
get the start value- Returns:
- the initial value of the counter
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG