atg.service.idgen
Class IdSpace

java.lang.Object
  extended by atg.service.idgen.IdSpace
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class IdSpace
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

IdSpace defines the scope of a set of ids and how they are generated. Within an IdSpace ids are guaranteed to be unique. There is no logic in this class. The properties of id spaces are manipulated by an id generator according to the rules of that generator.

If this class is subclassed, it should be only to add properties. The logic for generating ids should be contained in an IdGenerator.

See Also:
IdGenerator, Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  int mHashCode
          cached hash code
protected  long mSeed
          seed to use for calculating ids in some sequence
 
Constructor Summary
  IdSpace()
          Empty constructor
  IdSpace(java.lang.String pName, long pSeed)
          Construct an id space with the specfied name and seed.
  IdSpace(java.lang.String pName, long pSeed, int pBatchSize, java.lang.String pPrefix, java.lang.String pSuffix)
          Construct an id space with all the user properties set.
protected IdSpace(java.lang.String pName, long pSeed, long pLastSeed, int pBatchSize, java.lang.String pPrefix, java.lang.String pSuffix)
          Construct an id space with all the properties and fields set.
  IdSpace(java.lang.String pName, long pSeed, java.lang.String pPrefix, java.lang.String pSuffix)
          Construct an id space with the name, seed, prefix, and suffix set.
 
Method Summary
 java.lang.Object clone()
          Get a copy of this object
 void copyFrom(IdSpace pOther)
          Set the values of this object from the specified id space.
 boolean equals(java.lang.Object pOther)
          Compare an object for equality with this object.
 int getBatchSize()
          Get property batchSize
 int getIdsPerBatch()
          Get property idsPerBatch
 long getLastSeed()
          Get property LastSeed
 java.lang.String getName()
          Get property Name
 java.lang.String getPrefix()
          Get property Prefix
 long getSeed()
          Get property Seed
 java.lang.String getSuffix()
          Get property Suffix
 java.util.Set getUsedLongIds()
          Get property usedLongIds
 int hashCode()
          Get the hash code for this object.
 void setBatchSize(int pBatchSize)
          Set property BatchSize
 void setIdsPerBatch(int pIdsPerBatch)
          Set property idsPerBatch
 void setLastSeed(long pLastSeed)
          Internal setter for lastSeed
 void setPrefix(java.lang.String pPrefix)
          Set property Prefix
protected  void setSeed(long pSeed)
          Internal setter for seed.
 void setSuffix(java.lang.String pSuffix)
          Set property Suffix
 void setUsedLongIds(java.util.Set pUsedLongIds)
          Set property usedLongIds
 java.lang.String toString()
          Get a string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


mHashCode

protected transient int mHashCode
cached hash code


mSeed

protected long mSeed
seed to use for calculating ids in some sequence

Constructor Detail

IdSpace

public IdSpace()
Empty constructor


IdSpace

public IdSpace(java.lang.String pName,
               long pSeed)
Construct an id space with the specfied name and seed.

Parameters:
pName - name property
pSeed - seed property

IdSpace

public IdSpace(java.lang.String pName,
               long pSeed,
               java.lang.String pPrefix,
               java.lang.String pSuffix)
Construct an id space with the name, seed, prefix, and suffix set.

Parameters:
pName - name property
pSeed - seed property
pPrefix - prefix property
pSuffix - suffix property

IdSpace

public IdSpace(java.lang.String pName,
               long pSeed,
               int pBatchSize,
               java.lang.String pPrefix,
               java.lang.String pSuffix)
Construct an id space with all the user properties set.

Parameters:
pName - name property
pSeed - seed property
pBatchSize - batchSize property
pPrefix - prefix property
pSuffix - suffix property

IdSpace

protected IdSpace(java.lang.String pName,
                  long pSeed,
                  long pLastSeed,
                  int pBatchSize,
                  java.lang.String pPrefix,
                  java.lang.String pSuffix)
Construct an id space with all the properties and fields set.

Parameters:
pName - name property
pSeed - seed property
pLastSeed - lastSeed property
pBatchSize - batchSize property
pPrefix - prefix property
pSuffix - suffix property
Method Detail

getName

public java.lang.String getName()
Get property Name

Returns:
Name

getSeed

public long getSeed()
Get property Seed

Returns:
Seed

setSeed

protected void setSeed(long pSeed)
Internal setter for seed.

Parameters:
pSeed - new value to set

getLastSeed

public long getLastSeed()
Get property LastSeed

Returns:
LastSeed

setLastSeed

public void setLastSeed(long pLastSeed)
Internal setter for lastSeed

Parameters:
pLastSeed - new value to set

setBatchSize

public void setBatchSize(int pBatchSize)
Set property BatchSize

Parameters:
pBatchSize - new value to set

getBatchSize

public int getBatchSize()
Get property batchSize

Returns:
BatchSize

setIdsPerBatch

public void setIdsPerBatch(int pIdsPerBatch)
Set property idsPerBatch

Parameters:
pIdsPerBatch - new value to set

getIdsPerBatch

public int getIdsPerBatch()
Get property idsPerBatch

Returns:
idsPerBatch

setPrefix

public void setPrefix(java.lang.String pPrefix)
Set property Prefix

Parameters:
pPrefix - new value to set

getPrefix

public java.lang.String getPrefix()
Get property Prefix

Returns:
Prefix

setSuffix

public void setSuffix(java.lang.String pSuffix)
Set property Suffix

Parameters:
pSuffix - new value to set

getSuffix

public java.lang.String getSuffix()
Get property Suffix

Returns:
Suffix

setUsedLongIds

public void setUsedLongIds(java.util.Set pUsedLongIds)
Set property usedLongIds

Parameters:
pUsedLongIds - new value to set

getUsedLongIds

public java.util.Set getUsedLongIds()
Get property usedLongIds

Returns:
usedLongIds

hashCode

public int hashCode()
Get the hash code for this object. We cache the value, which is only dependent on the name

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

equals

public boolean equals(java.lang.Object pOther)
Compare an object for equality with this object. The two are equal if they have the same name, which may be null.

Overrides:
equals in class java.lang.Object
Returns:
true if the other object equals this object, else false

toString

public java.lang.String toString()
Get a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object

clone

public java.lang.Object clone()
Get a copy of this object

Overrides:
clone in class java.lang.Object
Returns:
a copy of this object

copyFrom

public void copyFrom(IdSpace pOther)
Set the values of this object from the specified id space.

Parameters:
pOther - id space to copy from