Class AbstractGenerator<T>
java.lang.Object
org.datanucleus.store.valuegenerator.AbstractGenerator<T>
- All Implemented Interfaces:
ValueGenerator<T>
- Direct Known Subclasses:
AbstractConnectedGenerator
,AbstractUUIDGenerator
,AUIDGenerator
,TimestampGenerator
,TimestampValueGenerator
,UUIDGenerator
,UUIDObjectGenerator
Abstract value generator.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
Allocation sizeprotected ValueGenerationBlock
<T> The current block of values that have been reserved.protected int
Initial value (of the first id).protected String
Symbolic name for the value generator.protected StoreManager
Fields inherited from interface org.datanucleus.store.valuegenerator.ValueGenerator
PROPERTY_CATALOG_NAME, PROPERTY_CLASS_NAME, PROPERTY_COLUMN_NAME, PROPERTY_FIELD_NAME, PROPERTY_KEY_CACHE_SIZE, PROPERTY_KEY_DATABASE_CACHE_SIZE, PROPERTY_KEY_INITIAL_VALUE, PROPERTY_KEY_MAX_VALUE, PROPERTY_KEY_MIN_VALUE, PROPERTY_ROOT_CLASS_NAME, PROPERTY_SCHEMA_NAME, PROPERTY_SEQUENCE_NAME, PROPERTY_SEQUENCETABLE_CATALOG, PROPERTY_SEQUENCETABLE_NAME_COLUMN, PROPERTY_SEQUENCETABLE_NEXTVAL_COLUMN, PROPERTY_SEQUENCETABLE_SCHEMA, PROPERTY_SEQUENCETABLE_TABLE, PROPERTY_TABLE_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
allocate
(int additional) Method to allocate a number of values into the block.current()
Accessor for the current value allocated.long
Accessor for the current element as a long.private long
Convenience method to convert a value into a long.getName()
Accessor for the symbolic name for this generator.next()
Get next value from the reserved block of values.long
Accessor for the next element as a long.protected ValueGenerationBlock
<T> Get a new block with the default number of ids.protected ValueGenerationBlock
<T> obtainGenerationBlock
(int number) Get a new block with the specified number of ids.protected ValueGenerationBlock
<T> Method to reserve a default sized block of values.protected abstract ValueGenerationBlock
<T> reserveBlock
(long size) Method to reserve a block of "size" values.
-
Field Details
-
storeMgr
-
name
Symbolic name for the value generator. -
allocationSize
protected int allocationSizeAllocation size -
initialValue
protected int initialValueInitial value (of the first id). -
block
The current block of values that have been reserved.
-
-
Constructor Details
-
AbstractGenerator
Constructor.- Parameters:
storeMgr
- Store Managername
- Symbolic name for this generator
-
-
Method Details
-
getName
Accessor for the symbolic name for this generator.- Returns:
- Symbolic name for the generator.
-
next
Get next value from the reserved block of values.- Specified by:
next
in interfaceValueGenerator<T>
- Returns:
- The next value
-
current
Accessor for the current value allocated. Returns null if none are allocated- Specified by:
current
in interfaceValueGenerator<T>
- Returns:
- The current value
-
nextValue
public long nextValue()Accessor for the next element as a long.- Specified by:
nextValue
in interfaceValueGenerator<T>
- Returns:
- The next element
- Throws:
NucleusDataStoreException
- Thrown if not numeric
-
currentValue
public long currentValue()Accessor for the current element as a long.- Specified by:
currentValue
in interfaceValueGenerator<T>
- Returns:
- The current element
- Throws:
NucleusDataStoreException
- Thrown if not numeric
-
getLongValueForObject
Convenience method to convert a value into a long. Throws NucleusDataStoreException if the value is not numeric.- Parameters:
oid
- The id- Returns:
- The long value
- Throws:
NucleusDataStoreException
- Thrown if not numeric
-
allocate
public void allocate(int additional) Method to allocate a number of values into the block. If the block already exists and has remaining values, the additional values are added to the block.- Specified by:
allocate
in interfaceValueGenerator<T>
- Parameters:
additional
- The number to allocate
-
obtainGenerationBlock
Get a new block with the default number of ids.- Returns:
- the block
-
obtainGenerationBlock
Get a new block with the specified number of ids.- Parameters:
number
- The number of additional ids required- Returns:
- the block
-
reserveBlock
Method to reserve a default sized block of values.- Returns:
- The reserved block
-
reserveBlock
Method to reserve a block of "size" values.- Parameters:
size
- Number of values to reserve- Returns:
- The allocated block
-