sam.io
Class RandomMixer

java.lang.Object
  |
  +--sam.io.Mixer
        |
        +--sam.io.RandomMixer

public class RandomMixer
extends Mixer

Basic pseudo-random implementation of a mixer.


Nested Class Summary
 
Nested classes inherited from class sam.io.Mixer
Mixer.InputStream, Mixer.OutputStream
 
Field Summary
static sam.io.RandomMixer DEFAULT
          Immutable default value, defined as new RandomMixer(0.05, 0.05, 0.50, 0.50)
 float density
          Actual density factor
 float frequency
          Actual frequency factor
 float redundancy
          Actual redundancy factor
 float variety
          Actual variety factor
 
Fields inherited from class sam.io.Mixer
DUMMY
 
Constructor Summary
RandomMixer(float frequency, float density, float variety, float redundancy)
          Builds a new RandomMixer instance, with values as float in the range 0.01..0.99
RandomMixer(java.lang.String frequency)
           
RandomMixer(java.lang.String frequency, java.lang.String density)
           
RandomMixer(java.lang.String frequency, java.lang.String density, java.lang.String variety)
           
RandomMixer(java.lang.String frequency, java.lang.String density, java.lang.String variety, java.lang.String redundancy)
          Builds a new RandomMixer instance, with values as String coding integers in the range 1..99
 
Method Summary
static int factored(float value, int factor)
           
protected  long getDataChunkLength(long blockSize)
          Sets the next data chunk length, in bytes.
 void readGarbageChunk(java.io.InputStream stream, long length)
          Reads garbage data from the stream.
 java.lang.String toString()
           
 java.lang.String verbose()
           
 void writeGarbageChunk(java.io.OutputStream delegee)
          Writes garbage data to the stream.
 
Methods inherited from class sam.io.Mixer
blockSize, getTrace, nextDataChunkLength, setBlockSize, setTrace, setTracker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final sam.io.RandomMixer DEFAULT
Immutable default value, defined as new RandomMixer(0.05, 0.05, 0.50, 0.50)


density

public final float density
Actual density factor


frequency

public final float frequency
Actual frequency factor


variety

public final float variety
Actual variety factor


redundancy

public final float redundancy
Actual redundancy factor

Constructor Detail

RandomMixer

public RandomMixer(java.lang.String frequency)
            throws java.lang.NumberFormatException

RandomMixer

public RandomMixer(java.lang.String frequency,
                   java.lang.String density)
            throws java.lang.NumberFormatException

RandomMixer

public RandomMixer(java.lang.String frequency,
                   java.lang.String density,
                   java.lang.String variety)
            throws java.lang.NumberFormatException

RandomMixer

public RandomMixer(java.lang.String frequency,
                   java.lang.String density,
                   java.lang.String variety,
                   java.lang.String redundancy)
            throws java.lang.NumberFormatException
Builds a new RandomMixer instance, with values as String coding integers in the range 1..99


RandomMixer

public RandomMixer(float frequency,
                   float density,
                   float variety,
                   float redundancy)
            throws java.lang.NumberFormatException
Builds a new RandomMixer instance, with values as float in the range 0.01..0.99

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

verbose

public java.lang.String verbose()

factored

public static int factored(float value,
                           int factor)

getDataChunkLength

protected long getDataChunkLength(long blockSize)
Description copied from class: Mixer
Sets the next data chunk length, in bytes.

Specified by:
getDataChunkLength in class Mixer
Parameters:
blockSize - the block size of the data stream, which might be zero to specify infinite block size A lazy implementation might just return blockSize
Returns:
desired data chunk length, or zero to specify unlimited data chunk

writeGarbageChunk

public void writeGarbageChunk(java.io.OutputStream delegee)
                       throws java.io.IOException
Description copied from class: Mixer
Writes garbage data to the stream.

Specified by:
writeGarbageChunk in class Mixer
Parameters:
delegee - the output to write onto Note that the number of bytes written will be kept back automatically
java.io.IOException

readGarbageChunk

public void readGarbageChunk(java.io.InputStream stream,
                             long length)
                      throws java.io.IOException
Description copied from class: Mixer
Reads garbage data from the stream.

Specified by:
readGarbageChunk in class Mixer
Parameters:
stream - the input to write onto
length - the number of garbage bytes to read
java.io.IOException