KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > util > IteratorEnumeration


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.util;
8
9 import java.util.Enumeration JavaDoc;
10 import java.util.Iterator JavaDoc;
11
12
13 /**
14  * <p>
15  * This class is an adapter from an Iterator to an
16  * Enumeration.
17  * </p>
18  *
19  * @author Brian Pontarelli
20  */

21 public class IteratorEnumeration implements Enumeration JavaDoc {
22     
23     private Iterator JavaDoc iterator;
24     
25
26     /**
27      * Creates a new <code>IteratorEnumeration</code>.
28      *
29      * @param iterator The iterator to adapt
30      */

31     public IteratorEnumeration(Iterator JavaDoc iterator) {
32         this.iterator = iterator;
33     }
34
35     /**
36      * Returns true if the adapted Iterator has more elements, false otherwise.
37      */

38     public boolean hasMoreElements() {
39         return iterator.hasNext();
40     }
41
42     /**
43      * Returns the next item in the adapted Iterator.
44      */

45     public Object JavaDoc nextElement() {
46         return iterator.next();
47     }
48 }
Popular Tags