KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > velocity > util > EnumerationIterator


1 package org.apache.velocity.util;
2
3 /*
4  * Copyright 1999-2001,2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.util.Iterator;
20 import java.util.Enumeration;
21
22 /**
23  * An Iterator wrapper for an Enumeration.
24  *
25  * @author <a HREF="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
26  * @version $Id: EnumerationIterator.java,v 1.1.14.1 2004/03/03 23:23:07 geirm Exp $
27  */

28 public class EnumerationIterator implements Iterator
29 {
30     /**
31      * The enumeration to iterate.
32      */

33     private Enumeration enum = null;
34
35     /**
36      * Creates a new iteratorwrapper instance for the specified
37      * Enumeration.
38      *
39      * @param enum The Enumeration to wrap.
40      */

41     public EnumerationIterator( Enumeration enum)
42     {
43         this.enum = enum;
44     }
45
46     /**
47      * Move to next element in the array.
48      *
49      * @return The next object in the array.
50      */

51     public Object next()
52     {
53         return enum.nextElement();
54     }
55     
56     /**
57      * Check to see if there is another element in the array.
58      *
59      * @return Whether there is another element.
60      */

61     public boolean hasNext()
62     {
63         return enum.hasMoreElements();
64     }
65
66     /**
67      * Unimplemented. No analogy in Enumeration
68      */

69     public void remove()
70     {
71         // not implemented
72
}
73    
74 }
75
Popular Tags