Source code: com/eireneh/util/IteratorEnumeration.java
1
2 package com.eireneh.util;
3
4 import java.util.*;
5 import com.sun.java.util.collections.*;
6 import java.util.NoSuchElementException;
7
8 /**
9 * Convert a JDK 1.2 Iterator into a JDK 1.1 Enumeration.
10 * The only real difference between the 2 is the naming and
11 * that Enumeration does not have the delete method.
12 *
13 * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
14 * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
15 * Distribution Licence:<br />
16 * Project B is free software; you can redistribute it
17 * and/or modify it under the terms of the GNU General Public License,
18 * version 2 as published by the Free Software Foundation.<br />
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.<br />
23 * The License is available on the internet
24 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
25 * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26 * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
27 * The copyright to this program is held by it's authors.
28 * </font></td></tr></table>
29 * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
30 * @see docs.Licence
31 * @author Joe Walker
32 * @version D9.I9.T5
33 */
34 public final class IteratorEnumeration implements Enumeration
35 {
36 /**
37 * Create an Enumeration that proxies to an Iterator
38 */
39 public IteratorEnumeration(Iterator it)
40 {
41 this.it = it;
42 }
43
44 /**
45 * Returns true if the iteration has more elements
46 */
47 public final boolean hasMoreElements()
48 {
49 return it.hasNext();
50 }
51
52 /**
53 * Returns the next element in the interation
54 */
55 public final Object nextElement() throws NoSuchElementException
56 {
57 return it.next();
58 }
59
60 /** The Iterator that we are proxying to */
61 private Iterator it;
62 }