org.melati.poem.util
Class EnumUtils

Package class diagram package EnumUtils
java.lang.Object
  extended by org.melati.poem.util.EnumUtils

public final class EnumUtils
extends Object

An assortment of useful operations on Enumerations.


Method Summary
static String concatenated(String sep, Enumeration<?> e)
          Concatenate an Enumeration, specifying the separator.
static boolean contains(Enumeration<?> e, Object o)
          Whether the Enumeration contain an Object.
static
<T> Vector<T>
initial(Enumeration<T> e, int n)
          Create a Vector of the first n Elements of an Enumeration.
static
<T> Enumeration<T>
join(Enumeration<T> a, Enumeration<T> b)
          Join two Enumerations into a single one.
static
<T> int
skip(Enumeration<T> e, int n)
          Skip a specified number of Elements in an Enumeration.
static
<T> Vector<T>
vectorOf(Enumeration<T> e)
          Create a Vector from an Enumeration, supplying an initial size of 20.
static
<T> Vector<T>
vectorOf(Enumeration<T> e, int roughSize)
          Create a Vector from an Enumeration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

skip

public static <T> int skip(Enumeration<T> e,
                           int n)
Skip a specified number of Elements in an Enumeration.

Parameters:
e - the Enumeration to skip Elements of
n - the number of Elements to skip
Returns:
the number of Elements actually skipped, may be less than asked

initial

public static <T> Vector<T> initial(Enumeration<T> e,
                                    int n)
Create a Vector of the first n Elements of an Enumeration. If the number of elements in the Enumeration is less than n then the remaining elements of the Vector will be null.

Parameters:
e - the input Enumeration
n - the number of Elements to include
Returns:
a new Vector of the initial Elements

join

public static <T> Enumeration<T> join(Enumeration<T> a,
                                      Enumeration<T> b)
Join two Enumerations into a single one.

Parameters:
a - head Enumeration
b - tail Enumeration
Returns:
a new enumeration which is a concatenation of A and B

vectorOf

public static <T> Vector<T> vectorOf(Enumeration<T> e,
                                     int roughSize)
Create a Vector from an Enumeration.

Parameters:
e - the source Enumeration
roughSize - starting size of the Vector
Returns:
a Vector of the Elements of the input Enumeration

vectorOf

public static <T> Vector<T> vectorOf(Enumeration<T> e)
Create a Vector from an Enumeration, supplying an initial size of 20.

Parameters:
e - the source Enumeration
Returns:
a Vector with size at least 20 of the Elements of the input Enumeration

concatenated

public static String concatenated(String sep,
                                  Enumeration<?> e)
Concatenate an Enumeration, specifying the separator.

Parameters:
sep - Separator string
e - Enumeration to be concatenated
Returns:
A String representation of the Enumeration

contains

public static boolean contains(Enumeration<?> e,
                               Object o)
Whether the Enumeration contain an Object.

Parameters:
e - an Enumeration to look in
o - the Object to look for
Returns:
true if the Object occurs in the Enumeration


Copyright © 2000-2010 PanEris. All Rights Reserved.