org.datamixer.collections
Class DatamixerIterator

java.lang.Object
  extended byorg.datamixer.collections.DatamixerIterator
All Implemented Interfaces:
DatamixerEventGenerator, java.util.Iterator
Direct Known Subclasses:
CollectionContainerIterator, CollectionWrapperIterator, ConstantsIterator, IteratorReference, NullIterator, RandomFunction, RandomIterator, SyntheticIterator, ValueListIterator

public abstract class DatamixerIterator
extends java.lang.Object
implements java.util.Iterator, DatamixerEventGenerator


Field Summary
protected  DatamixerCollection collection_
          the associated collection
protected  boolean debugEnabled_
          true if debugging is enabled
protected  boolean done_
          true if done
protected  boolean doneChecked_
          true if done() has been called for this generation
protected  java.util.List doneListeners_
          done listeners
protected  java.text.Format format_
          format
protected  java.lang.String formatPattern_
          format pattern
protected  java.lang.String id_
          this iterator's id
protected  boolean infoEnabled_
          true if info is enabled
protected  boolean initialized_
          true if initialized
protected  org.apache.log4j.Logger logger_
          logger
protected  java.lang.String name_
          value name
protected  java.util.List nextListeners_
          next listeners
protected  java.lang.String path_
          this iterator's path
protected  boolean repeat_
          if true, reset when done
protected  boolean repeatSet_
          true if repeat flag was set
 
Constructor Summary
DatamixerIterator()
           
 
Method Summary
 void addDatamixerListener(DatamixerListener listener, int event, int action)
          Add listener.
protected  boolean doDone()
          Returns false, always.
protected  void doFireDatamixerEvent(DatamixerEvent event)
          Allows subclasses to initialize event.
protected  void doGenerate()
          Generate the next element in the collection.
protected abstract  Value doGetCurrentValue()
          Returns the current value.
protected  void doInitialize()
          Initialization.
protected  void doReset()
          Resets the generator to an initial state.
 void fireDatamixerEvent(int event)
          Calls handleDatamixerEvent on listeners.
 void generate()
          Generates the next value and sets it as the current value.
 DatamixerCollection getCollection()
          Returns this iterator's collection.
 DatamixerIterator getContainer()
          Returns this iterator's container.
 java.lang.Object getCurrent()
          Returns the object most recently returned by next().
 Value getCurrentValue()
          Returns the value most recently returned by nextValue().
 int getDataType()
          Returns the datatype.
 java.text.Format getFormat(java.lang.String pattern)
          Returns an appropriate Format object.
 java.lang.String getFormatPattern()
          Returns the format pattern.
 boolean getHasNext()
          Provides JavaBean access.
 java.lang.String getId()
          Returns this iterator's id.
protected  java.util.List getListeners(int event)
          Calls handleGenerateEvent on listeners.
 java.lang.String getName()
          Returns the value name.
 java.lang.Object getNext()
          Provides JavaBean access.
 Value getNextValue()
          Generates the next value, sets it as the current value, and fires a next event.
 java.lang.String getPath()
          Returns this iterator's path.
 boolean getRepeat()
          Returns the repeat flag.
 boolean hasNext()
          Returns true if the iteration has more elements.
 void initialize()
          Initialize this instance.
 java.lang.Object next()
          Returns the next value.
 void remove()
           
 void removeDatamixerListener(DatamixerListener listener, int event, int action)
          Remove listener.
 void reset()
          Resets the generator to an initial state.
 void setCollection(DatamixerCollection collection)
          Sets this iterator's collection.
 void setContainer(DatamixerIterator container)
          Sets this iterator's container.
 void setCurrentValue(Value value)
          Returns the value most recently returned by nextValue().
 void setDataType(int value)
          Sets the data type.
 void setFormatPattern(java.lang.String value)
          Sets the format pattern.
 void setId(java.lang.String id)
          Sets this iterator's id.
 void setName(java.lang.String name)
          Set the value name.
 void setRepeat(boolean value)
          Sets the repeat flag.
 java.lang.String toString()
           
protected  void updateCurrentValue()
          Sets the current value from the derived class, and sets its name and format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id_

protected java.lang.String id_
this iterator's id


path_

protected java.lang.String path_
this iterator's path


collection_

protected DatamixerCollection collection_
the associated collection


repeat_

protected boolean repeat_
if true, reset when done


repeatSet_

protected boolean repeatSet_
true if repeat flag was set


format_

protected java.text.Format format_
format


formatPattern_

protected java.lang.String formatPattern_
format pattern


name_

protected java.lang.String name_
value name


done_

protected boolean done_
true if done


doneChecked_

protected boolean doneChecked_
true if done() has been called for this generation


initialized_

protected boolean initialized_
true if initialized


nextListeners_

protected java.util.List nextListeners_
next listeners


doneListeners_

protected java.util.List doneListeners_
done listeners


debugEnabled_

protected boolean debugEnabled_
true if debugging is enabled


infoEnabled_

protected boolean infoEnabled_
true if info is enabled


logger_

protected org.apache.log4j.Logger logger_
logger

Constructor Detail

DatamixerIterator

public DatamixerIterator()
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. In other words, returns true if next would return an element rather than throwing an exception. Otherwise fires a done event, and returns false.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if the iterator has more elements.

doDone

protected boolean doDone()
                  throws DatamixerException
Returns false, always.

Throws:
DatamixerException

next

public java.lang.Object next()
Returns the next value.

Specified by:
next in interface java.util.Iterator
Returns:
the next element in the iteration.

remove

public void remove()
Specified by:
remove in interface java.util.Iterator

addDatamixerListener

public void addDatamixerListener(DatamixerListener listener,
                                 int event,
                                 int action)
Add listener.

Specified by:
addDatamixerListener in interface DatamixerEventGenerator

removeDatamixerListener

public void removeDatamixerListener(DatamixerListener listener,
                                    int event,
                                    int action)
Remove listener. action is ignored.

Specified by:
removeDatamixerListener in interface DatamixerEventGenerator

getListeners

protected java.util.List getListeners(int event)
Calls handleGenerateEvent on listeners.


fireDatamixerEvent

public void fireDatamixerEvent(int event)
                        throws DatamixerException
Calls handleDatamixerEvent on listeners.

Specified by:
fireDatamixerEvent in interface DatamixerEventGenerator
Throws:
DatamixerException

doFireDatamixerEvent

protected void doFireDatamixerEvent(DatamixerEvent event)
                             throws DatamixerException
Allows subclasses to initialize event.

Throws:
DatamixerException

toString

public java.lang.String toString()

getId

public java.lang.String getId()
Returns this iterator's id.


setId

public void setId(java.lang.String id)
Sets this iterator's id.


getPath

public java.lang.String getPath()
Returns this iterator's path.


getContainer

public DatamixerIterator getContainer()
Returns this iterator's container.


setContainer

public void setContainer(DatamixerIterator container)
Sets this iterator's container.


getCollection

public DatamixerCollection getCollection()
Returns this iterator's collection.

Returns:
this iterator's collection.

setCollection

public void setCollection(DatamixerCollection collection)
Sets this iterator's collection.

Parameters:
collection - this iterator's collection.

getDataType

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


setDataType

public void setDataType(int value)
Sets the data type. Datatypes are defined in java.sql.Types.


getRepeat

public boolean getRepeat()
Returns the repeat flag.


setRepeat

public void setRepeat(boolean value)
Sets the repeat flag.


getFormatPattern

public java.lang.String getFormatPattern()
Returns the format pattern.


setFormatPattern

public void setFormatPattern(java.lang.String value)
Sets the format pattern.


getFormat

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


getName

public java.lang.String getName()
Returns the value name.


setName

public void setName(java.lang.String name)
Set the value name.


getHasNext

public boolean getHasNext()
                   throws DatamixerException
Provides JavaBean access.

Throws:
DatamixerException

getNext

public java.lang.Object getNext()
                         throws DatamixerException
Provides JavaBean access.

Throws:
DatamixerException

getNextValue

public Value getNextValue()
                   throws DatamixerException
Generates the next value, sets it as the current value, and fires a next event.

Returns:
the (new) current value.
Throws:
DatamixerException

getCurrent

public java.lang.Object getCurrent()
Returns the object most recently returned by next().

Returns:
the current object.

getCurrentValue

public Value getCurrentValue()
Returns the value most recently returned by nextValue().

Returns:
the current value.

setCurrentValue

public void setCurrentValue(Value value)
Returns the value most recently returned by nextValue().

Returns:
the current value.

doGetCurrentValue

protected abstract Value doGetCurrentValue()
Returns the current value.


initialize

public void initialize()
                throws DatamixerException
Initialize this instance.

Throws:
DatamixerException

doInitialize

protected void doInitialize()
                     throws DatamixerException
Initialization.

Throws:
DatamixerException

reset

public void reset()
           throws DatamixerException
Resets the generator to an initial state.

Throws:
DatamixerException

doReset

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

Throws:
DatamixerException

updateCurrentValue

protected void updateCurrentValue()
Sets the current value from the derived class, and sets its name and format.


generate

public void generate()
              throws DatamixerException
Generates the next value and sets it as the current value.

Throws:
DatamixerException

doGenerate

protected void doGenerate()
                   throws DatamixerException
Generate the next element in the collection.

Throws:
DatamixerException


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