01: /*
02: * Copyright 2003-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.collections;
17:
18: import java.util.Enumeration;
19: import java.util.List;
20:
21: import org.apache.commons.collections.iterators.EnumerationIterator;
22:
23: /**
24: * Provides utility methods for {@link Enumeration} instances.
25: *
26: * @since Commons Collections 3.0
27: * @version $Id: EnumerationUtils.java 155406 2005-02-26 12:55:26Z dirkv $
28: *
29: * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
30: */
31: public class EnumerationUtils {
32:
33: /**
34: * EnumerationUtils is not normally instantiated.
35: */
36: public EnumerationUtils() {
37: // no init.
38: }
39:
40: /**
41: * Creates a list based on an enumeration.
42: *
43: * <p>As the enumeration is traversed, an ArrayList of its values is
44: * created. The new list is returned.</p>
45: *
46: * @param enumeration the enumeration to traverse, which should not be <code>null</code>.
47: * @throws NullPointerException if the enumeration parameter is <code>null</code>.
48: */
49: public static List toList(Enumeration enumeration) {
50: return IteratorUtils
51: .toList(new EnumerationIterator(enumeration));
52: }
53:
54: }
|