@NotThreadSafe public final class AstNode extends Object implements Iterable<AstNode>, Cloneable
Constructor and Description |
---|
AstNode(AstNode parent,
String name)
Construct a node with the supplied name and parent.
|
Modifier and Type | Method and Description |
---|---|
void |
addChildren(AstNode first,
AstNode second)
Add the supplied nodes at the end of the list of children.
|
void |
addChildren(AstNode first,
AstNode second,
AstNode third)
Add the supplied nodes at the end of the list of children.
|
void |
addChildren(Iterable<AstNode> otherChildren)
Add the supplied nodes at the end of the list of children.
|
void |
addFirstChild(AstNode child)
Add the supplied node to the front of the list of children.
|
void |
addLastChild(AstNode child)
Add the supplied node to the end of the list of children.
|
boolean |
addMixin(String mixin) |
List<AstNode> |
childrenWithName(String name) |
AstNode |
clone()
This class returns a new clone of the plan tree rooted at this node.
|
protected AstNode |
cloneWithoutNewParent() |
void |
extractChild(AstNode child)
Remove the child node from this node, and replace that child with its first child (if there is one).
|
void |
extractFromParent()
Extract this node from its parent, but replace this node with its child (if there is one).
|
String |
getAbsolutePath()
Get the current path of this node
|
AstNode |
getChild(int index)
Get the child at the supplied index.
|
int |
getChildCount()
Get the number of child nodes.
|
List<AstNode> |
getChildren()
Get the unmodifiable list of child nodes.
|
List<AstNode> |
getChildren(String mixin) |
AstNode |
getFirstChild()
Get the first child.
|
AstNode |
getLastChild()
Get the last child.
|
List<String> |
getMixins() |
String |
getName()
Get the name of the node.
|
AstNode |
getParent()
Get the parent of this node.
|
String |
getPrimaryType() |
Object |
getProperty(String name)
Get the property with the supplied name.
|
List<String> |
getPropertyNames()
Return the list of property names for this node.
|
int |
getSameNameSiblingIndex()
Get the current same-name-sibling index.
|
boolean |
hasMixin(String mixin) |
void |
insertAsParent(AstNode newParent)
Insert the supplied node into the plan node tree immediately above this node.
|
boolean |
isSameAs(AstNode other)
Determine whether the supplied plan is equivalent to this plan.
|
Iterator<AstNode> |
iterator()
This iterator is immutable.
|
List<AstNode> |
removeAllChildren()
Remove all children from this node.
|
boolean |
removeChild(AstNode child)
Remove the node from this node.
|
AstNode |
removeFromParent()
Remove this node from its parent, and return the node that used to be the parent of this node.
|
Object |
removeProperty(String name)
Remove and return the property with the supplied name.
|
boolean |
replaceChild(AstNode child,
AstNode replacement)
Replace the supplied child with another node.
|
void |
setParent(AstNode parent)
Set the parent for this node.
|
AstNode |
setProperty(String name,
Object... values)
Set the property with the given name to the supplied values.
|
AstNode |
setProperty(String name,
Object value)
Set the property with the given name to the supplied value.
|
String |
toString() |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public boolean addMixin(String mixin)
mixin
- the mixin being added (cannot be null
or empty)true
if mixin was addedpublic boolean hasMixin(String mixin)
mixin
- the mixin to look for (cannot be null
or empty)true
if the node has the specified mixinpublic String getName()
public String getPrimaryType()
public int getSameNameSiblingIndex()
public String getAbsolutePath()
public Object getProperty(String name)
name
- the property name; never nullpublic AstNode setProperty(String name, Object value)
name
- the name of the property; may not be nullvalue
- the value of the property; may not be nullpublic AstNode setProperty(String name, Object... values)
name
- the name of the property; may not be nullvalues
- the values of the propertypublic Object removeProperty(String name)
name
- the property name; may not be nullpublic List<String> getPropertyNames()
public AstNode getParent()
public void setParent(AstNode parent)
parent
- the new parent, or null if this node is to have no parentpublic void insertAsParent(AstNode newParent)
For example, consider a plan node tree before this method is called:
A / | \ / | \ B C DThen after this method is called with
c.insertAsParent(e)
, the resulting plan node tree will be:
A / | \ / | \ B E D | | C
Also note that the node on which this method is called ('C' in the example above) will always be added as the
last child
to the new parent. This allows the new parent to already have children before
this method is called.
newParent
- the new parent; method does nothing if this is nullpublic AstNode removeFromParent()
extractChild(AstNode)
,
extractFromParent()
public boolean replaceChild(AstNode child, AstNode replacement)
child
- the node that is already a child and that is to be replaced; may not be null and must be a childreplacement
- the node that is to replace the 'child' node; may not be nullpublic int getChildCount()
public AstNode getFirstChild()
public AstNode getLastChild()
public List<AstNode> childrenWithName(String name)
name
- the name of the child being requested (cannot be null
or empty)null
but can be empty)public AstNode getChild(int index)
index
- the indexIndexOutOfBoundsException
- if the index is not valid given the number of childrenpublic void addFirstChild(AstNode child)
child
- the node that should be added as the first child; may not be nullpublic void addLastChild(AstNode child)
child
- the node that should be added as the last child; may not be nullpublic void addChildren(Iterable<AstNode> otherChildren)
otherChildren
- the children to add; may not be nullpublic void addChildren(AstNode first, AstNode second)
first
- the first child to addsecond
- the second child to addpublic void addChildren(AstNode first, AstNode second, AstNode third)
first
- the first child to addsecond
- the second child to addthird
- the third child to addpublic boolean removeChild(AstNode child)
child
- the child node; may not be nullpublic void extractChild(AstNode child)
child
- the child to be extracted; may not be null and must have at most 1 childextractFromParent()
public void extractFromParent()
extractChild(AstNode)
public List<AstNode> getChildren()
public List<AstNode> getChildren(String mixin)
mixin
- the mixin to match children with (cannot be null
or empty)null
)public Iterator<AstNode> iterator()
This iterator is immutable.
iterator
in interface Iterable<AstNode>
Iterable.iterator()
public List<AstNode> removeAllChildren()
public boolean isSameAs(AstNode other)
other
- the other plan to compare with this instancepublic AstNode clone()
This class returns a new clone of the plan tree rooted at this node. However, the top node of the resulting plan tree (that is, the node returned from this method) has no parent.
clone
in class Object
Object.clone()
protected AstNode cloneWithoutNewParent()
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.