public interface IdGenerator
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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
Modifier and Type | Method and Description |
---|---|
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 |
static final java.lang.String CLASS_VERSION
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 spaceIdGeneratorException
- 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 spaceIdGeneratorException
- if there is an error generating
the idIdSpace getIdSpace(java.lang.String pName)
name
- of id space to getjava.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 nullIdGeneratorException
- 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 nulljava.lang.IllegalArgumentException
- if the specified space is
null or otherwise invalidIdGeneratorException
- 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