01: /*
02: * Copyright 1999-2001,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.commons.jexl.util;
18:
19: import java.util.Iterator;
20: import java.util.Enumeration;
21:
22: /**
23: * An Iterator wrapper for an Enumeration.
24: *
25: * @since 1.0
26: * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
27: * @version $Id: EnumerationIterator.java 398330 2006-04-30 12:52:35Z dion $
28: */
29: public class EnumerationIterator implements Iterator {
30: /**
31: * The enumeration to iterate over.
32: */
33: private final Enumeration enumeration;
34:
35: /**
36: * Creates a new iteratorwrapper instance for the specified
37: * Enumeration.
38: *
39: * @param enumer The Enumeration to wrap.
40: */
41: public EnumerationIterator(Enumeration enumer) {
42: enumeration = enumer;
43: }
44:
45: /**
46: * Move to next element in the array.
47: *
48: * @return The next object in the array.
49: */
50: public Object next() {
51: return enumeration.nextElement();
52: }
53:
54: /**
55: * Check to see if there is another element in the array.
56: *
57: * @return Whether there is another element.
58: */
59: public boolean hasNext() {
60: return enumeration.hasMoreElements();
61: }
62:
63: /**
64: * Unimplemented. No analogy in Enumeration
65: */
66: public void remove() {
67: // not implemented
68: }
69:
70: }
|