Package freemarker.ext.beans
Class NumberModel
- java.lang.Object
-
- freemarker.ext.beans.BeanModel
-
- freemarker.ext.beans.NumberModel
-
- All Implemented Interfaces:
WrapperTemplateModel
,AdapterTemplateModel
,TemplateHashModel
,TemplateHashModelEx
,TemplateModel
,TemplateModelWithAPISupport
,TemplateNumberModel
public class NumberModel extends BeanModel implements TemplateNumberModel
Wraps arbitrary subclass ofNumber
into a reflective model. Beside acting as aTemplateNumberModel
, you can call all Java methods on these objects as well.
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
-
Constructor Summary
Constructors Constructor Description NumberModel(Number number, BeansWrapper wrapper)
Creates a new model that wraps the specified number object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Number
getAsNumber()
Returns the numeric value.-
Methods inherited from class freemarker.ext.beans.BeanModel
get, getAdaptedObject, getAPI, getWrappedObject, hasPlainGetMethod, invokeGenericGet, isEmpty, keys, keySet, size, toString, unwrap, values, wrap
-
-
-
-
Constructor Detail
-
NumberModel
public NumberModel(Number number, BeansWrapper wrapper)
Creates a new model that wraps the specified number object.- Parameters:
number
- the number object to wrap into a model.wrapper
- theBeansWrapper
associated with this model. Every model has to have an associatedBeansWrapper
instance. The model gains many attributes from its wrapper, including the caching behavior, method exposure level, method-over-item shadowing policy etc.
-
-
Method Detail
-
getAsNumber
public Number getAsNumber()
Description copied from interface:TemplateNumberModel
Returns the numeric value. The return value must not be null.- Specified by:
getAsNumber
in interfaceTemplateNumberModel
- Returns:
- the
Number
instance associated with this number model.
-
-