com.abstractics.utils.converter
Class ConverterBoolean
java.lang.Object
com.abstractics.utils.converter.ConverterBoolean
- All Implemented Interfaces:
- ObjectConverter
- public class ConverterBoolean
- extends java.lang.Object
- implements ObjectConverter
Converts to a java.lang.Boolean
object. Conversion is done by
taking the given object, calling its toString()
method and
then using that String to do the conversion.
These values will return true: "true", "y", "yes", "t", "1", "on"
These values will return false: "false", "n", "no", "f", "0", "off"
Any other values will cause an ObjectConverterException to be thrown.
- Version:
- $Id: ConverterBoolean.java,v 1.2 2006/03/15 05:37:30 andyman99 Exp $
- Author:
- Andrew Lawrence, Copyright 2006 Abstractics, L.L.C., Licensed under the Apache
License, Version 2.0
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConverterBoolean
public ConverterBoolean()
getClassToConvertTo
public java.lang.Class getClassToConvertTo()
- Specified by:
getClassToConvertTo
in interface ObjectConverter
- Returns:
- The class that this converter converts to
convert
public java.lang.Object convert(java.lang.Object obj,
java.util.Locale locale)
throws ObjectConverterException
- Specified by:
convert
in interface ObjectConverter
- Parameters:
obj
- Object to be converted. Guaranteed not to be null and not to
already be an instanceof the Class returned by
ObjectConverter.getClassToConvertTo()
. Those conditions are checked
before the converter is even called.locale
- The locale that is asking for the conversion. This may or may
not be necessary for the conversion.
- Returns:
- The converted object - should NEVER return anything that is not
an instanceof the class returned by
ObjectConverter.getClassToConvertTo()
- Throws:
ObjectConverterException
- Throw this exception if the string cannot be converted, for
whatever reason.