org.apache.tools.ant.types.resources
class: FailFast [javadoc |
source]
java.lang.Object
org.apache.tools.ant.types.resources.FailFast
All Implemented Interfaces:
Iterator
Helper class for ResourceCollections to return Iterators
that fail on changes to the object.
| Constructor: |
FailFast(Object o,
Iterator i) {
if (o == null) {
throw new IllegalArgumentException("parent object is null");
}
if (i == null) {
throw new IllegalArgumentException("cannot wrap null iterator");
}
parent = o;
if (i.hasNext()) {
wrapped = i;
add(this);
}
}
Construct a new FailFast Iterator wrapping the specified Iterator
and dependent upon the specified parent Object. Parameters:
o - the parent Object.
i - the wrapped Iterator.
|
| Method from org.apache.tools.ant.types.resources.FailFast Detail: |
public boolean hasNext() {
if (wrapped == null) {
return false;
}
failFast(this);
return wrapped.hasNext();
}
Fulfill the Iterator contract. |
static synchronized void invalidate(Object o) {
Set s = (Set) (MAP.get(o));
if (s != null) {
s.clear();
}
}
Invalidate any in-use Iterators from the specified Object. |
public Object next() {
if (wrapped == null || !wrapped.hasNext()) {
throw new NoSuchElementException();
}
failFast(this);
try {
return wrapped.next();
} finally {
if (!wrapped.hasNext()) {
wrapped = null;
remove(this);
}
}
}
Fulfill the Iterator contract. |
public void remove() {
throw new UnsupportedOperationException();
}
Fulfill the Iterator contract. |