Class BufferedSeedGenerator

  • All Implemented Interfaces:
    SeedGenerator, Serializable

    public class BufferedSeedGenerator
    extends Object
    implements SeedGenerator
    A seed generator that wraps another, maintaining a buffer of previously-fetched bytes to reduce the number of I/O calls. The buffer is only used when the requested seed is strictly smaller than the buffer.
    See Also:
    Serialized Form
    • Constructor Detail

      • BufferedSeedGenerator

        public BufferedSeedGenerator​(SeedGenerator delegate,
                                     int size)
        Creates an instance.
        Parameters:
        delegate - the SeedGenerator to wrap
        size - the buffer size in bytes
    • Method Detail

      • generateSeed

        public void generateSeed​(byte[] output)
                          throws SeedException
        Description copied from interface: SeedGenerator
        Generates a seed value for a random number generator in an existing array.
        Specified by:
        generateSeed in interface SeedGenerator
        Parameters:
        output - The array that is to be populated with the seed.
        Throws:
        SeedException - If a seed cannot be generated for any reason.
      • generateSeed

        public byte[] generateSeed​(int length)
                            throws SeedException
        Description copied from interface: SeedGenerator
        Generates and returns a seed value for a random number generator as a new array.
        Specified by:
        generateSeed in interface SeedGenerator
        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.