freemarker.template.expression
Class Minus

java.lang.Object
  extended by freemarker.template.expression.AbstractBinary
      extended by freemarker.template.expression.Minus
All Implemented Interfaces:
Binary, Expression, Operator, java.io.Serializable

public final class Minus
extends AbstractBinary
implements java.io.Serializable

A subtraction operator.

Since:
1.8
Version:
$Id: Minus.java 1153 2013-04-15 10:59:37Z run2000 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class freemarker.template.expression.AbstractBinary
left, right
 
Constructor Summary
Minus()
          Default constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determines whether this object is equal to the given object.
 TemplateModel getAsTemplateModel(TemplateWriteableHashModel modelRoot)
          Performs subtraction on the two number models set previously.
 ExpressionBuilder.Precedence getPrecedence()
          Return the precedence for this operator to the caller.
 java.util.Set<ExpressionUtils.ExpressionType> getType()
          Determine the type of result that can be calculated by this expression.
 int hashCode()
          Returns the hash code for this operator.
 boolean isConstant()
          Determine whether result calculated by this expression is a constant value.
 void setLeft(Expression left)
          Sets the left-hand side of the expression.
 void setRight(Expression right)
          Sets the right-hand side of the expression.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class freemarker.template.expression.AbstractBinary
isComplete, resolveExpression
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Minus

public Minus()
Default constructor.

Method Detail

setLeft

public void setLeft(Expression left)
Sets the left-hand side of the expression.

Specified by:
setLeft in interface Binary
Overrides:
setLeft in class AbstractBinary
Parameters:
left - the left-hand side of the expression
Throws:
java.lang.NullPointerException - the key expression was null
java.lang.IllegalArgumentException - the key could not be evaluated as a number

setRight

public void setRight(Expression right)
Sets the right-hand side of the expression.

Specified by:
setRight in interface Binary
Overrides:
setRight in class AbstractBinary
Parameters:
right - the right-hand side of the expression
Throws:
java.lang.NullPointerException - the key expression was null
java.lang.IllegalArgumentException - the key could not be evaluated as a number

getAsTemplateModel

public TemplateModel getAsTemplateModel(TemplateWriteableHashModel modelRoot)
                                 throws TemplateException
Performs subtraction on the two number models set previously. One is subtracted from the other using normal arithmetic, then returned. If either of the values is not a number, an exception is thrown.

Specified by:
getAsTemplateModel in interface Expression
Parameters:
modelRoot - the template model that will be evaluated by the expression
Returns:
A FastNumber of the expression
Throws:
TemplateException - the expression could not be evaluated for some reason

getType

public java.util.Set<ExpressionUtils.ExpressionType> 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

isConstant

public boolean isConstant()
Determine whether result calculated by this expression is a constant value.

Specified by:
isConstant in interface Expression

getPrecedence

public ExpressionBuilder.Precedence getPrecedence()
Return the precedence for this operator to the caller. Used for associating operators according to precedence.

Specified by:
getPrecedence in interface Operator
Returns:
an enumeration indicating the precedence of this operator

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this expression

equals

public boolean equals(java.lang.Object o)
Determines whether this object is equal to the given object.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to be compared with
Returns:
true if the objects are equal, otherwise false

hashCode

public int hashCode()
Returns the hash code for this operator.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of this object