public class SequenceValueGenerator extends AbstractSequenceValueProducer
Sequence
,
StoredSequence
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_INCREMENT |
static int |
DEFAULT_INITIAL_VALUE |
static int |
DEFAULT_RESERVE_AMOUNT |
Constructor and Description |
---|
SequenceValueGenerator(Repository repo,
java.lang.String name)
Construct a new SequenceValueGenerator which might create persistent
sequence data if it does not exist.
|
SequenceValueGenerator(Repository repo,
java.lang.String name,
long initialValue,
int increment)
Construct a new SequenceValueGenerator which might create persistent
sequence data if it does not exist.
|
SequenceValueGenerator(Repository repo,
java.lang.String name,
long initialValue,
int increment,
int reserveAmount)
Construct a new SequenceValueGenerator which might create persistent
sequence data if it does not exist.
|
Modifier and Type | Method and Description |
---|---|
int |
nextIntValue()
Returns the next value from the sequence, which may wrap negative if all
positive values are exhausted.
|
long |
nextLongValue()
Returns the next value from the sequence, which may wrap negative if all
positive values are exhausted.
|
void |
reset(int initialValue)
Reset the sequence.
|
boolean |
returnReservedValues()
Allow any unused reserved values to be returned for re-use.
|
nextDecimalValue, nextNumericalValue
public static final int DEFAULT_RESERVE_AMOUNT
public static final int DEFAULT_INITIAL_VALUE
public static final int DEFAULT_INCREMENT
public SequenceValueGenerator(Repository repo, java.lang.String name) throws RepositoryException
repo
- repository to persist sequence dataname
- name of sequenceRepositoryException
public SequenceValueGenerator(Repository repo, java.lang.String name, long initialValue, int increment) throws RepositoryException
repo
- repository to persist sequence dataname
- name of sequenceinitialValue
- initial sequence value, if sequence needs to be createdincrement
- amount to increment sequence byRepositoryException
public SequenceValueGenerator(Repository repo, java.lang.String name, long initialValue, int increment, int reserveAmount) throws RepositoryException
repo
- repository to persist sequence dataname
- name of sequenceinitialValue
- initial sequence value, if sequence needs to be createdincrement
- amount to increment sequence byreserveAmount
- amount of sequence values to reserveRepositoryException
public void reset(int initialValue) throws FetchException, PersistException
initialValue
- first value produced by sequenceFetchException
PersistException
public long nextLongValue() throws PersistException
Note: this method throws PersistException even for fetch failures since this method is called by insert operations. Insert operations can only throw a PersistException.
PersistException
- for fetch/persist failure or if sequence is exhausted.public int nextIntValue() throws PersistException
Note: this method throws PersistException even for fetch failures since this method is called by insert operations. Insert operations can only throw a PersistException.
nextIntValue
in interface SequenceValueProducer
nextIntValue
in class AbstractSequenceValueProducer
PersistException
- for fetch/persist failure or if sequence is
exhausted for int values.public boolean returnReservedValues() throws FetchException, PersistException
This method should be called during the shutdown process of a repository, although calling it does not invalidate this SequenceValueGenerator. If getNextValue is called again, it will reserve values again.
FetchException
PersistException
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.