01: /*
02: * LICENSE INFORMATION
03: * Copyright 2005-2007 by FZI (http://www.fzi.de).
04: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
05: * <OWNER> = Max Völkel
06: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
07: * <YEAR> = 2007
08: *
09: * Project information at http://semweb4j.org/rdf2go
10: */
11: package org.ontoware.aifbcommons.collection;
12:
13: import java.util.Iterator;
14:
15: /**
16: * An <b>closabel</b> iterator over a collection. Iterator takes the place of Enumeration in
17: * the Java collections framework.
18: *
19: * @author Josh Bloch, adapter by Max Voelkel
20: * @see Collection
21: * @see ListIterator
22: * @see Enumeration
23: */
24: public interface ClosableIterator<E> extends Iterator<E> {
25:
26: /**
27: * Returns <tt>true</tt> if the iteration has more elements. (In other
28: * words, returns <tt>true</tt> if <tt>next</tt> would return an element
29: * rather than throwing an exception.)
30: *
31: * @return <tt>true</tt> if the iterator has more elements.
32: */
33: boolean hasNext();
34:
35: /**
36: * Returns the next element in the iteration. Calling this method
37: * repeatedly until the {@link #hasNext()} method returns false will
38: * return each element in the underlying collection exactly once.
39: *
40: * @return the next element in the iteration.
41: * @exception NoSuchElementException iteration has no more elements.
42: */
43: E next();
44:
45: /**
46: *
47: * Removes from the underlying collection the last element returned by the
48: * iterator (optional operation). This method can be called only once per
49: * call to <tt>next</tt>. The behavior of an iterator is unspecified if
50: * the underlying collection is modified while the iteration is in
51: * progress in any way other than by calling this method.
52: *
53: * @exception UnsupportedOperationException if the <tt>remove</tt>
54: * operation is not supported by this Iterator.
55:
56: * @exception IllegalStateException if the <tt>next</tt> method has not
57: * yet been called, or the <tt>remove</tt> method has already
58: * been called after the last call to the <tt>next</tt>
59: * method.
60: */
61: void remove();
62:
63: /**
64: * The uderlying implementation frees resources.
65: * For some it is absolutely necessary to call this method.
66: */
67: void close();
68: }
|