net.sf.zig_project.gpl.common.enumerations
Class Enumerator

java.lang.Object
  extended bynet.sf.zig_project.gpl.common.enumerations.Enumerator

public abstract class Enumerator
extends Object

The Enumerator class provides a library of methods in order to operate on Enumerations, such as comparing them, and converting them into a displayable form.

Version:
September 15, 2004
Author:
Frank Ziglar

Field Summary
static String ON_LINE_SEP
          Default seperator between two objects to be displayed on a single line of text.
 
Constructor Summary
Enumerator()
           
 
Method Summary
static boolean equals(Enumeration a, Enumeration b)
          Compares two Enumerations if they contain the same sequence of elements.
static String list(Enumeration e, String sep)
          Lists the contents of the Enumeration by their String representation.
static void list(Enumeration e, StringBuffer sb, String sep)
          Lists the contents of the Enumeration by their String representation.
static String listOnLine(Enumeration e)
          Lists the contents of the Enumeration as a String that can be displayed as a single line.
static void listOnLine(Enumeration e, StringBuffer sb)
          Lists the contents of the Enumeration by their String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ON_LINE_SEP

public static final String ON_LINE_SEP
Default seperator between two objects to be displayed on a single line of text. Displayed as: ", "

See Also:
Constant Field Values
Constructor Detail

Enumerator

public Enumerator()
Method Detail

equals

public static boolean equals(Enumeration a,
                             Enumeration b)
Compares two Enumerations if they contain the same sequence of elements. There are no guarantees on the state of each Enumeration (whether or not one will contain more elements) after this method returns false. In order to be true, each Enumeration must have the same number of elements, and each element, must be equal in sequence with the next element from the compared Enumeration.

Returns:
true only if the sequence of elements in each Enumeration are equal.

listOnLine

public static String listOnLine(Enumeration e)
Lists the contents of the Enumeration as a String that can be displayed as a single line. Each element in the Enumeration is written to the String using it's toString() representation, and elements are seperated by the default seperator.

Returns:
the String representation of the contents of the Enumeration

listOnLine

public static void listOnLine(Enumeration e,
                              StringBuffer sb)
Lists the contents of the Enumeration by their String representation. Each element is put into the provided StringBuffer, using the default seperator, so that the result is suitable to display on a single line. The call to this method is equivilent to sb.append(Enumerator.listOnLine(e)); but is potentially more efficient.


list

public static String list(Enumeration e,
                          String sep)
Lists the contents of the Enumeration by their String representation. Each element is seperated by the provided seperator, such as ", " for on line seperators, or "\n" to list each element on a different line.

Parameters:
e - the Enumeration from which to list elements
sep - the seperator to use between each element
Returns:
the String representation of the elements listed, seperated by the provided seperator

list

public static void list(Enumeration e,
                        StringBuffer sb,
                        String sep)
Lists the contents of the Enumeration by their String representation. Each element is put into the provided StringBuffer, using the provided seperator. The call to this method is equivilent to sb.append(Enumerator.list(e, sep)); but is potentially more efficient.

Parameters:
e - the Enumeration from which to list elements
sep - the seperator to use between each element
sb - the buffer in which to store the resulting list