public class AutoincrementCounter
extends java.lang.Object
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 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
|
Modifier and Type | Method and Description |
---|---|
void |
flushToDisk(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.
|
int |
getColumnPosition()
get the column position in the table for which this counter has been
created.
|
java.lang.Long |
getCurrentValue()
get the current value of the counter.
|
java.lang.String |
getIdentity()
return the identity of the counter.
|
java.lang.Long |
getStartValue()
get the start value
|
static java.lang.String |
makeIdentity(java.lang.String s,
java.lang.String t,
java.lang.String c)
make a unique key for the counter.
|
static java.lang.String |
makeIdentity(TableDescriptor td,
ColumnDescriptor cd)
make a unique key for the counter.
|
void |
reset(boolean begin)
reset to the counter to the beginning or the end.
|
java.lang.String |
toString() |
long |
update()
update the counter to its next value.
|
long |
update(long t)
update the counter.
|
public AutoincrementCounter(java.lang.Long start, long increment, long finalValue, java.lang.String s, java.lang.String t, java.lang.String c, int position)
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
- public static java.lang.String makeIdentity(java.lang.String s, java.lang.String t, java.lang.String c)
public static java.lang.String makeIdentity(TableDescriptor td, ColumnDescriptor cd)
public void reset(boolean begin)
begin
- if TRUE reset to beginning and mark it uninitialized.public long update(long t)
t
- update the counter to this value.public long update() throws StandardException
StandardException
- if the counter has not yet been
initialized and the Start value is NULL.public java.lang.Long getCurrentValue()
public java.lang.String getIdentity()
public void flushToDisk(TransactionController tc, DataDictionary dd, UUID tableUUID) throws StandardException
tc
- TransactionController to usedd
- DataDictionary to use.tableUUID
- I might have the table name but I need more
informationStandardException
- standard Derby exception.public int getColumnPosition()
public java.lang.Long getStartValue()
public java.lang.String toString()
toString
in class java.lang.Object