|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.sequencer.ddl.node.AstNode
@NotThreadSafe public class AstNode
Utility object class designed to facilitate constructing an AST or Abstract Syntax Tree representing nodes and properties that are compatible with ModeShape graph component structure.
Constructor Summary | |
---|---|
AstNode(AstNode parent,
Name name)
Construct a node with the supplied name and parent. |
|
AstNode(Name name)
Construct a node with the supplied name but without a parent. |
Method Summary | |
---|---|
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. |
AstNode |
clone()
This class returns a new clone of the plan tree rooted at this node. |
protected AstNode |
cloneWithoutNewParent()
|
boolean |
equals(Object obj)
|
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). |
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. |
AstNode |
getFirstChild()
Get the first child. |
AstNode |
getLastChild()
Get the last child. |
Name |
getName()
Get the name of the node. |
AstNode |
getParent()
Get the parent of this node. |
Path |
getPath(ExecutionContext context)
Get the current path of this node, using the supplied context. |
Path |
getPathRelativeTo(Path rootPath,
ExecutionContext context)
Get the current path of this node, as if the current tree is below the supplied root path, using the supplied context. |
List<Property> |
getProperties()
Return the list of properties for this node. |
Property |
getProperty(Name name)
Get the property with the supplied name. |
int |
getSameNameSiblingIndex()
Get the current same-name-sibling index. |
String |
getString(ExecutionContext context)
Get the string representation of this query object. |
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. |
Property |
removeProperty(Name 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(Name name,
Object... values)
Set the property with the given name to the supplied values. |
AstNode |
setProperty(Name name,
Object value)
Set the property with the given name to the supplied value. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AstNode(Name name)
name
- the name of the node; may not be nullpublic AstNode(AstNode parent, Name name)
parent
- the parent node; may be null if the new node is to be a rootname
- the name of the node; may not be nullMethod Detail |
---|
public Name getName()
public int getSameNameSiblingIndex()
public Path getPath(ExecutionContext context)
context
- the context; may not be null
public Path getPathRelativeTo(Path rootPath, ExecutionContext context)
rootPath
- the path to the root of this AST tree; may not be nullcontext
- the context; may not be null
public Property getProperty(Name name)
name
- the property name; never null
public AstNode setProperty(Name name, Object value)
name
- the name of the property; may not be nullvalue
- the value of the property; may not be null
public AstNode setProperty(Name name, Object... values)
name
- the name of the property; may not be nullvalues
- the values of the property
removeProperty(Name)
public Property removeProperty(Name name)
name
- the property name; may not be null
public List<Property> getProperties()
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 null
public int getChildCount()
public AstNode getFirstChild()
public AstNode getLastChild()
public AstNode getChild(int index)
index
- the index
IndexOutOfBoundsException
- 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 null
public 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 Iterator<AstNode> iterator()
This iterator is immutable.
iterator
in interface Iterable<AstNode>
Iterable.iterator()
public List<AstNode> removeAllChildren()
public String toString()
toString
in class Object
Object.toString()
public final boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public 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()
public boolean isSameAs(AstNode other)
other
- the other plan to compare with this instance
public String getString(ExecutionContext context)
context
- the execution context in which the conversion is to take place
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |