Top Description Fields Constructors Methods
org.apache.derby.impl.sql.execute

public Class AutoincrementCounter

extends Object
Class Inheritance
Imports
org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.dictionary.TableDescriptor, .ColumnDescriptor, .DataDictionary, org.apache.derby.iapi.store.access.TransactionController, org.apache.derby.shared.common.error.StandardException, org.apache.derby.catalog.UUID, org.apache.derby.shared.common.reference.SQLState

AutoincrementCounter 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.

Field Summary

Modifier and TypeField and Description
private String
private int
private long
private long
private String
private long
private boolean
private String
private Long
private String

Constructor Summary

AccessConstructor and Description
public
AutoincrementCounter(Long
The start value of the counter; is a java object as it can also be null.
start
,
long
how much to increment the counter by.
increment
,
long
the finalvalue of the counter. used by reset
finalValue
,
String s, String t, String c, int position)

constructor

Method Summary

Modifier and TypeMethod and Description
public void
flushToDisk(TransactionController
TransactionController to use
tc
,
DataDictionary
DataDictionary to use.
dd
,
UUID
I might have the table name but I need more information
tableUUID
)

flush a counter to disk; i.e write the current value of the counter into the row in SYSCOLUMNS.

public int

Returns:

the position of the corresponding column in the table (1-based)
getColumnPosition
()

get the column position in the table for which this counter has been created.

public Long
getCurrentValue()

get the current value of the counter.

public String
getIdentity()

return the identity of the counter.

public Long

Returns:

the initial value of the counter
getStartValue
()

get the start value

public static String
makeIdentity(String s, String t, String c)

make a unique key for the counter.

public static String
makeIdentity(TableDescriptor td, ColumnDescriptor cd)

make a unique key for the counter.

public void
reset(boolean
if TRUE reset to beginning and mark it uninitialized.
begin
)

reset to the counter to the beginning or the end.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public long
update(long
update the counter to this value.
t
)

update the counter.

public long
update()

update the counter to its next value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

columnNameback to summary
private String columnName
columnPositionback to summary
private int columnPosition
counterback to summary
private long counter
finalValueback to summary
private long finalValue
identityback to summary
private String identity
incrementback to summary
private long increment
initializedback to summary
private boolean initialized
schemaNameback to summary
private String schemaName
startback to summary
private Long start
tableNameback to summary
private String tableName

Constructor Detail

AutoincrementCounterback to summary
public AutoincrementCounter(Long start, long increment, long finalValue, String s, String t, String c, int position)

constructor

Parameters
start:Long

The start value of the counter; is a java object as it can also be null.

increment:long

how much to increment the counter by.

finalValue:long

the finalvalue of the counter. used by reset

Method Detail

flushToDiskback to summary
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

TransactionController to use

dd:DataDictionary

DataDictionary to use.

tableUUID:UUID

I might have the table name but I need more information

Exceptions
StandardException:
standard Derby exception.
getColumnPositionback to summary
public int getColumnPosition()

get the column position in the table for which this counter has been created.

Returns:int

the position of the corresponding column in the table (1-based)

getCurrentValueback to summary
public Long getCurrentValue()

get the current value of the counter. An uninitialized counter means the current value is NULL.

getIdentityback to summary
public String getIdentity()

return the identity of the counter.

getStartValueback to summary
public Long getStartValue()

get the start value

Returns:Long

the initial value of the counter

makeIdentityback to summary
public static String makeIdentity(String s, String t, String c)

make a unique key for the counter.

makeIdentityback to summary
public static String makeIdentity(TableDescriptor td, ColumnDescriptor cd)

make a unique key for the counter.

resetback to summary
public void reset(boolean begin)

reset to the counter to the beginning or the end.

Parameters
begin:boolean

if TRUE reset to beginning and mark it uninitialized.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

updateback to summary
public long update(long t)

update the counter.

Parameters
t:long

update the counter to this value.

updateback to summary
public long update() throws StandardException

update the counter to its next value.

Exceptions
StandardException:
if the counter has not yet been initialized and the Start value is NULL.