com.taco.text
Class StringToBooleanConverter

java.lang.Object
  extended by com.taco.text.AbstractStringToObjectConverter
      extended by com.taco.text.StringToBooleanConverter
All Implemented Interfaces:
IStringToObjectConverter, IObjectMapper, java.io.Serializable

public final class StringToBooleanConverter
extends AbstractStringToObjectConverter
implements java.io.Serializable

A converter from strings to instances of Boolean.

See Also:
Serialized Form

Field Summary
static StringToBooleanConverter instance
          The singleton instance of this class.
 
Method Summary
 java.lang.Object toObject(java.lang.String s)
          If the string is null or empty, return Boolean.FALSE.
 
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 StringToBooleanConverter instance
The singleton instance of this class.

Method Detail

toObject

public java.lang.Object toObject(java.lang.String s)
                          throws java.text.ParseException
If the string is null or empty, return Boolean.FALSE. If the string begins with 't' or 'y', ignoring case, return Boolean.TRUE. If the string begins with 'f' or 'n', return Boolean.FALSE. Otherwise, throw a ParseException. This is slightly unsafe, but very fast.

Specified by:
toObject in interface IStringToObjectConverter
Throws:
java.text.ParseException