|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.scheinerman.phoenix.interpreter.parser.operators.OperatorNode
public abstract class OperatorNode
Represents an operator that is being parsed in an expression tree in Phoenix. This class is to be
subclasssed to provide specific implementation of operator capabilities in Phoenix. For example the
AddOperatorNode
class provides implementation of the +
operator.
Field Summary | |
---|---|
private ParserTreeNode |
left
The left-hand operand of this operator. |
private boolean |
parenthesized
Whether or not this node is encapsulated by parentheses. |
private ParserTreeNode |
right
The right-hand operand of this operator. |
Constructor Summary | |
---|---|
OperatorNode(ParserTreeNode left,
ParserTreeNode right)
Creates a new operator node with left and right-hand operands. |
Method Summary | |
---|---|
abstract int |
getPrecedence()
Returns the precedence of the node in the order of operations, when it should be evaluated in the tree. |
boolean |
isLeftOperandUnary()
Determines if, for a unary operator the operand is on the right or the left. |
boolean |
isParenthesized()
Returns true or false based on whether or not this node was encapsulated by parentheses. |
boolean |
isUnary()
Returns whether or not this operator is unary, meaning that it only accepts one operand on the right or the left. |
ParserTreeNode |
left()
Returns the left-hand operand of this operator. |
void |
left(ParserTreeNode left)
Sets the left-hand operand of this operator. |
Variable |
operate()
Parses this operator, by operating on the left and right hand arguments and then combining the results in some implementation specific manner. |
abstract java.lang.String |
operator()
Returns the string representation of this operator. |
ParserTreeNode |
right()
Returns the left-hand operand of this operator. |
void |
right(ParserTreeNode right)
Sets the right-hand operand of this operator. |
void |
setParenthesized(boolean parenthesized)
Sets whether or not this node is encapsulated by parentheses. |
java.lang.String |
toString()
Returns a string in the form: "(" + left().toString() + operator() + right().toString() + ")" . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private boolean parenthesized
private ParserTreeNode left
private ParserTreeNode right
Constructor Detail |
---|
public OperatorNode(ParserTreeNode left, ParserTreeNode right)
left
- - The new left-hand operand.right
- - The new left-hand operand.Method Detail |
---|
public boolean isParenthesized()
ParserTreeNode
isParenthesized
in interface ParserTreeNode
public void setParenthesized(boolean parenthesized)
ParserTreeNode
setParenthesized
in interface ParserTreeNode
parenthesized
- - true
if this node is surrounded by parentheses, false
if not.public final ParserTreeNode left()
left
in interface ParserTreeNode
public final void left(ParserTreeNode left)
left
- - The new left-hand operand.public final ParserTreeNode right()
right
in interface ParserTreeNode
public final void right(ParserTreeNode right)
left
- - The new right-hand operand.public Variable operate()
operate
in interface ParserTreeNode
public abstract java.lang.String operator()
"+"
is returned.
public java.lang.String toString()
"(" + left().toString() + operator() + right().toString() + ")"
.
toString
in class java.lang.Object
public abstract int getPrecedence()
ParserTreeNode
getPrecedence
in interface ParserTreeNode
public boolean isUnary()
isLeftOperandUnary()
method is used.
By default, this method returns false
.
true
if it is unary, false
if not.public boolean isLeftOperandUnary()
true
, then the operator has a left-hand operand, if false
, the operator
has a right-hand operand.
true
if this operator has a left-hand, false
if it has a right-hand
operand.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |