01: /*
02: * Modified from Struts IteratorAdapter class by Nabh Information Systems, Inc.
03: * Modifications (c) 2006 Nabh Information Systems, Inc.
04: *
05: * Copyright 2002-2005 The Apache Software Foundation.
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License"); you may
08: * not use this file except in compliance with the License. You may obtain a
09: * copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16: * License for the specific language governing permissions and limitations
17: * under the License.
18: */
19: package com.nabhinc.util;
20:
21: import java.util.Enumeration;
22: import java.util.Iterator;
23: import java.util.NoSuchElementException;
24:
25: /**
26: * Utility method for converting Enumeration to an Iterator class. If you
27: * attempt to remove() an Object from the iterator, it will throw an
28: * UnsupportedOperationException. Added for use by TagLib so Enumeration can
29: * be supported
30: *
31: * @version $Rev: 164530 $ $Date: 2005-04-25 04:11:07 +0100 (Mon, 25 Apr
32: * 2005) $
33: */
34: public class EnumerationIterator implements Iterator {
35: private Enumeration e;
36:
37: public EnumerationIterator(Enumeration e) {
38: this .e = e;
39: }
40:
41: public boolean hasNext() {
42: return e.hasMoreElements();
43: }
44:
45: public Object next() {
46: if (!e.hasMoreElements()) {
47: throw new NoSuchElementException(
48: "IteratorAdaptor.next() has no more elements");
49: }
50: return e.nextElement();
51: }
52:
53: public void remove() {
54: throw new UnsupportedOperationException(
55: "Method IteratorAdaptor.remove() not implemented");
56: }
57: }
|