org.jcoderz.commons
Class Color

java.lang.Object
  extended by org.jcoderz.commons.Color
All Implemented Interfaces:
Serializable, EnumType, StrongType

public final class Color
extends Object
implements Serializable, EnumType

Enumerated type of a color. Instances of this class are immutable. The following colors are defined:

The values of this enum have a internal sequential integer representation starting with '0'.

Author:
generated
See Also:
Serialized Form

Field Summary
static Color BLUE
          The Color blue.
static Color RED
          The Color red.
static String TYPE_NAME
          The name of this type.
static Map VALUE_MAP
          Immutable map using the name string as key holding the Colors as values.
static List VALUES
          Immutable list of the Colors.
static Color YELLOW
          The Color yellow.
 
Method Summary
static Color fromInt(int i)
          Creates a Color object from its int representation.
static Color fromString(String str)
          Creates a Color object from its String representation.
 int toInt()
          Returns the int representation of this color.
 String toString()
          Returns the String representation of this color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_NAME

public static final String TYPE_NAME
The name of this type.

See Also:
Constant Field Values

BLUE

public static final Color BLUE
The Color blue.


RED

public static final Color RED
The Color red.


YELLOW

public static final Color YELLOW
The Color yellow.


VALUES

public static final List VALUES
Immutable list of the Colors.


VALUE_MAP

public static final Map VALUE_MAP
Immutable map using the name string as key holding the Colors as values.

Method Detail

fromInt

public static Color fromInt(int i)
                     throws ArgumentMalformedException
Creates a Color object from its int representation.

Parameters:
i - the integer representation of the color.
Returns:
the Color object represented by this int.
Throws:
ArgumentMalformedException - If the assigned int value isn't listed in the internal color table.

fromString

public static Color fromString(String str)
                        throws ArgumentMalformedException
Creates a Color object from its String representation.

Parameters:
str - the string representation of the color.
Returns:
the Color object represented by this str.
Throws:
ArgumentMalformedException - If the given str value isn't listed in the internal color table.

toInt

public int toInt()
Returns the int representation of this color.

Specified by:
toInt in interface EnumType
Returns:
the int representation of this color.

toString

public String toString()
Returns the String representation of this color.

Overrides:
toString in class Object
Returns:
the String representation of this color.


Copyright 2007 The jCoderZ Project.