|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.id.uuid.VersionFourGenerator
public final class VersionFourGenerator
Class is responsible for generating version 4 UUID's per RFC 4122.
This class attempts to use a java.security.SecureRandom with
the following instantiation
SecureRandom.getInstance("SHA1PRNG", "SUN")
. If neither secure
random implementation is avialable or an Exception is raised a java.util.Random
is used.
Note: Instantiation of SecureRandom is an expensive operation. The constructor therefore creates a static member to hold the SecureRandom. The first call to getInstance may take time; subsequent calls should return quickly.
Field Summary |
---|
Constructor Summary | |
---|---|
VersionFourGenerator()
Constructs a new VersionFourGenerator. |
Method Summary | |
---|---|
static VersionFourGenerator |
getInstance()
Returns a singleton instance of the version four UUID generator. |
java.lang.Object |
nextIdentifier()
Returns a new version four UUID. |
java.lang.Object |
nextIdentifier(boolean secure)
Returns a new version four UUID. |
UUID |
nextUUID()
Returns a new version four UUID. |
static void |
setPRNGProvider(java.lang.String prngName,
java.lang.String packageName)
Allows clients to set the pseudo-random number generator implementation used when generating a version four uuid with the secure option. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VersionFourGenerator()
Constructs a new VersionFourGenerator.
Method Detail |
---|
public static VersionFourGenerator getInstance()
Returns a singleton instance of the version four UUID generator.
public java.lang.Object nextIdentifier()
Returns a new version four UUID.
nextIdentifier
in interface IdentifierGenerator
public java.lang.Object nextIdentifier(boolean secure)
Returns a new version four UUID.
This overloaded method may produce both UUID's using a SecureRandom
as well as using normal
Random
secure
- indicates whether or not to use SecureRandom
in generating the random bits.
Random
or SecureRandom
.public UUID nextUUID()
Returns a new version four UUID.
public static void setPRNGProvider(java.lang.String prngName, java.lang.String packageName)
Allows clients to set the pseudo-random number generator implementation used when generating a version four uuid with
the secure option. The secure option uses a SecureRandom
. The packageName string may be null to specify
no preferred package.
prngName
- the pseudo-random number generator implementation name. For example "SHA1PRNG".packageName
- the package name for the PRNG provider. For example "SUN".
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |