|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.query.plan.PlanNode
@NotThreadSafe public final class PlanNode
A representation of a single node within a plan tree.
Nested Class Summary | |
---|---|
static class |
PlanNode.Property
An enumeration dictating the type of plan tree nodes. |
static class |
PlanNode.Traversal
|
static class |
PlanNode.Type
An enumeration dictating the type of plan tree nodes. |
Constructor Summary | |
---|---|
PlanNode(PlanNode.Type type)
Create a new plan node with the supplied initial type. |
|
PlanNode(PlanNode.Type type,
Iterable<SelectorName> selectors)
Create a new plan node with the supplied initial type ad that is a child of the supplied parent. |
|
PlanNode(PlanNode.Type type,
PlanNode parent)
Create a new plan node with the supplied initial type ad that is a child of the supplied parent. |
|
PlanNode(PlanNode.Type type,
PlanNode parent,
Iterable<SelectorName> selectors)
Create a new plan node with the supplied initial type ad that is a child of the supplied parent. |
|
PlanNode(PlanNode.Type type,
PlanNode parent,
SelectorName... selectors)
Create a new plan node with the supplied initial type ad that is a child of the supplied parent. |
|
PlanNode(PlanNode.Type type,
SelectorName... selectors)
Create a new plan node with the supplied initial type ad that is a child of the supplied parent. |
Method Summary | ||
---|---|---|
void |
addChildren(Iterable<PlanNode> otherChildren)
Add the supplied nodes at the end of the list of children. |
|
void |
addChildren(PlanNode first,
PlanNode second)
Add the supplied nodes at the end of the list of children. |
|
void |
addChildren(PlanNode first,
PlanNode second,
PlanNode third)
Add the supplied nodes at the end of the list of children. |
|
void |
addFirstChild(PlanNode child)
Add the supplied node to the front of the list of children. |
|
void |
addLastChild(PlanNode child)
Add the supplied node to the end of the list of children. |
|
void |
addSelector(SelectorName symbol)
Add a selector to this plan node. |
|
void |
addSelector(SelectorName first,
SelectorName second)
Add the selectors to this plan node. |
|
void |
addSelectors(Iterable<SelectorName> names)
Add the selectors to this plan node. |
|
PlanNode |
clone()
This class returns a new clone of the plan tree rooted at this node. |
|
protected PlanNode |
cloneWithoutNewParent()
|
|
boolean |
equals(Object obj)
|
|
void |
extractChild(PlanNode 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). |
|
List<PlanNode> |
findAllAtOrBelow()
Find all of the nodes that are at or below this node. |
|
List<PlanNode> |
findAllAtOrBelow(PlanNode.Traversal order)
Find all of the nodes that are at or below this node. |
|
List<PlanNode> |
findAllAtOrBelow(PlanNode.Traversal order,
PlanNode.Type typeToFind)
Find all of the nodes of the specified type that are at or below this node. |
|
List<PlanNode> |
findAllAtOrBelow(PlanNode.Traversal order,
PlanNode.Type firstTypeToFind,
PlanNode.Type... additionalTypesToFind)
Find all of the nodes with one of the specified types that are at or below this node. |
|
List<PlanNode> |
findAllAtOrBelow(PlanNode.Traversal order,
Set<PlanNode.Type> typesToFind)
Find all of the nodes with one of the specified types that are at or below this node. |
|
List<PlanNode> |
findAllAtOrBelow(PlanNode.Type typeToFind)
Find all of the nodes of the specified type that are at or below this node, using pre-order traversal. |
|
List<PlanNode> |
findAllAtOrBelow(PlanNode.Type firstTypeToFind,
PlanNode.Type... additionalTypesToFind)
Find all of the nodes with one of the specified types that are at or below this node. |
|
List<PlanNode> |
findAllAtOrBelow(Set<PlanNode.Type> typesToFind)
Find all of the nodes with one of the specified types that are at or below this node. |
|
List<PlanNode> |
findAllFirstNodesAtOrBelow(PlanNode.Type typeToFind)
Look at nodes below this node, searching for nodes that have the supplied type. |
|
PlanNode |
findAncestor(PlanNode.Type typeToFind)
Starting at the parent of this node, find the lowest (also closest) ancestor that has the specified type. |
|
PlanNode |
findAncestor(PlanNode.Type firstTypeToFind,
PlanNode.Type... additionalTypesToFind)
Starting at the parent of this node, find the lowest (also closest) ancestor that has one of the specified types. |
|
PlanNode |
findAncestor(Set<PlanNode.Type> typesToFind)
Starting at the parent of this node, find the lowest (also closest) ancestor that has one of the specified types. |
|
PlanNode |
findAtOrBelow(PlanNode.Traversal order,
PlanNode.Type typeToFind)
Find the first node with the specified type that are at or below this node. |
|
PlanNode |
findAtOrBelow(PlanNode.Traversal order,
PlanNode.Type firstTypeToFind,
PlanNode.Type... additionalTypesToFind)
Find the first node with one of the specified types that are at or below this node. |
|
PlanNode |
findAtOrBelow(PlanNode.Traversal order,
Set<PlanNode.Type> typesToFind)
Find the first node with one of the specified types that are at or below this node. |
|
PlanNode |
findAtOrBelow(PlanNode.Type typeToFind)
Find the first node with the specified type that are at or below this node. |
|
PlanNode |
findAtOrBelow(PlanNode.Type firstTypeToFind,
PlanNode.Type... additionalTypesToFind)
Find the first node with one of the specified types that are at or below this node. |
|
PlanNode |
findAtOrBelow(Set<PlanNode.Type> typesToFind)
Find the first node with one of the specified types that are at or below this node. |
|
PlanNode |
getChild(int index)
Get the child at the supplied index. |
|
int |
getChildCount()
Get the number of child nodes. |
|
List<PlanNode> |
getChildren()
Get the unmodifiable list of child nodes. |
|
PlanNode |
getFirstChild()
Get the first child. |
|
PlanNode |
getLastChild()
Get the last child. |
|
PlanNode |
getParent()
Get the parent of this node. |
|
LinkedList<PlanNode> |
getPathTo(PlanNode descendant)
Get the path from this node (inclusive) to the supplied descendant node (inclusive) |
|
Object |
getProperty(PlanNode.Property propertyId)
Get the node's value for this supplied property. |
|
|
getProperty(PlanNode.Property propertyId,
Class<ValueType> type)
Get the node's value for this supplied property, casting the result to the supplied type. |
|
|
getPropertyAsCollection(PlanNode.Property propertyId,
Class<ValueType> type)
Get the node's value for this supplied property, casting the result to a Collection of the supplied type. |
|
|
getPropertyAsList(PlanNode.Property propertyId,
Class<ValueType> type)
Get the node's value for this supplied property, casting the result to a List of the supplied type. |
|
Set<PlanNode.Property> |
getPropertyKeys()
Get the keys for the property values that are set on this node. |
|
Set<SelectorName> |
getSelectors()
Get the selectors that are referenced by this plan node. |
|
String |
getString()
Get the string representation of this query object. |
|
PlanNode.Type |
getType()
Get the type for this node. |
|
boolean |
hasAncestorOfType(PlanNode.Type type)
Determine whether this node has an ancestor with the supplied type. |
|
boolean |
hasAncestorOfType(PlanNode.Type firstType,
PlanNode.Type... additionalTypes)
Determine whether this node has an ancestor with any of the supplied types. |
|
boolean |
hasAncestorOfType(Set<PlanNode.Type> types)
Determine whether this node has an ancestor with any of the supplied types. |
|
boolean |
hasBooleanProperty(PlanNode.Property propertyId)
Indicates if there is a non-null property value that equates to a true boolean value. |
|
boolean |
hasCollectionProperty(PlanNode.Property propertyId)
Indicates if there is a non-null and non-empty Collection value for the property. |
|
boolean |
hasProperty(PlanNode.Property propertyId)
Indicates if there is a non-null value for the property. |
|
void |
insertAsParent(PlanNode newParent)
Insert the supplied node into the plan node tree immediately above this node. |
|
boolean |
is(PlanNode.Type type)
Return true if this node's type does match the supplied type |
|
boolean |
isAbove(PlanNode possibleDescendant)
Determine if the supplied node is a descendant of this node. |
|
boolean |
isBelow(PlanNode possibleAncestor)
Determine if the supplied node is an ancestor of this node. |
|
boolean |
isNot(PlanNode.Type type)
Return true if this node's type does not match the supplied type |
|
boolean |
isNotOneOf(PlanNode.Type first,
PlanNode.Type... rest)
Return true if this node's type does not match any of the supplied types |
|
boolean |
isNotOneOf(Set<PlanNode.Type> types)
Return true if this node's type does not match any of the supplied types |
|
boolean |
isOneOf(PlanNode.Type first,
PlanNode.Type... rest)
Return true if this node's type matches one of the supplied types |
|
boolean |
isOneOf(Set<PlanNode.Type> types)
Return true if this node's type matches one of the supplied types |
|
boolean |
isSameAs(PlanNode other)
Determine whether the supplied plan is equivalent to this plan. |
|
Iterator<PlanNode> |
iterator()
This iterator is immutable. |
|
List<PlanNode> |
removeAllChildren()
Remove all children from this node. |
|
boolean |
removeChild(PlanNode child)
Remove the node from this node. |
|
PlanNode |
removeFromParent()
Remove this node from its parent, and return the node that used to be the parent of this node. |
|
Object |
removeProperty(Object propertyId)
Remove the node's value for this supplied property. |
|
boolean |
replaceChild(PlanNode child,
PlanNode replacement)
Replace the supplied child with another node. |
|
void |
setParent(PlanNode parent)
Set the parent for this node. |
|
Object |
setProperty(PlanNode.Property propertyId,
Object value)
Set the node's value for the supplied property. |
|
void |
setType(PlanNode.Type type)
Set the type for this node. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PlanNode(PlanNode.Type type)
type
- the type of the node; may not be nullpublic PlanNode(PlanNode.Type type, PlanNode parent)
type
- the type of the node; may not be nullparent
- the parent node, or null if there is no parentpublic PlanNode(PlanNode.Type type, SelectorName... selectors)
type
- the type of the node; may not be nullselectors
- the selectors that should be assigned to this nodepublic PlanNode(PlanNode.Type type, Iterable<SelectorName> selectors)
type
- the type of the node; may not be nullselectors
- the selectors that should be assigned to this nodepublic PlanNode(PlanNode.Type type, PlanNode parent, SelectorName... selectors)
type
- the type of the node; may not be nullparent
- the parent node, or null if there is no parentselectors
- the selectors that should be assigned to this nodepublic PlanNode(PlanNode.Type type, PlanNode parent, Iterable<SelectorName> selectors)
type
- the type of the node; may not be nullparent
- the parent node, or null if there is no parentselectors
- the selectors that should be assigned to this nodeMethod Detail |
---|
public PlanNode.Type getType()
public void setType(PlanNode.Type type)
type
- Sets type to the specified value; may not be nullpublic boolean isNot(PlanNode.Type type)
type
- the type to compare
public boolean isNotOneOf(PlanNode.Type first, PlanNode.Type... rest)
first
- the type to comparerest
- the additional types to compare
public boolean isNotOneOf(Set<PlanNode.Type> types)
types
- the types to compare
public boolean is(PlanNode.Type type)
type
- the type to compare
public boolean isOneOf(PlanNode.Type first, PlanNode.Type... rest)
first
- the type to comparerest
- the additional types to compare
public boolean isOneOf(Set<PlanNode.Type> types)
types
- the types to compare
public boolean isBelow(PlanNode possibleAncestor)
possibleAncestor
- the node that is to be determined if it is an ancestor
public boolean isAbove(PlanNode possibleDescendant)
possibleDescendant
- the node that is to be determined if it is a descendant
public PlanNode getParent()
public void setParent(PlanNode parent)
parent
- the new parent, or null if this node is to have no parentpublic void insertAsParent(PlanNode 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 PlanNode removeFromParent()
extractChild(PlanNode)
,
extractFromParent()
public List<PlanNode> getChildren()
public Iterator<PlanNode> iterator()
This iterator is immutable.
iterator
in interface Iterable<PlanNode>
Iterable.iterator()
public List<PlanNode> removeAllChildren()
public boolean replaceChild(PlanNode child, PlanNode 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 PlanNode getFirstChild()
public PlanNode getLastChild()
public PlanNode getChild(int index)
index
- the index
IndexOutOfBoundsException
- if the index is not valid given the number of childrenpublic void addFirstChild(PlanNode child)
child
- the node that should be added as the first child; may not be nullpublic void addLastChild(PlanNode child)
child
- the node that should be added as the last child; may not be nullpublic void addChildren(Iterable<PlanNode> otherChildren)
otherChildren
- the children to add; may not be nullpublic void addChildren(PlanNode first, PlanNode second)
first
- the first child to addsecond
- the second child to addpublic void addChildren(PlanNode first, PlanNode second, PlanNode third)
first
- the first child to addsecond
- the second child to addthird
- the third child to addpublic boolean removeChild(PlanNode child)
child
- the child node; may not be null
public void extractChild(PlanNode child)
child
- the child to be extracted; may not be null and must have at most 1 childextractFromParent()
public void extractFromParent()
extractChild(PlanNode)
public Set<PlanNode.Property> getPropertyKeys()
public Object getProperty(PlanNode.Property propertyId)
propertyId
- the property identifier
public <ValueType> ValueType getProperty(PlanNode.Property propertyId, Class<ValueType> type)
ValueType
- the type of the value expectedpropertyId
- the property identifiertype
- the class denoting the type of value expected; may not be null
public <ValueType> Collection<ValueType> getPropertyAsCollection(PlanNode.Property propertyId, Class<ValueType> type)
Collection
of the supplied type.
ValueType
- the type of the value expectedpropertyId
- the property identifiertype
- the class denoting the type of value expected; may not be null
public <ValueType> List<ValueType> getPropertyAsList(PlanNode.Property propertyId, Class<ValueType> type)
List
of the supplied type.
ValueType
- the type of the value expectedpropertyId
- the property identifiertype
- the class denoting the type of value expected; may not be null
public Object setProperty(PlanNode.Property propertyId, Object value)
propertyId
- the property identifiervalue
- the value, or null if the property is to be removed
public Object removeProperty(Object propertyId)
propertyId
- the property identifier
public boolean hasProperty(PlanNode.Property propertyId)
propertyId
- the property identifier
public boolean hasCollectionProperty(PlanNode.Property propertyId)
propertyId
- the property identifier
public boolean hasBooleanProperty(PlanNode.Property propertyId)
true
boolean value.
propertyId
- the property identifier
true
public void addSelector(SelectorName symbol)
symbol
- the symbol of the selectorpublic void addSelector(SelectorName first, SelectorName second)
first
- the first symbol to be addedsecond
- the second symbol to be addedpublic void addSelectors(Iterable<SelectorName> names)
names
- the symbols to be addedpublic Set<SelectorName> getSelectors()
public LinkedList<PlanNode> getPathTo(PlanNode descendant)
descendant
- the descendant; may not be null, and must be a descendant of this node
public boolean hasAncestorOfType(PlanNode.Type type)
type
- the type; may not be null
public boolean hasAncestorOfType(PlanNode.Type firstType, PlanNode.Type... additionalTypes)
firstType
- the first type; may not be nulladditionalTypes
- the additional types; may not be null
public boolean hasAncestorOfType(Set<PlanNode.Type> types)
types
- the types; may not be null
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 PlanNode 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 PlanNode cloneWithoutNewParent()
public boolean isSameAs(PlanNode other)
other
- the other plan to compare with this instance
public String getString()
getString
in interface Readable
Readable.getString()
public PlanNode findAncestor(PlanNode.Type typeToFind)
typeToFind
- the type of the node to find; may not be null
public PlanNode findAncestor(PlanNode.Type firstTypeToFind, PlanNode.Type... additionalTypesToFind)
firstTypeToFind
- the first type to find; may not be nulladditionalTypesToFind
- additional types to find; may not be null
public PlanNode findAncestor(Set<PlanNode.Type> typesToFind)
typesToFind
- the set of types to find; may not be null
public List<PlanNode> findAllFirstNodesAtOrBelow(PlanNode.Type typeToFind)
typeToFind
- the type of node to find; may not be null
public List<PlanNode> findAllAtOrBelow()
public List<PlanNode> findAllAtOrBelow(PlanNode.Traversal order)
order
- the order to traverse; may not be null
public List<PlanNode> findAllAtOrBelow(PlanNode.Type typeToFind)
typeToFind
- the type of node to find; may not be null
public List<PlanNode> findAllAtOrBelow(PlanNode.Type firstTypeToFind, PlanNode.Type... additionalTypesToFind)
firstTypeToFind
- the first type of node to find; may not be nulladditionalTypesToFind
- the additional types of node to find; may not be null
public List<PlanNode> findAllAtOrBelow(Set<PlanNode.Type> typesToFind)
typesToFind
- the types of node to find; may not be null
public List<PlanNode> findAllAtOrBelow(PlanNode.Traversal order, PlanNode.Type typeToFind)
order
- the order to traverse; may not be nulltypeToFind
- the type of node to find; may not be null
public List<PlanNode> findAllAtOrBelow(PlanNode.Traversal order, PlanNode.Type firstTypeToFind, PlanNode.Type... additionalTypesToFind)
order
- the order to traverse; may not be nullfirstTypeToFind
- the first type of node to find; may not be nulladditionalTypesToFind
- the additional types of node to find; may not be null
public List<PlanNode> findAllAtOrBelow(PlanNode.Traversal order, Set<PlanNode.Type> typesToFind)
order
- the order to traverse; may not be nulltypesToFind
- the types of node to find; may not be null
public PlanNode findAtOrBelow(PlanNode.Type typeToFind)
typeToFind
- the type of node to find; may not be null
public PlanNode findAtOrBelow(PlanNode.Type firstTypeToFind, PlanNode.Type... additionalTypesToFind)
firstTypeToFind
- the first type of node to find; may not be nulladditionalTypesToFind
- the additional types of node to find; may not be null
public PlanNode findAtOrBelow(Set<PlanNode.Type> typesToFind)
typesToFind
- the types of node to find; may not be null
public PlanNode findAtOrBelow(PlanNode.Traversal order, PlanNode.Type typeToFind)
order
- the order to traverse; may not be nulltypeToFind
- the type of node to find; may not be null
public PlanNode findAtOrBelow(PlanNode.Traversal order, PlanNode.Type firstTypeToFind, PlanNode.Type... additionalTypesToFind)
order
- the order to traverse; may not be nullfirstTypeToFind
- the first type of node to find; may not be nulladditionalTypesToFind
- the additional types of node to find; may not be null
public PlanNode findAtOrBelow(PlanNode.Traversal order, Set<PlanNode.Type> typesToFind)
order
- the order to traverse; may not be nulltypesToFind
- the types of node to find; may not be null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |