Interface SeedGenerator
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
BufferedSeedGenerator
,DefaultSeedGenerator
,DevRandomSeedGenerator
,RandomDotOrgSeedGenerator
,SecureRandomSeedGenerator
,SeedGeneratorPreferenceList
public interface SeedGenerator extends Serializable
Strategy interface for seeding random number generators. Implementations that can have multiple equivalent instances that contend for a resource should implementObject.equals(Object)
andObject.hashCode()
to help with de-duplication ofSimpleRandomSeeder
instances.- Author:
- Daniel Dyer, Chris Hennick
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]
EMPTY_SEED
An empty byte array.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
generateSeed(byte[] output)
Generates a seed value for a random number generator in an existing array.byte[]
generateSeed(int length)
Generates and returns a seed value for a random number generator as a new array.boolean
isWorthTrying()
Returns true if we cannot determine quickly (i.e.
-
-
-
Method Detail
-
generateSeed
void generateSeed(byte[] output) throws SeedException
Generates a seed value for a random number generator in an existing array.- Parameters:
output
- The array that is to be populated with the seed.- Throws:
SeedException
- If a seed cannot be generated for any reason.
-
generateSeed
byte[] generateSeed(int length) throws SeedException
Generates and returns a seed value for a random number generator as a new array.- Parameters:
length
- The length of the seed to generate (in bytes).- Returns:
- A byte array containing the seed data.
- Throws:
SeedException
- If a seed cannot be generated for any reason.
-
isWorthTrying
boolean isWorthTrying()
Returns true if we cannot determine quickly (i.e. without I/O calls) that this SeedGenerator would throw aSeedException
ifgenerateSeed(int)
orgenerateSeed(byte[])
were being called right now.- Returns:
- true if this SeedGenerator will get as far as an I/O call or other slow operation in attempting to generate a seed immediately.
-
-