org.jpox.store.poid
Class AbstractPoidGenerator

java.lang.Object
  extended byorg.jpox.store.poid.AbstractPoidGenerator
All Implemented Interfaces:
PoidGenerator, javax.jdo.datastore.Sequence
Direct Known Subclasses:
AbstractDatastorePoidGenerator, AbstractUIDPoidGenerator

public abstract class AbstractPoidGenerator
extends java.lang.Object
implements PoidGenerator

Abstract POID generator.

Version:
$Revision: 1.5 $

Field Summary
protected  int defaultBlockSize
          Default block size
protected static Localiser LOCALISER
          Localisation of messages
protected  java.lang.String name
          Symbolic name for the sequence.
protected  PoidBlock poidBlock
          The current block of ids that have been reserved.
protected  java.util.Properties properties
          Properties controlling the generator behaviour.
 
Constructor Summary
AbstractPoidGenerator(java.lang.String name, java.util.Properties props)
          Constructor.
 
Method Summary
 void allocate(int additional)
          Method to allocate a number of values into the block.
protected  boolean createRepository()
          Method to create any needed repository for the ids.
 java.lang.Object current()
          Accessor for the current value allocated.
 long currentValue()
          Accessor for the current element in the sequence as a long.
 java.lang.String getName()
          Accessor for the symbolic name for this generator.
 java.lang.Object next()
          Get next value from the reserved block of values.
 long nextValue()
          Accessor for the next element in the sequence as a long.
protected  PoidBlock obtainPoidBlock()
          Get a new PoidBlock with the default number of ids.
protected  PoidBlock obtainPoidBlock(int number)
          Get a new PoidBlock with the specified number of ids.
protected  boolean requiresRepository()
          Indicator for whether the generator requires its own repository.
protected  PoidBlock reserveBlock()
          Method to reserve a default sized block of identities.
protected abstract  PoidBlock reserveBlock(long size)
          Method to reserve a blobk of "size" ids.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation of messages


name

protected java.lang.String name
Symbolic name for the sequence.


properties

protected java.util.Properties properties
Properties controlling the generator behaviour.


defaultBlockSize

protected int defaultBlockSize
Default block size


poidBlock

protected PoidBlock poidBlock
The current block of ids that have been reserved.

Constructor Detail

AbstractPoidGenerator

public AbstractPoidGenerator(java.lang.String name,
                             java.util.Properties props)
Constructor.

Parameters:
name - Symbolic name for this generator
props - Properties controlling the behaviour of the generator (or null if not required).
Method Detail

getName

public java.lang.String getName()
Accessor for the symbolic name for this generator.

Specified by:
getName in interface javax.jdo.datastore.Sequence
Returns:
Symbolic name for the generator.

next

public java.lang.Object next()
Get next value from the reserved block of values.

Specified by:
next in interface javax.jdo.datastore.Sequence
Returns:
The next value

current

public java.lang.Object current()
Accessor for the current value allocated. Returns null if none are allocated

Specified by:
current in interface javax.jdo.datastore.Sequence
Returns:
The current value

nextValue

public long nextValue()
Accessor for the next element in the sequence as a long.

Specified by:
nextValue in interface javax.jdo.datastore.Sequence
Returns:
The next element
Throws:
javax.jdo.JDODataStoreException - Thrown if not numeric

currentValue

public long currentValue()
Accessor for the current element in the sequence as a long.

Specified by:
currentValue in interface javax.jdo.datastore.Sequence
Returns:
The current element
Throws:
javax.jdo.JDODataStoreException - 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 interface javax.jdo.datastore.Sequence
Parameters:
additional - The number to allocate

obtainPoidBlock

protected PoidBlock obtainPoidBlock()
Get a new PoidBlock with the default number of ids.

Returns:
the PoidBlock

obtainPoidBlock

protected PoidBlock obtainPoidBlock(int number)
Get a new PoidBlock with the specified number of ids.

Parameters:
number - The number of additional ids required
Returns:
the PoidBlock

reserveBlock

protected PoidBlock reserveBlock()
Method to reserve a default sized block of identities.

Returns:
The reserved block

reserveBlock

protected abstract PoidBlock reserveBlock(long size)
Method to reserve a blobk of "size" ids.

Parameters:
size - Number of ids to reserve
Returns:
The allocated block

requiresRepository

protected boolean requiresRepository()
Indicator for whether the generator requires its own repository. AbstractPoidGenerator returns false and this should be overridden by all generators requiring a repository.

Returns:
Whether a repository is required.

createRepository

protected boolean createRepository()
Method to create any needed repository for the ids. AbstractPoidGenerator just returns true and should be overridden by any implementing generator requiring its own repository.

Returns:
If all is ready for use


Copyright © -2007 . All Rights Reserved.