org.jbeans.converters
Class BooleanTypeConverter
java.lang.Object
|
+--org.jbeans.BaseTypeConverter
|
+--org.jbeans.converters.BooleanTypeConverter
- All Implemented Interfaces:
- TypeConverter
- public class BooleanTypeConverter
- extends BaseTypeConverter
This class is the type covnerter for booleans. It only contains one method
that converts a string to a boolean. All other conversion is handled by
the BaseTypeConverter class. Therefore, this class will handle all the
conversions described in the TypeConverter interface except conversion
from an array to an object when the array has a length greater than one.
This is the same deficiency that BaseTypeConverter posses.
- Author:
- Brian Pontarelli
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BooleanTypeConverter
public BooleanTypeConverter()
convertString
public Object convertString(String value,
Class convertTo)
throws TypeConversionException
- Converts the given string to a boolean. If the convertTo type is Boolean.TYPE
or the primitive, then this method will convert the string to a Boolean object
and NEVER return null. This way there are no exceptions when attempting to set
a primitive type to null. If the convertTo type is an array, then this method
calls convertToArray. If the convertTo type is not Boolean.TYPE it is ignored.
If the convertTo type is not Boolean.TYPE and the passed in string is either
null, empty or contains only white space, this method returns null.
- Overrides:
convertString
in class BaseTypeConverter
- Parameters:
value
- The string value to convertconvertTo
- The type to convert the string to should be either Boolean.class
or Boolean.TYPE, or an array of either one of those.- Returns:
- A Boolean object containing the boolean value of the string (which
must conform to the java.lang.Boolean#valueOf() method) or a false
Boolean obect if the convertTo type is Boolean.TYPE and the string
is null, empty or only whitespace.
- Throws:
TypeConversionException
- If the value is an invalid boolean
expression or if the convertTo type is an array and there
was a problem converting the string to an array