ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.collections
Class ObjectTypeIterator<E>

java.lang.Object
  extended by umontreal.iro.lecuyer.collections.FilteredIterator<E>
      extended by umontreal.iro.lecuyer.collections.ObjectTypeIterator<E>
Type Parameters:
E - the type of the objects.
All Implemented Interfaces:
Iterator<E>

public class ObjectTypeIterator<E>
extends FilteredIterator<E>

Represents an iterator traversing objects of a particular class enumerated by another iterator.


Constructor Summary
ObjectTypeIterator(Iterator<? super E> it, Class<E> objectClass)
          Constructs a new iterator traversing objects of class objectClass enumerated by the inner iterator it.
ObjectTypeIterator(Iterator<? super E> it, Class<E> objectClass, int maxNumElements)
          Constructs a new iterator traversing at most maxNumElements objects of class objectClass enumerated by the inner iterator it.
 
Method Summary
 boolean filter(Object o)
          Determines if the object o is returned by this iterator.
 Class<E> getObjectClass()
          Returns the class of the objects returned by this iterator.
 
Methods inherited from class umontreal.iro.lecuyer.collections.FilteredIterator
getInnerIterator, getMaxNumElements, hasNext, next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectTypeIterator

public ObjectTypeIterator(Iterator<? super E> it,
                          Class<E> objectClass)
Constructs a new iterator traversing objects of class objectClass enumerated by the inner iterator it.

Parameters:
it - the inner iterator.
objectClass - the object class.
Throws:
NullPointerException - if it or objectClass are null.

ObjectTypeIterator

public ObjectTypeIterator(Iterator<? super E> it,
                          Class<E> objectClass,
                          int maxNumElements)
Constructs a new iterator traversing at most maxNumElements objects of class objectClass enumerated by the inner iterator it.

Parameters:
it - the inner iterator.
objectClass - the object class.
maxNumElements - the maximal number of traversed objects.
Throws:
NullPointerException - if it or objectClass are null.
IllegalArgumentException - if maxNumElements is negative.
Method Detail

getObjectClass

public Class<E> getObjectClass()
Returns the class of the objects returned by this iterator.

Returns:
the class of the iterated objects.

filter

public boolean filter(Object o)
Description copied from class: FilteredIterator
Determines if the object o is returned by this iterator. Returns true if the object is accepted, false otherwise. This iterator assumes that this method returns true for a particular object o only if o can be cast into an instance of E.

Specified by:
filter in class FilteredIterator<E>
Parameters:
o - the tested object.
Returns:
the result of the test.

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.