terp - the Codemesh Modular
Template Interpreter v1.3.309

com.codemesh.terp.eval.converters
Class ToInteger

java.lang.Object
  extended by com.codemesh.terp.eval.converters.ToInteger
All Implemented Interfaces:
Converter<java.lang.Integer>

public class ToInteger
extends java.lang.Object
implements Converter<java.lang.Integer>

Converts various types to Integer values. This converter is registered under the ^int name.

Like all converters, this type supports conversion from its own target type (i.e. Integer) and the String type. Any given string will be evaluated as an expression and the result of that evaluation will be evaluated as a Integer value. This converter also supports conversions from numeric types. Any number will be converted to a Integer. For any other type, null is returned.


Field Summary
static ToInteger TO_INTEGER
          An immediately usable instance of a to-integer converter.
 
Constructor Summary
ToInteger()
           
 
Method Summary
 java.lang.Integer 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
 

Field Detail

TO_INTEGER

public static final ToInteger TO_INTEGER
An immediately usable instance of a to-integer converter.

Constructor Detail

ToInteger

public ToInteger()
Method Detail

fromObject

public java.lang.Integer 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.Integer>
Parameters:
obj - the source object.
ctx - the context in which the conversion takes place.
Returns:
an instance of the target type or null.

terp - the Codemesh Modular
Template Interpreter v1.3.309

Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.