org.datamixer.containers
Class CollectionContainerIterator

java.lang.Object
  extended byorg.datamixer.collections.DatamixerIterator
      extended byorg.datamixer.containers.CollectionContainerIterator
All Implemented Interfaces:
DatamixerEventGenerator, java.util.Iterator
Direct Known Subclasses:
CounterIterator, FunctionIterator

public class CollectionContainerIterator
extends DatamixerIterator

A CollectionContainerIterator manages a list of collections or iterators. At initialization time, it gets an iterator from each collection, so that at runtime it has a list of iterators. DatamixerIterator.next() returns a ValueListValue, which contains a ValueList with the next value from each iterator.

Collections or iterators can be added to a CollectionContainerIterator instantiated from its default constructor. A CollectionContainerIterator can also be instantiated with iterator(), in which case each list in the CollectionContainer contributes an iterator to the CollectionContainerIterator.


Field Summary
static int ALL_DONE
          done when all children are done
static java.lang.String ALL_DONE_STRING
          string representation for ALL_DONE
static int ANY_DONE
          done when any child is done
static java.lang.String ANY_DONE_STRING
          string representation for ANY_DONE
protected  Value current_
          current value
protected  int dataType_
          datatype
protected  boolean dataTypeSet_
          true if datatype has been set
static int DONE_UNDEFINED
          done policy not defined
static java.lang.String DONE_UNDEFINED_STRING
          string representation for UNDEFINED_DONE
protected  int donePolicy_
          policy for deciding when done (ANY_DONE or ALL_DONE).
protected  java.util.ArrayList elements_
          collections and iterators
protected  java.util.ArrayList iterators_
          iterators
protected  java.lang.Boolean repeatAll_
          set the repeat flag for all iterators to enabled.
 
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
CollectionContainerIterator()
           
 
Method Summary
 void addElement(DatamixerCollection collection)
          Add collection to the element list.
 void addElement(DatamixerIterator iterator)
          Add iterator to the element list.
protected  boolean allDone()
          returns true if all iterators are done.
protected  boolean anyDone()
          returns true if any generator is done.
static void checkCompatibility(int type1, int type2)
          Checks compatibility between two datatypes.
static int dataTypeWeight(int type)
          Returns the datatype with maximum precision for type1 and type2.
protected  void doContainerGenerate(ValueList result)
          Generate the next element in the collection.
protected  boolean doDone()
          call done on generators.
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.
protected  int findDataType()
          Returns the datatype.
 int getDataType()
          Returns the datatype.
 int getDonePolicy()
           
 java.lang.String getDonePolicyString()
           
static java.lang.String getDonePolicyString(int value)
           
 java.lang.Object getElement(int index)
           
 java.util.ArrayList getElements()
           
 java.text.Format getFormat(java.lang.String pattern)
          Returns an appropriate Format object.
 DatamixerIterator getIterator(int index)
           
 java.util.ArrayList getIterators()
           
 java.lang.Boolean getRepeatAll()
          Returns repeat flag for all iterators to enabled.
static int maxDataType(int type1, int type2)
          Returns the datatype with maximum precision for type1 and type2.
 void setDataType(int value)
          Sets the data type.
 void setDonePolicy(int value)
           
 void setDonePolicyString(java.lang.String value)
           
 void setRepeatAll(java.lang.Boolean enabled)
          Set the repeat flag for all iterators to enabled.
 
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, 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

DONE_UNDEFINED

public static final int DONE_UNDEFINED
done policy not defined

See Also:
Constant Field Values

ANY_DONE

public static final int ANY_DONE
done when any child is done

See Also:
Constant Field Values

ALL_DONE

public static final int ALL_DONE
done when all children are done

See Also:
Constant Field Values

DONE_UNDEFINED_STRING

public static final java.lang.String DONE_UNDEFINED_STRING
string representation for UNDEFINED_DONE

See Also:
Constant Field Values

ANY_DONE_STRING

public static final java.lang.String ANY_DONE_STRING
string representation for ANY_DONE

See Also:
Constant Field Values

ALL_DONE_STRING

public static final java.lang.String ALL_DONE_STRING
string representation for ALL_DONE

See Also:
Constant Field Values

dataType_

protected int dataType_
datatype


dataTypeSet_

protected boolean dataTypeSet_
true if datatype has been set


elements_

protected java.util.ArrayList elements_
collections and iterators


iterators_

protected java.util.ArrayList iterators_
iterators


current_

protected Value current_
current value


repeatAll_

protected java.lang.Boolean repeatAll_
set the repeat flag for all iterators to enabled.


donePolicy_

protected int donePolicy_
policy for deciding when done (ANY_DONE or ALL_DONE).

Constructor Detail

CollectionContainerIterator

public CollectionContainerIterator()
Method Detail

getDataType

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

Overrides:
getDataType in class DatamixerIterator

setDataType

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

Overrides:
setDataType 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
call done on generators.

Overrides:
doDone in class DatamixerIterator
Throws:
DatamixerException

anyDone

protected boolean anyDone()
                   throws DatamixerException
returns true if any generator is done.

Throws:
DatamixerException

allDone

protected boolean allDone()
                   throws DatamixerException
returns true if all iterators are done.

Throws:
DatamixerException

doGenerate

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

Overrides:
doGenerate in class DatamixerIterator
Throws:
DatamixerException

doContainerGenerate

protected void doContainerGenerate(ValueList result)
                            throws DatamixerException
Generate the next element in the collection.

Throws:
DatamixerException

doReset

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

Overrides:
doReset in class DatamixerIterator
Throws:
DatamixerException

findDataType

protected int findDataType()
                    throws DatamixerException
Returns the datatype. Datatypes are defined in java.sql.Types.

Throws:
DatamixerException - if children have incompatible types.

maxDataType

public static int maxDataType(int type1,
                              int type2)
                       throws DatamixerException
Returns the datatype with maximum precision for type1 and type2.

Throws:
DatamixerException - if types are not supported or incompatible.

checkCompatibility

public static void checkCompatibility(int type1,
                                      int type2)
                               throws DatamixerException
Checks compatibility between two datatypes.

Throws:
DatamixerException - if types are incompatible.

dataTypeWeight

public static int dataTypeWeight(int type)
                          throws DatamixerException
Returns the datatype with maximum precision for type1 and type2.

Throws:
DatamixerException - if type is not supported.

addElement

public void addElement(DatamixerCollection collection)
Add collection to the element list.


addElement

public void addElement(DatamixerIterator iterator)
Add iterator to the element list.


getElements

public java.util.ArrayList getElements()

getElement

public java.lang.Object getElement(int index)

getIterators

public java.util.ArrayList getIterators()

getIterator

public DatamixerIterator getIterator(int index)

getDonePolicy

public int getDonePolicy()

setDonePolicy

public void setDonePolicy(int value)

setDonePolicyString

public void setDonePolicyString(java.lang.String value)

getDonePolicyString

public java.lang.String getDonePolicyString()

getDonePolicyString

public static java.lang.String getDonePolicyString(int value)

getRepeatAll

public java.lang.Boolean getRepeatAll()
Returns repeat flag for all iterators to enabled.


setRepeatAll

public void setRepeatAll(java.lang.Boolean enabled)
Set the repeat flag for all iterators to enabled.



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