01:/*
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13:package com.sun.portal.common.collection;
14:
15:import java.util.Enumeration;
16:import java.util.Iterator;
17:
18:/**
19: * This utility class consists of static methods that operate on
20: * or return collection objects.
21: */
22:
23:public class CollectionUtils {
24:
25: /**
26: * Returns an iterator over the specified Enumeration.
27: */
28: static public Iterator enumerationToIterator(final Enumeration enum) {
29:
30: return new Iterator() {
31:
32: public boolean hasNext() {
33: return enum.hasMoreElements();
34: }
35:
36: public Object next() {
37: return enum.nextElement();
38: }
39:
40: // Throws an UnsupportedOperationException when removed()
41: // method is invoked since it is not supported by this
42: // Iterator. Based on the Java specification, the remove
43: // operation is OPTIONAL.
44: public void remove() {
45: throw new UnsupportedOperationException();
46: }
47: };
48: }
49:}
|