public class RandomIdentifierGenerationStrategy extends Object implements IdentifierGenerationStrategy
Random
source and encodes them into a string using a
BinaryEncoder
(Hex
by default).Constructor and Description |
---|
RandomIdentifierGenerationStrategy()
Constructor.
|
RandomIdentifierGenerationStrategy(int identifierSize)
Constructor.
|
RandomIdentifierGenerationStrategy(Random source,
int identifierSize,
org.apache.commons.codec.BinaryEncoder identifierEncoder)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
generateIdentifier()
Generates an identifier guaranteed to be XML ID safe.
|
String |
generateIdentifier(boolean xmlSafe)
Generates an identifier.
|
public RandomIdentifierGenerationStrategy()
SecureRandom
, size of identifier is set to 16
bytes, and the encoder is set to a Hex
.public RandomIdentifierGenerationStrategy(int identifierSize)
SecureRandom
and the encoder is set to a
Hex
.identifierSize
- number of random bytes in identifierpublic RandomIdentifierGenerationStrategy(@Nonnull Random source, int identifierSize, @Nonnull org.apache.commons.codec.BinaryEncoder identifierEncoder)
source
- source of random bytesidentifierSize
- number of random bytes in the identifieridentifierEncoder
- encoder used to convert random bytes to string identifier@Nonnull public String generateIdentifier()
generateIdentifier
in interface IdentifierGenerationStrategy
public String generateIdentifier(boolean xmlSafe)
generateIdentifier
in interface IdentifierGenerationStrategy
xmlSafe
- true iff the result must be XML ID safeCopyright © 2016 JBoss by Red Hat. All rights reserved.