01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.util;
06:
07: import java.util.Enumeration;
08: import java.util.Iterator;
09:
10: /**
11: * A base class for iterator filters
12: *
13: * @author Rickard Öberg (rickard@middleware-company.com)
14: * @version $Revision: 1282 $
15: */
16: public abstract class IteratorFilterSupport {
17:
18: // Protected implementation --------------------------------------
19: protected Object getIterator(Object source) {
20: return MakeIterator.convert(source);
21: }
22:
23: // Wrapper for enumerations
24: public class EnumerationIterator implements Iterator {
25: Enumeration enumeration;
26:
27: public EnumerationIterator(Enumeration aEnum) {
28: enumeration = aEnum;
29: }
30:
31: public boolean hasNext() {
32: return enumeration.hasMoreElements();
33: }
34:
35: public Object next() {
36: return enumeration.nextElement();
37: }
38:
39: public void remove() {
40: throw new UnsupportedOperationException(
41: "Remove is not supported in IteratorFilterSupport.");
42: }
43: }
44: }
|