freemarker.ext.beans
Class SimpleNumberModel

java.lang.Object
  extended by freemarker.ext.beans.SimpleNumberModel
All Implemented Interfaces:
TemplateModel, TemplateNumberModel, TemplateObjectModel, TemplateScalarModel, java.io.Serializable

Deprecated. this class is deprecated in favour of the classes in the freemarker.ext.beans2 package

public class SimpleNumberModel
extends java.lang.Object
implements TemplateNumberModel, TemplateScalarModel, TemplateObjectModel, java.io.Serializable

Holds subclasses of Number for evaluation as TemplateNumberModel or unwrapped as an object. We also implement TemplateScalarModel so that floats or doubles are printed with full precision.

Version:
$Id: SimpleNumberModel.java 1101 2013-04-01 04:17:32Z run2000 $
Author:
Nicholas Cull
See Also:
Serialized Form

Constructor Summary
SimpleNumberModel(java.lang.Number number)
          Deprecated. Constructor that takes the Number object to be wrapped.
 
Method Summary
 long getAsNumber()
          Deprecated. Retrieve the underlying value as a long.
 java.lang.Object getAsObject()
          Deprecated. Retrieve the underlying object for object unwrapping purposes.
 java.lang.String getAsString()
          Deprecated. Retrieve the underlying value as a String.
 boolean isEmpty()
          Deprecated. Is there an underlying number in this model?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleNumberModel

public SimpleNumberModel(java.lang.Number number)
Deprecated. 
Constructor that takes the Number object to be wrapped.

Parameters:
number - the number to be wrapped
Method Detail

getAsNumber

public long getAsNumber()
                 throws TemplateModelException
Deprecated. 
Retrieve the underlying value as a long. Numbers that use decimal places will be rounded appropriately.

Specified by:
getAsNumber in interface TemplateNumberModel
Returns:
a long value representing the underlying number
Throws:
TemplateModelException

getAsString

public java.lang.String getAsString()
                             throws TemplateModelException
Deprecated. 
Retrieve the underlying value as a String. This preserves any decimal places held in the underlying object.

Specified by:
getAsString in interface TemplateScalarModel
Returns:
a String representation of the underlying number
Throws:
TemplateModelException

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Deprecated. 
Is there an underlying number in this model?

Specified by:
isEmpty in interface TemplateModel
Returns:
true if there is a Number object present, otherwise false
Throws:
TemplateModelException

getAsObject

public java.lang.Object getAsObject()
                             throws TemplateModelException
Deprecated. 
Retrieve the underlying object for object unwrapping purposes.

Specified by:
getAsObject in interface TemplateObjectModel
Returns:
the underlying Number object
Throws:
TemplateModelException - the object could not be returned