|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.betwixt.io.id.AbstractIDGenerator
org.apache.commons.betwixt.io.id.RandomIDGenerator
public final class RandomIDGenerator
Generates ID's at random.
The random number source is java.util.Random.
Random ID's are very useful if you're inserting
elements created by Betwixt into a stream with existing
elements.
Using random ID's should reduce the danger of collision
with existing element ID's.
This class can generate positive-only ids (the default)
or it can generate a mix of negative and postive ones.
This behaviour can be set by setPositiveIds(boolean)
or by using the RandomIDGenerator(boolean onlyPositiveIds)
constructor.
| Constructor Summary | |
|---|---|
RandomIDGenerator()
Constructor sets the PositiveIds property to true. |
|
RandomIDGenerator(boolean onlyPositiveIds)
Constructor sets PositiveIds property. |
|
| Method Summary | |
|---|---|
boolean |
getPositiveIds()
Gets whether only positive ID's should be generated |
java.lang.String |
nextIdImpl()
Generates a random ID. |
void |
setPositiveIds(boolean onlyPositiveIds)
Sets whether only positive ID's should be generated |
| Methods inherited from class org.apache.commons.betwixt.io.id.AbstractIDGenerator |
|---|
getLastId, nextId |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RandomIDGenerator()
PositiveIds property to true.
public RandomIDGenerator(boolean onlyPositiveIds)
PositiveIds property.
onlyPositiveIds - set PositiveIds property to this value| Method Detail |
|---|
public java.lang.String nextIdImpl()
Generates a random ID.
If the PositiveIds property is true,
then this method will recursively call itself if the random
ID is less than zero.
nextIdImpl in class AbstractIDGeneratorpublic boolean getPositiveIds()
ID's should be generated
public void setPositiveIds(boolean onlyPositiveIds)
ID's should be generated
onlyPositiveIds - pass true if only positive IDs should be generated
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||