wugle.expression
Class AbstractBinaryOperator

java.lang.Object
  |
  +--wugle.expression.AbstractExpression
        |
        +--wugle.expression.AbstractBinaryOperator
All Implemented Interfaces:
BinaryOperator, java.lang.Cloneable, Expression, Operator
Direct Known Subclasses:
Implies, LogicBinaryOperator, Xor

public abstract class AbstractBinaryOperator
extends AbstractExpression
implements BinaryOperator

An abstract implementation of BinaryOperator.

AbstractBinaryOperator provides a basic implementation of BinaryOperator, but is not meant to be a full class. Subclasses should implement the appropriate operation interfaces.

Version:
0.1.3
Author:
Jacob Perkins

Field Summary
 
Fields inherited from class wugle.expression.AbstractExpression
log, operation
 
Constructor Summary
AbstractBinaryOperator(java.lang.String symbol, ExpressionOperation operation, Expression leftChild, Expression rightChild)
          Initializes the Expression and sets the initial child Expressions
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this Expression.
 Expression getLeftChild()
          Gets the left child Expression.
 Expression getRightChild()
          Gets the right child Expression.
 boolean isEqual(Expression expression)
          Tests if this Expression is equal to the given Expression.
 void setChild(Expression oldChild, Expression newChild)
          Replaces a current child Expression with a new child Expression
 void setLeftChild(Expression child)
          Sets the left child Expression.
 void setRightChild(Expression child)
          Sets the right child Expression.
 java.lang.String toString()
          Gets the String representation of the Expression.
 
Methods inherited from class wugle.expression.AbstractExpression
getParent, getSymbol, setParent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wugle.expression.Expression
getParent, getSymbol, setParent
 

Constructor Detail

AbstractBinaryOperator

public AbstractBinaryOperator(java.lang.String symbol,
                              ExpressionOperation operation,
                              Expression leftChild,
                              Expression rightChild)
Initializes the Expression and sets the initial child Expressions

Parameters:
symbol - Symbol representing this Operator
operation - Object for delegating operations to
leftChild - Left child Expression
rightChild - Right child Expression
Method Detail

toString

public java.lang.String toString()
Description copied from class: AbstractExpression
Gets the String representation of the Expression.

Overrides:
toString in class AbstractExpression
Returns:
The symbol representing the Expression
See Also:
AbstractExpression.getSymbol()

clone

public java.lang.Object clone()
Description copied from interface: Expression
Returns a copy of this Expression.

Specified by:
clone in interface Expression
Overrides:
clone in class AbstractExpression
Returns:
Copy of the Expression

isEqual

public boolean isEqual(Expression expression)
Description copied from interface: Expression
Tests if this Expression is equal to the given Expression.

Specified by:
isEqual in interface Expression
Parameters:
expression - Expression to compare to
Returns:
true if they are equal

setChild

public void setChild(Expression oldChild,
                     Expression newChild)
Description copied from interface: Operator
Replaces a current child Expression with a new child Expression

Specified by:
setChild in interface Operator
Parameters:
oldChild - Child Expression to replace
newChild - Replacement child Expression
See Also:
setLeftChild(Expression), setRightChild(Expression)

getLeftChild

public Expression getLeftChild()
Description copied from interface: BinaryOperator
Gets the left child Expression.

Specified by:
getLeftChild in interface BinaryOperator
Returns:
The left child Expression, or null if there is none
See Also:
BinaryOperator.getRightChild(), BinaryOperator.setLeftChild(Expression)

setLeftChild

public void setLeftChild(Expression child)
Description copied from interface: BinaryOperator
Sets the left child Expression.

Specified by:
setLeftChild in interface BinaryOperator
Parameters:
child - The new left child Expression, or null for no child
See Also:
BinaryOperator.getLeftChild(), BinaryOperator.setRightChild(Expression)

getRightChild

public Expression getRightChild()
Description copied from interface: BinaryOperator
Gets the right child Expression.

Specified by:
getRightChild in interface BinaryOperator
Returns:
The right child Expression, or null if there is none
See Also:
BinaryOperator.getLeftChild(), BinaryOperator.setRightChild(Expression)

setRightChild

public void setRightChild(Expression child)
Description copied from interface: BinaryOperator
Sets the right child Expression.

Specified by:
setRightChild in interface BinaryOperator
Parameters:
child - The new right child Expression, or null for no child
See Also:
BinaryOperator.getRightChild(), BinaryOperator.setLeftChild(Expression)