freemarker.ext.beans2
Class NumberWrapper

java.lang.Object
  extended by freemarker.ext.beans2.NumberWrapper
All Implemented Interfaces:
ObjectWrapper, TemplateModel, TemplateNumberModel, TemplateObjectModel, TemplateScalarModel, java.io.Serializable, java.lang.Cloneable

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

Wraps a Number object as a number model. Does not provide any additional Bean methods.

Since:
1.9
Version:
$Id: NumberWrapper.java 1067 2011-06-06 10:55:28Z run2000 $
Author:
Nicholas Cull
See Also:
Serialized Form

Constructor Summary
NumberWrapper()
          Default constructor where an object is not provided initially.
NumberWrapper(java.lang.Number object)
          Constructor that takes a Number object to be wrapped.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a copy of this object.
 long getAsNumber()
          Returns the number's value as a long.
 java.lang.Object getAsObject()
          Return the underlying object to the reflection mechanism in the freemarker.ext.beans2 package.
 java.lang.String getAsString()
          Returns the scalar's value as a String.
 boolean isEmpty()
          Is the object empty?
 void setObject(java.lang.Object object)
          Sets the object to be wrapped by this object wrapper.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberWrapper

public NumberWrapper()
Default constructor where an object is not provided initially. This allows the wrapper to be used as a prototype.


NumberWrapper

public NumberWrapper(java.lang.Number object)
Constructor that takes a Number object to be wrapped.

Parameters:
object - the number object to be wrapped
Method Detail

setObject

public void setObject(java.lang.Object object)
Description copied from interface: ObjectWrapper
Sets the object to be wrapped by this object wrapper.

Specified by:
setObject in interface ObjectWrapper
Parameters:
object - the object to be wrapped

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Description copied from interface: TemplateModel
Is the object empty?

Specified by:
isEmpty in interface TemplateModel
Returns:
true if this object is empty, otherwise false
Throws:
TemplateModelException

getAsString

public java.lang.String getAsString()
                             throws TemplateModelException
Description copied from interface: TemplateScalarModel
Returns the scalar's value as a String.

Specified by:
getAsString in interface TemplateScalarModel
Returns:
the String value of this scalar.
Throws:
TemplateModelException

getAsNumber

public long getAsNumber()
                 throws TemplateModelException
Description copied from interface: TemplateNumberModel
Returns the number's value as a long.

Specified by:
getAsNumber in interface TemplateNumberModel
Returns:
the long value of this scalar.
Throws:
TemplateModelException

getAsObject

public java.lang.Object getAsObject()
                             throws TemplateModelException
Description copied from interface: TemplateObjectModel
Return the underlying object to the reflection mechanism in the freemarker.ext.beans2 package. Any variables, methods or properties can be called directly via reflection.

Specified by:
getAsObject in interface TemplateObjectModel
Returns:
the underlying object for this template model
Throws:
TemplateModelException - the object could not be returned

clone

public java.lang.Object clone()
Creates and returns a copy of this object.

Specified by:
clone in interface ObjectWrapper
Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
java.lang.RuntimeException - the clone operation was not successful
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable