org.mov.parser.expression
Class BinaryExpression
java.lang.Object
org.mov.parser.expression.AbstractExpression
org.mov.parser.expression.BinaryExpression
- All Implemented Interfaces:
- java.lang.Cloneable, Expression
- Direct Known Subclasses:
- ArithmeticExpression, ComparisionExpression, LagExpression, LogicExpression, MACDExpression, PercentExpression, RSIExpression, WhileExpression
public abstract class BinaryExpression
- extends AbstractExpression
Abstract base class for all expressions requiring two arguments.
Method Summary |
int |
getChildCount()
Return the number of children required in a binary expression. |
protected java.lang.String |
toString(java.lang.String operator)
Helper method to conver the given expression to a string. |
Methods inherited from class org.mov.parser.expression.AbstractExpression |
clone, equals, getChild, getIndex, getNumberFormat, getParent, hashCode, isRoot, iterator, parseDouble, parseInt, setChild, setParent, simplify, size, size, valueOfDouble, valueOfInt |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
BinaryExpression
public BinaryExpression(Expression left,
Expression right)
- Create a new binary expression with the given left and right
arguments.
- Parameters:
left
- the left argumentright
- the right argument
getChildCount
public int getChildCount()
- Return the number of children required in a binary expression.
This will always evaluate to
2
.
- Returns:
2
toString
protected java.lang.String toString(java.lang.String operator)
- Helper method to conver the given expression to a string.
Given an operator such as
+
, -
etc
it will return arg1 operator arg2
. It will insert
parentheses as needed.
- Parameters:
operator
- the binary operator
- Returns:
- the string representation