de.rwth.utils
Class ArrayIterator

java.lang.Object
  |
  +--de.rwth.utils.ArrayIterator
All Implemented Interfaces:
java.util.Iterator

public class ArrayIterator
extends java.lang.Object
implements java.util.Iterator

Creates an iterator from an array of iterator-capable Object. Each element is an array of objects, consisting of elements from the component iterators. The iterator goes over all possible combinations by traversing the first object first, second object second and so forth.

Version:
$Id: ArrayIterator.java,v 1.3 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen

Field Summary
protected  java.lang.Object[] elements
          The next element return by next.
protected  boolean hasNext
          true as long as there are Objects in this iterator.
protected  java.lang.reflect.Method[] iMeths
          For each entry in objs, this array contains the Method used to create an iterator.
protected  java.util.Iterator[] iterators
          For each entry in objs, this array contains the current state of the component iterator.
protected  java.lang.Object[] objs
          The array of objects.
 
Constructor Summary
ArrayIterator(java.lang.Object[] objs)
          Creates a new ArrayIterator instance.
ArrayIterator(java.lang.Object[] objs, java.lang.String name)
          Creates a new ArrayIterator instance.
 
Method Summary
 boolean hasNext()
          Checks if there are more elements pending.
protected  java.util.Iterator iterator(int i)
          Invokes the i-th iterator method without raising exceptions.
static void main(java.lang.String[] args)
          Mini test environment.
 java.lang.Object next()
          Returns the next element, an array of elements of the components.
 void remove()
          Not implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objs

protected java.lang.Object[] objs
The array of objects.

iMeths

protected java.lang.reflect.Method[] iMeths
For each entry in objs, this array contains the Method used to create an iterator.

hasNext

protected boolean hasNext
true as long as there are Objects in this iterator.

elements

protected java.lang.Object[] elements
The next element return by next.

iterators

protected java.util.Iterator[] iterators
For each entry in objs, this array contains the current state of the component iterator.
Constructor Detail

ArrayIterator

public ArrayIterator(java.lang.Object[] objs,
                     java.lang.String name)
              throws java.lang.IllegalArgumentException
Creates a new ArrayIterator instance.
Parameters:
objs - an Object[] value: The iterator-capable objects.
name - a String value: The name of the methods used to create the iterators.
Throws:
java.lang.IllegalArgumentException - if this class does not have Iterator as unique super interface or if one of the objs is not iterator-capable via name.

ArrayIterator

public ArrayIterator(java.lang.Object[] objs)
              throws java.lang.IllegalArgumentException
Creates a new ArrayIterator instance.
Parameters:
objs - an Object[] value: The iterator-capable objects, which must have a method Iterator iterator().
Throws:
java.lang.IllegalArgumentException - if this class does not have Iterator as unique super interface or if one of the objs is not iterator-capable via Iterator iterator().
Method Detail

iterator

protected java.util.Iterator iterator(int i)
Invokes the i-th iterator method without raising exceptions.
Parameters:
i - an int value
Returns:
an Iterator value

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Returns the next element, an array of elements of the components.
Specified by:
next in interface java.util.Iterator
Returns:
an Object value
Throws:
java.util.NoSuchElementException - if there is no more element.

hasNext

public boolean hasNext()
Checks if there are more elements pending.
Specified by:
hasNext in interface java.util.Iterator
Returns:
a boolean value

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Not implemented.
Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - always

main

public static void main(java.lang.String[] args)
Mini test environment.
Parameters:
args - a String[] value