com.google.template.soy.data.restricted
Class NumberData

java.lang.Object
  extended by com.google.template.soy.data.SoyData
      extended by com.google.template.soy.data.restricted.PrimitiveData
          extended by com.google.template.soy.data.restricted.NumberData
Direct Known Subclasses:
FloatData, IntegerData

public abstract class NumberData
extends PrimitiveData

Abstract superclass for number data (integers and floats).

Important: This class may only be used in implementing plugins (e.g. functions, directives).


Constructor Summary
NumberData()
           
 
Method Summary
 boolean equals(Object other)
          Compares this data object against another for equality in the sense of the operator '==' for Soy expressions.
 int hashCode()
           
 double numberValue()
          Precondition: Only call this method if you know that this SoyData object is a number.
abstract  double toFloat()
          Gets the float value of this number data object.
 
Methods inherited from class com.google.template.soy.data.SoyData
booleanValue, createFromExistingData, createFromExistingData, floatValue, integerValue, stringValue, toBoolean, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberData

public NumberData()
Method Detail

toFloat

public abstract double toFloat()
Gets the float value of this number data object. If this object is actually an integer, its value will be converted to a float before being returned.

Returns:
The float value of this number data object.

numberValue

public double numberValue()
Description copied from class: SoyData
Precondition: Only call this method if you know that this SoyData object is a number. This method gets the float value of this number object (converting integer to float if necessary).

Overrides:
numberValue in class SoyData
Returns:
The float value of this number object.

equals

public boolean equals(Object other)
Description copied from class: SoyData
Compares this data object against another for equality in the sense of the operator '==' for Soy expressions.

Specified by:
equals in class SoyData
Parameters:
other - The other data object to compare against.
Returns:
True if the two objects are equal.

hashCode

public int hashCode()
Overrides:
hashCode in class Object