|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--parser.ExpressionParser.Default.Node
Provides a simple implementation of ExpressionParser.Node
.
Constructor Summary | |
ExpressionParser.Default.Node(java.util.List childNodes)
Constucts an instance. |
Method Summary | |
void |
accept(ExpressionParser.Visitor visitor)
The accept method of the visitor design pattern. |
java.util.List |
getChildNodes()
Returns the list given by the constructor. |
ExpressionParser.Node |
getParentNode()
Returns the parent node of this , or null if and only if this node is the root of the tree. |
protected void |
replaceChild(ExpressionParser.Node oldChild,
ExpressionParser.Node newChild)
Replaces the child node oldChild with newChild . |
void |
replaceSubtree(ExpressionParser.Node node)
Replaces the sub-tree whose root is this with the sub-tree whose root is node . |
void |
setParentNode(ExpressionParser.Node parentNode)
Sets the result of getParentNode() . |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ExpressionParser.Default.Node(java.util.List childNodes)
The parent node of childNodes
is set to this
.
childNodes
- a list of child nodes, which is not copied and returned by getChildNodes()
.Method Detail |
public java.util.List getChildNodes()
getChildNodes
in interface ExpressionParser.Node
this
.public void accept(ExpressionParser.Visitor visitor)
ExpressionParser.Node
The visitor
visits this
node and the children using the preorder traversal method.
accept
in interface ExpressionParser.Node
visitor
- the visitor.public ExpressionParser.Node getParentNode()
ExpressionParser.Node
this
, or null if and only if this
node is the root of the tree.
This method simply returns the value the method ExpressionParser.Node.setParentNode(parser.ExpressionParser.Node)
set, so the above specification should be maintained by the user of this
object.
getParentNode
in interface ExpressionParser.Node
this
, or null if this
node is the root of the tree.public void setParentNode(ExpressionParser.Node parentNode)
ExpressionParser.Node
ExpressionParser.Node.getParentNode()
.
setParentNode
in interface ExpressionParser.Node
protected void replaceChild(ExpressionParser.Node oldChild, ExpressionParser.Node newChild)
oldChild
with newChild
.
Correctly, the method replaces the sub-tree whose root is oldChild
with the sub-tree whose root is newChild
.
The method dose not replace only the element of ExpressionParser.Node.getChildNodes()
,
but also the values returned by the methods that are
defined by the classes in ExpressionParser
and that return the child node(s) labeled in the notavaCC source.
The method calls newChild.setParentNode(this)
and oldChild.setParentNode(null)
.
oldChild
- a replaced child node.newChild
- a child node to replace oldChild
.public void replaceSubtree(ExpressionParser.Node node) throws java.lang.IllegalStateException
this
with the sub-tree whose root is node
.
The method calls node.setParentNode
and this.setParentNode(null)
.
Precondition: (this.getParentNode() instanceof DefaultNode)
sould be true
.
node
- a node to replace.
java.lang.IllegalStateException
- parent == null || !(parent instanceof DefaultNode)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |