1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.event.util;
11
12 import java.util.Iterator;
13
14 import nl.tudelft.simulation.event.EventProducer;
15 import nl.tudelft.simulation.event.EventType;
16
17 /***
18 * The Event producing iterator provides a set to which one can subscribe
19 * interest in entry changes.
20 * <p>
21 * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
22 * University of Technology </a>, the Netherlands. <br>
23 * See for project information <a
24 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
25 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
26 * License (GPL) </a>, no warranty <br>
27 *
28 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
29 * Jacobs </a>
30 * @version 1.1, 2004-03-18
31 * @since 1.2
32 */
33 public class EventIterator extends EventProducer implements java.util.Iterator
34 {
35 /*** OBJECT_REMOVED_EVENT is fired on removel of entries */
36 public static final EventType OBJECT_REMOVED_EVENT = new EventType(
37 "OBJECT_REMOVED_EVENT");
38
39 /*** our parent iterator */
40 private Iterator parent = null;
41
42 /***
43 * constructs a new Iterator.
44 *
45 * @param parent parent.
46 */
47 public EventIterator(final Iterator parent)
48 {
49 super();
50 this.parent = parent;
51 }
52
53 /***
54 * @see java.util.Iterator#hasNext()
55 */
56 public boolean hasNext()
57 {
58 return this.parent.hasNext();
59 }
60
61 /***
62 * @see java.util.Iterator#next()
63 */
64 public Object next()
65 {
66 return this.parent.next();
67 }
68
69 /***
70 * @see java.util.Iterator#remove()
71 */
72 public void remove()
73 {
74 this.parent.remove();
75 this.fireEvent(OBJECT_REMOVED_EVENT, null);
76 }
77 }