KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > EnumerationUtils


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19 import java.util.List JavaDoc;
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,v 1.5 2004/02/18 01:15:42 scolebourne Exp $
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 JavaDoc toList(Enumeration JavaDoc enumeration) {
50         return IteratorUtils.toList(new EnumerationIterator(enumeration));
51     }
52
53 }
54
Popular Tags