freemarker.template.expression
Class NumberLiteral

java.lang.Object
  |
  +--freemarker.template.expression.NumberLiteral
All Implemented Interfaces:
Expression, ExpressionElement, java.io.Serializable

public final class NumberLiteral
extends java.lang.Object
implements Expression, java.io.Serializable

Represents a number literal in a FM-Classic template.

Since:
1.8
Version:
$Id: NumberLiteral.java,v 1.22 2003/11/27 11:36:45 run2000 Exp $
See Also:
Serialized Form

Constructor Summary
NumberLiteral(java.lang.String value)
          Constructor that takes a numeric value as a String.
 
Method Summary
 boolean equals(java.lang.Object o)
          Override the Object.equals method.
 TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
          Retrieve the value of this NumberLiteral as a TemplateModel.
 int getType()
          Determine the type of result that can be calculated by this expression.
 int hashCode()
          Override the Object.hashCode method.
 boolean isComplete()
          Does the NumberLiteral have a value?
 java.lang.String toString()
          Override the Object.toString method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberLiteral

public NumberLiteral(java.lang.String value)
Constructor that takes a numeric value as a String.
Parameters:
value - the value to be held by this NumberLiteral
Throws:
NullPointerException - the value is null
java.lang.NumberFormatException - the value could not be parsed as a long value
Method Detail

getAsTemplateModel

public TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
Retrieve the value of this NumberLiteral as a TemplateModel.
Specified by:
getAsTemplateModel in interface Expression
Parameters:
modelRoot - the template model that will be evaluated by the expression
Returns:
a FastScalar containing the number

isComplete

public boolean isComplete()
Does the NumberLiteral have a value?
Specified by:
isComplete in interface Expression
Returns:
true if there is a value, otherwise false

getType

public int getType()
Determine the type of result that can be calculated by this expression. This is in the form of an integer constant ored together from values in the ExpressionUtils class.
Specified by:
getType in interface Expression

toString

public java.lang.String toString()
Override the Object.toString method.
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this expression

equals

public boolean equals(java.lang.Object o)
Override the Object.equals method.
Overrides:
equals in class java.lang.Object
Parameters:
o - the object we're comparing against
Returns:
true if the two objects are equal, otherwise false

hashCode

public int hashCode()
Override the Object.hashCode method.
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code corresponding to the value of this object