org.objectweb.jorm.facility.naming.longid
Class CompositePLongGen

java.lang.Object
  extended byorg.objectweb.jorm.facility.naming.longid.CompositePLongGen
All Implemented Interfaces:
LongGen, PLongGen

public class CompositePLongGen
extends java.lang.Object
implements PLongGen

This object long identifier generates identifier divided in two parts. The first part is the value representing a class persistent class. The second part is a value representing the instance of the class. In fact this generator adds a fixed value (class id) with another long values choosen by a sub PLongGen.

Author:
S.Chassande-Barrioz

Field Summary
protected  long cid
          The identifier of the persitent class
protected  int cidSize
           
protected  PLongGen objectIdGenerator
          The inner generator of object identifier
 
Constructor Summary
CompositePLongGen(PLongGen objectIdGenerator, long cid, int cidSize)
           
 
Method Summary
 long allocateIds(int additional)
          Allocate a range of ids.
 long current()
          return the id that will be assigned next time.
 long genId()
          Allocates a new composite identifier
 long genId(java.lang.Object conn)
          Allocates a new composite identifier
 long getCid()
           
 int getIncrement()
           
 void init(java.lang.String name, PClassMapping pcm, LongGenMgr mgr)
          Initializes the underlying object identifier generator
 void setIncrement(int incr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectIdGenerator

protected PLongGen objectIdGenerator
The inner generator of object identifier


cid

protected long cid
The identifier of the persitent class


cidSize

protected int cidSize
Constructor Detail

CompositePLongGen

public CompositePLongGen(PLongGen objectIdGenerator,
                         long cid,
                         int cidSize)
Method Detail

getCid

public long getCid()

init

public void init(java.lang.String name,
                 PClassMapping pcm,
                 LongGenMgr mgr)
          throws PException
Initializes the underlying object identifier generator

Specified by:
init in interface PLongGen
Parameters:
name - The name identifier associated with this long generator.
pcm - The associated PClassMapping.
mgr - The manager associated with this generator.
Throws:
PException

genId

public long genId()
           throws PException
Allocates a new composite identifier

Specified by:
genId in interface LongGen
Returns:
The new identifier.
Throws:
PException

genId

public long genId(java.lang.Object conn)
           throws PException
Allocates a new composite identifier

Specified by:
genId in interface LongGen
Parameters:
conn - is a way to access the data support
Throws:
PException

allocateIds

public long allocateIds(int additional)
                 throws PException
Description copied from interface: LongGen
Allocate a range of ids.

Specified by:
allocateIds in interface LongGen
Parameters:
additional -
Returns:
the last identifier allocated
Throws:
PException

setIncrement

public void setIncrement(int incr)
Specified by:
setIncrement in interface LongGen

getIncrement

public int getIncrement()
Specified by:
getIncrement in interface LongGen

current

public long current()
Description copied from interface: LongGen
return the id that will be assigned next time.

Specified by:
current in interface LongGen