|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IdGenerator
Facility that generates ids as both Strings and longs. IdGenerators support the concept of an id space. Ids are unique within an id space, but not necessarily across id spaces. This allows a single id generator to generate ids for a related set of objects.
Users of an IdGenerator need not be aware that id spaces exist. All id generators support a default id space which is assumed when no other id space is specified. Additionality, id generators are responsible for initializing the default id space.
Implementations add functionality like: the ability to generate id that are unique in a distributed system; and user defined hooks to modify or filter generated ids.
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string |
Method Summary | |
---|---|
boolean |
addIdSpace(IdSpace pSpace)
Add an id space to the id generator. |
long |
generateLongId()
Generate a long id in the default name space. |
long |
generateLongId(java.lang.String pIdSpace)
Generate a long id in the specified name space. |
java.lang.String |
generateStringId()
Generate a String id in the default name space. |
java.lang.String |
generateStringId(java.lang.String pIdSpace)
Generate a string id in the specified name space. |
boolean |
getAutoCreate()
Get property autoCreate |
IdSpace |
getDefaultIdSpace()
Get property DefaultIdSpace |
IdSpace |
getIdSpace(java.lang.String pName)
Get a copy of the named id space from the generator. |
java.util.Map |
getIdSpaces()
Get a copy of all the spaces defined in the generator. |
void |
initialize()
Initialize the generator, preparing it to generate ids. |
boolean |
isAutoCreate()
Test property autoCreate |
void |
removeAllIdSpaces()
Remove all id spaces from the id generator. |
boolean |
removeIdSpace(IdSpace pSpace)
Remove an id space from the id generator. |
void |
setAutoCreate(boolean pAutoCreate)
Set property autoCreate |
Field Detail |
---|
static final java.lang.String CLASS_VERSION
Method Detail |
---|
IdSpace getDefaultIdSpace()
long generateLongId() throws IdGeneratorException
IdGeneratorException
- if there is an error generating
the idjava.lang.String generateStringId() throws IdGeneratorException
IdGeneratorException
- if there is an error generating
the idlong generateLongId(java.lang.String pIdSpace) throws IdGeneratorException
pIdSpace
- name of id space to use, null means use
the anonymous, default space
IdGeneratorException
- if there is an error generating
the idjava.lang.String generateStringId(java.lang.String pIdSpace) throws IdGeneratorException
pIdSpace
- name of id space to use, null means use
the anonymous, default space
IdGeneratorException
- if there is an error generating
the idIdSpace getIdSpace(java.lang.String pName)
name
- of id space to get
java.util.Map getIdSpaces()
Map
of all the id spaces defined in the
generator. The keys of the Map
are the names of the
spaces, and the values are IdSpace
objectsboolean addIdSpace(IdSpace pSpace) throws IdGeneratorException
pSpace
- space to add, cannot be null
IdGeneratorException
- if there is trouble adding the spacevoid setAutoCreate(boolean pAutoCreate)
autoCreate
pAutoCreate
- new value to setboolean getAutoCreate()
autoCreate
autoCreate
boolean isAutoCreate()
autoCreate
autoCreate
boolean removeIdSpace(IdSpace pSpace) throws IdGeneratorException
pSpace
- space to remove, cannot be null
java.lang.IllegalArgumentException
- if the specified space is
null or otherwise invalid
IdGeneratorException
- if there is trouble removing the spacevoid removeAllIdSpaces() throws IdGeneratorException
IdGeneratorException
- if there is trouble removing the spacesvoid initialize() throws IdGeneratorException
IdGeneratorException
- if there is an error initializing
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |