|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
scphEditor.CloneableObservable
scphEditor.OperandVector
scphEditor.Operand
public abstract class Operand
This abstract class models an operand. An operand may be a terminal expression like x or 10; or a compound expression like x+10. This abstract class is the superclass of both, defining common services and default implementations; this is the base class in a composite pattern.
The common services include child management. A compound expression has a number of child operands, e.g., x and 10 are the child operands in x+10. Each child is referred to by a zero-based index; thus, in x+10, x is child #0 and 10 is child #1. Child management, then, consists of methods for:
A compound expression class must override this and other behaviours and implement them for real. This is done by the Expression class hierarchy, for example.
Expression
,
Serialized FormConstructor Summary | |
---|---|
Operand()
Default constructor. |
Method Summary | |
---|---|
abstract void |
acceptVisitor(OperandVisitor v)
Interface for OperandVisitor objects to visit this operand concretely. |
void |
addParen()
Parenthesizes me. |
java.lang.Object |
clone()
Clones this operand. |
protected void |
deParen()
De-parenthesizes me. |
protected void |
ensureParen(Operand owner)
Parenthesizes me, if I need to be. |
abstract IOperator |
getOperator()
Gives the operator in this subexpression. |
boolean |
getParen()
Tells if I am already parenthesized. |
boolean |
getSplit()
Gets my split status. |
protected boolean |
needParen(Operand owner)
Determines if I need to be parenthesized, assuming I am a child of the given operand. |
void |
removeParen(OperandVector owner)
De-parenthesizes me, if I do not need parentheses. |
void |
setSplit(boolean split)
Sets my split status. |
Methods inherited from class scphEditor.OperandVector |
---|
addChild, countChildren, delChild, getChild, getChildren, setChild |
Methods inherited from class scphEditor.CloneableObservable |
---|
addObserver, cloneObserverList, cloneObserverList, countObservers, deleteObserver, deleteObservers, notifyObservers, notifyObservers |
Methods inherited from class java.util.Observable |
---|
clearChanged, hasChanged, setChanged |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Operand()
Method Detail |
---|
public java.lang.Object clone()
clone
in class CloneableObservable
public abstract IOperator getOperator()
IOperator
protected boolean needParen(Operand owner)
owner
- my hypothetical or real parent, or null.
protected void ensureParen(Operand owner)
owner
- my hypothetical or real parent, or null.needParen(scphEditor.Operand)
,
addParen()
,
OperandVector.setChild(scphEditor.Operand, int)
public void addParen()
The default implementation is for leaf nodes and does nothing. Compound expressions should override this properly.
protected void deParen()
The default implementation is for leaf nodes and does nothing. Compound expressions should override this properly.
removeParen(scphEditor.OperandVector)
public void removeParen(OperandVector owner)
owner
- my hypothetical or real parent, or null.needParen(scphEditor.Operand)
,
deParen()
public boolean getParen()
This default implementation is for leaf nodes. Compound expressions should override this properly.
public boolean getSplit()
b = aOf course, this is just a hint to the view.
This default implementation is for leaf nodes, which never splits. Compound expressions should override this properly.
public void setSplit(boolean split)
This default implementation is for leaf nodes, which never splits. Compound expressions should override this properly.
split
- true if you want me to split, false otherwise.public abstract void acceptVisitor(OperandVisitor v)
Implementations of this method are typically one-liners like:
v.visitConcreteOperand(this);
v
- the visitor object that wants to visit this operand.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |