01 /**
02 *
03 * Copyright (c) 1995-2010, The University of Sheffield. See the file
04 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
05 *
06 * This file is part of GATE (see http://gate.ac.uk/), and is free
07 * software, licenced under the GNU Library General Public License,
08 * Version 2, June 1991 (in the distribution as file licence.html,
09 * and also available at http://gate.ac.uk/gate/licence.html).
10 *
11 * $Id: ClosableIterator.java 12006 2009-12-01 17:24:28Z thomas_heitz $
12 */
13
14 package gate.util;
15
16 import java.util.Iterator;
17
18 /**
19 * An iterator that should be closed as soon as it is not used anymore.
20 * The close() method is used to close the iterator at any time. It is
21 * not an error to close() an iterator that already has been closed.
22 *
23 * This iterator also auto-closes when hasNext() is called and no more
24 * elements are available.
25 *
26 * @param <T>
27 */
28 public interface ClosableIterator<T> extends Iterator<T> {
29
30 /**
31 * Close the iteratori and free all resources. This method can be called
32 * more than once, all calls after the first one have no effect.
33 * After close() has been called, hasNext() is guaranteed to return false.
34 * After close() it is an error the call next(). close will throw
35 * a GateRuntimeException in that case.
36 * This method is called automatically when hasNext() is called and no
37 * more elements are available.
38 */
39 public void close();
40
41 }
|