KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > util > IteratorFilterSupport


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.util;
6
7 import java.util.Enumeration JavaDoc;
8 import java.util.Iterator JavaDoc;
9
10
11 /**
12  * A base class for iterator filters
13  *
14  * @author Rickard Öberg (rickard@middleware-company.com)
15  * @version $Revision: 1.4 $
16  */

17 public abstract class IteratorFilterSupport {
18     //~ Methods ////////////////////////////////////////////////////////////////
19

20     // Protected implementation --------------------------------------
21
protected Object JavaDoc getIterator(Object JavaDoc source) {
22         return MakeIterator.convert(source);
23     }
24
25     //~ Inner Classes //////////////////////////////////////////////////////////
26

27     // Wrapper for enumerations
28
public class EnumerationIterator implements Iterator JavaDoc {
29         Enumeration JavaDoc enumeration;
30
31         public EnumerationIterator(Enumeration JavaDoc aEnum) {
32             enumeration = aEnum;
33         }
34
35         public boolean hasNext() {
36             return enumeration.hasMoreElements();
37         }
38
39         public Object JavaDoc next() {
40             return enumeration.nextElement();
41         }
42
43         public void remove() {
44             throw new UnsupportedOperationException JavaDoc("Remove is not supported in IteratorFilterSupport.");
45         }
46     }
47 }
48
Popular Tags