polyglot.util
Class TypedListIterator
java.lang.Object
polyglot.util.TypedListIterator
- All Implemented Interfaces:
- java.util.Iterator, java.util.ListIterator
public class TypedListIterator
- extends java.lang.Object
- implements java.util.ListIterator
A TypedListIterator is an ListIterator which will not allow members
not belonging to a given type to be added to a collection.
Optionally, it may also present an immutable view.
If an attempt is made to change an immutable listiterator, or if
an attempt is made to insert an improperly-typed element, an
UnsupportedOperationException is thrown.
This class is given so that we can present a ListIterator for a
given given class without worrying about outsiders breaking the
rep.
This is a poor substitute for PolyJ.
Constructor Summary |
TypedListIterator(java.util.ListIterator iter,
java.lang.Class c,
boolean immutable)
Requires: not null
Creates a new TypedIterator around which restricts all
members to belong to class . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TypedListIterator
public TypedListIterator(java.util.ListIterator iter,
java.lang.Class c,
boolean immutable)
- Requires: not null
Creates a new TypedIterator around which restricts all
members to belong to class . If is null, no typing
restriction is made. If is true, no modifications
are allowed.
getAllowedType
public java.lang.Class getAllowedType()
- Gets the allowed type for this ListIterator.
add
public void add(java.lang.Object o)
- Specified by:
add
in interface java.util.ListIterator
set
public void set(java.lang.Object o)
- Specified by:
set
in interface java.util.ListIterator
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator
- Specified by:
hasNext
in interface java.util.ListIterator
hasPrevious
public boolean hasPrevious()
- Specified by:
hasPrevious
in interface java.util.ListIterator
next
public java.lang.Object next()
- Specified by:
next
in interface java.util.Iterator
- Specified by:
next
in interface java.util.ListIterator
nextIndex
public int nextIndex()
- Specified by:
nextIndex
in interface java.util.ListIterator
previous
public java.lang.Object previous()
- Specified by:
previous
in interface java.util.ListIterator
previousIndex
public int previousIndex()
- Specified by:
previousIndex
in interface java.util.ListIterator
remove
public void remove()
- Specified by:
remove
in interface java.util.Iterator
- Specified by:
remove
in interface java.util.ListIterator