org.datamixer.collections
Class RandomIterator

java.lang.Object
  extended byorg.datamixer.collections.DatamixerIterator
      extended byorg.datamixer.collections.RandomIterator
All Implemented Interfaces:
DatamixerEventGenerator, java.util.Iterator

public class RandomIterator
extends DatamixerIterator


Field Summary
protected  int count_
          the number of indexes that have been chosen
protected  Value current_
          current value
protected  DatamixerList list_
          the associated list
protected  java.util.Random random_
          random number generator
protected  int[] remaining_
          array to hold indexes of remaining values, when selecting without replacement
protected  boolean replace_
          select with replacement if true
protected  long seed_
          seed for random number generator
protected  int size_
          the collection size
 
Fields inherited from class org.datamixer.collections.DatamixerIterator
collection_, debugEnabled_, done_, doneChecked_, doneListeners_, format_, formatPattern_, id_, infoEnabled_, initialized_, logger_, name_, nextListeners_, path_, repeat_, repeatSet_
 
Constructor Summary
RandomIterator()
           
 
Method Summary
protected  boolean doDone()
          Returns false, always.
protected  void doGenerate()
          Generate the next element in the collection.
protected  Value doGetCurrentValue()
          Returns the current value.
protected  void doInitialize()
          Initialization.
protected  void doReset()
          Resets the iterator to an initial state.
 int getDataType()
          Returns the datatype.
 java.text.Format getFormat(java.lang.String pattern)
          Returns an appropriate Format object.
 boolean getReplace()
           
 long getSeed()
           
protected  int randomIndex()
          Choose a random index.
 void setReplace(boolean value)
           
 void setSeed(long value)
           
protected  void updateRemaining()
          Resets the iterator to an initial state.
 
Methods inherited from class org.datamixer.collections.DatamixerIterator
addDatamixerListener, doFireDatamixerEvent, fireDatamixerEvent, generate, getCollection, getContainer, getCurrent, getCurrentValue, getFormatPattern, getHasNext, getId, getListeners, getName, getNext, getNextValue, getPath, getRepeat, hasNext, initialize, next, remove, removeDatamixerListener, reset, setCollection, setContainer, setCurrentValue, setDataType, setFormatPattern, setId, setName, setRepeat, toString, updateCurrentValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list_

protected DatamixerList list_
the associated list


random_

protected java.util.Random random_
random number generator


seed_

protected long seed_
seed for random number generator


replace_

protected boolean replace_
select with replacement if true


size_

protected int size_
the collection size


current_

protected Value current_
current value


count_

protected int count_
the number of indexes that have been chosen


remaining_

protected int[] remaining_
array to hold indexes of remaining values, when selecting without replacement

Constructor Detail

RandomIterator

public RandomIterator()
Method Detail

getDataType

public int getDataType()
Returns the datatype. Datatypes are defined in java.sql.Types.

Overrides:
getDataType in class DatamixerIterator

doGetCurrentValue

protected Value doGetCurrentValue()
Returns the current value.

Specified by:
doGetCurrentValue in class DatamixerIterator
Returns:
the current value.

getFormat

public java.text.Format getFormat(java.lang.String pattern)
Returns an appropriate Format object.

Overrides:
getFormat in class DatamixerIterator

doInitialize

protected void doInitialize()
                     throws DatamixerException
Initialization.

Overrides:
doInitialize in class DatamixerIterator
Throws:
DatamixerException

doDone

protected boolean doDone()
                  throws DatamixerException
Description copied from class: DatamixerIterator
Returns false, always.

Overrides:
doDone in class DatamixerIterator
Throws:
DatamixerException

doGenerate

protected void doGenerate()
                   throws DatamixerException
Description copied from class: DatamixerIterator
Generate the next element in the collection.

Overrides:
doGenerate in class DatamixerIterator
Throws:
DatamixerException

doReset

protected void doReset()
                throws DatamixerException
Resets the iterator to an initial state.

Overrides:
doReset in class DatamixerIterator
Throws:
DatamixerException

getSeed

public long getSeed()

setSeed

public void setSeed(long value)

getReplace

public boolean getReplace()

setReplace

public void setReplace(boolean value)

randomIndex

protected int randomIndex()
Choose a random index.


updateRemaining

protected void updateRemaining()
Resets the iterator to an initial state.



Copyright © 2004-2006 datamixer.org. All Rights Reserved.