com.taco.swinger.text2gui
Class StringToColorConverter

java.lang.Object
  extended by com.taco.text.AbstractStringToObjectConverter
      extended by com.taco.swinger.text2gui.StringToColorConverter
All Implemented Interfaces:
IStringToObjectConverter, IObjectMapper

public class StringToColorConverter
extends AbstractStringToObjectConverter

A converter from strings to colors, using Color.decode().


Field Summary
static StringToColorConverter instance
          The singleton instance of this class.
 
Constructor Summary
protected StringToColorConverter()
          Since this class is implemented as a singleton, its sole constructor is protected.
 
Method Summary
static void main(java.lang.String[] args)
           
static java.awt.Color toColor(java.lang.String s)
          If s is empty, throw a ParseException.
 java.lang.Object toObject(java.lang.String s)
          Return the result of toColor(s).
 
Methods inherited from class com.taco.text.AbstractStringToObjectConverter
map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final StringToColorConverter instance
The singleton instance of this class.

Constructor Detail

StringToColorConverter

protected StringToColorConverter()
Since this class is implemented as a singleton, its sole constructor is protected.

Method Detail

toObject

public java.lang.Object toObject(java.lang.String s)
                          throws java.text.ParseException
Return the result of toColor(s).

Throws:
java.text.ParseException

toColor

public static final java.awt.Color toColor(java.lang.String s)
                                    throws java.text.ParseException
If s is empty, throw a ParseException. Otherwise, check if s starts with a letter. If so, use reflection to return static field of Color that s refers to. Otherwise, assume s is a number string, and return the result of Color.decode(s).

Throws:
java.lang.NullPointerException - if s is null.
java.text.ParseException

main

public static void main(java.lang.String[] args)