com.codemesh.terp.eval.converters
Class ToBoolean
java.lang.Object
com.codemesh.terp.eval.converters.ToBoolean
- All Implemented Interfaces:
- Converter<java.lang.Boolean>
public class ToBoolean
- extends java.lang.Object
- implements Converter<java.lang.Boolean>
Converts various types to Booleans.
This converter is registered under the ^boolean name.
Like all converters, this type supports conversion from its own
target type (i.e. Boolean) and the String type. Any given string
will be evaluated as an expression and the result of that evaluation
will be evaluated as a boolean value.
For any other type, null is returned.
|
Field Summary |
static ToBoolean |
TO_BOOLEAN
An instance of the converter that can be used by
clients that need to convert something to a boolean. |
|
Method Summary |
java.lang.Boolean |
fromObject(java.lang.Object obj,
TerpContext ctx)
Converts the given object into an object of the target type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TO_BOOLEAN
public static final ToBoolean TO_BOOLEAN
- An instance of the converter that can be used by
clients that need to convert something to a boolean.
ToBoolean
public ToBoolean()
fromObject
public java.lang.Boolean fromObject(java.lang.Object obj,
TerpContext ctx)
- Converts the given object into an object of the target type.
Conversions can be implemented in any way that makes sense.
Normally, converters will return null for null, but some converters
may choose to interpret null as an indicator to return a
default-initialized target object. An example of this type
of conversion is the ShellExecutor. null simply indicates that
no preference overrides of any kind have been provided.
- Specified by:
fromObject in interface Converter<java.lang.Boolean>
- Parameters:
obj - the source object.ctx - the context in which the conversion takes place.
- Returns:
- an instance of the target type or null.
Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.