01: package org.apache.velocity.util;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import java.util.Iterator;
23: import java.util.Enumeration;
24:
25: /**
26: * An Iterator wrapper for an Enumeration.
27: *
28: * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
29: * @version $Id: EnumerationIterator.java 463298 2006-10-12 16:10:32Z henning $
30: */
31: public class EnumerationIterator implements Iterator {
32: /**
33: * The enumeration to iterate.
34: */
35: private Enumeration enumeration = null;
36:
37: /**
38: * Creates a new iteratorwrapper instance for the specified
39: * Enumeration.
40: *
41: * @param enumeration The Enumeration to wrap.
42: */
43: public EnumerationIterator(Enumeration enumeration) {
44: this .enumeration = enumeration;
45: }
46:
47: /**
48: * Move to next element in the array.
49: *
50: * @return The next object in the array.
51: */
52: public Object next() {
53: return enumeration.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: return enumeration.hasMoreElements();
63: }
64:
65: /**
66: * Unimplemented. No analogy in Enumeration
67: */
68: public void remove() {
69: // not implemented
70: }
71:
72: }
|