@NotThreadSafe public final class PlanNode extends Object implements Iterable<PlanNode>, Readable, Cloneable, Serializable
Modifier and Type | Class and Description |
---|---|
static interface |
PlanNode.Operation |
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
void |
apply(PlanNode.Traversal order,
PlanNode.Operation operation)
Walk the plan tree starting in the specified traversal order, and apply the supplied operation to every plan node.
|
void |
apply(PlanNode.Traversal order,
PlanNode.Operation operation,
PlanNode.Type type)
Walk the plan tree starting in the specified traversal order, and apply the supplied operation to every plan node with a
type that matches the given type.
|
void |
apply(PlanNode.Traversal order,
PlanNode.Operation operation,
PlanNode.Type firstType,
PlanNode.Type... additionalTypes)
Walk the plan tree starting in the specified traversal order, and apply the supplied operation to every plan node that is
one of the supplied types.
|
void |
apply(PlanNode.Traversal order,
PlanNode.Operation operation,
Set<PlanNode.Type> types)
Walk the plan tree starting in the specified traversal order, and apply the supplied operation to every plan node that is
one of the supplied types.
|
protected void |
applyLevelOrder(PlanNode.Traversal order,
PlanNode.Operation operation) |
void |
applyToAncestors(PlanNode.Operation operation)
Apply the operation to all ancestor nodes.
|
void |
applyToAncestorsUpTo(PlanNode.Type stopType,
PlanNode.Operation operation)
Apply the operation to all ancestor nodes below a node of the given type.
|
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.
|
<ValueType> |
getProperty(PlanNode.Property propertyId,
Class<ValueType> type)
Get the node's value for this supplied property, casting the result to the supplied type.
|
<ValueType> |
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. |
<ValueType> |
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.
|
int |
hashCode() |
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() |
void |
orderChildren(Comparator<PlanNode> comparator) |
void |
orderChildren(PlanNode.Type type,
Comparator<PlanNode> comparator) |
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.
|
boolean |
replaceSelector(SelectorName original,
SelectorName replacement)
Replace this plan's use of the named selector with the replacement. to this plan 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() |
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
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 nodepublic 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 comparepublic boolean isNotOneOf(PlanNode.Type first, PlanNode.Type... rest)
first
- the type to comparerest
- the additional types to comparepublic boolean isNotOneOf(Set<PlanNode.Type> types)
types
- the types to comparepublic boolean is(PlanNode.Type type)
type
- the type to comparepublic boolean isOneOf(PlanNode.Type first, PlanNode.Type... rest)
first
- the type to comparerest
- the additional types to comparepublic boolean isOneOf(Set<PlanNode.Type> types)
types
- the types to comparepublic boolean isBelow(PlanNode possibleAncestor)
possibleAncestor
- the node that is to be determined if it is an ancestorpublic boolean isAbove(PlanNode possibleDescendant)
possibleDescendant
- the node that is to be determined if it is a descendantpublic 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 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 nullpublic int getChildCount()
public PlanNode getFirstChild()
public PlanNode getLastChild()
public PlanNode getChild(int index)
index
- the indexIndexOutOfBoundsException
- 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 nullpublic 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 identifierpublic <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 nullpublic <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 nullpublic <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 nullpublic Object setProperty(PlanNode.Property propertyId, Object value)
propertyId
- the property identifiervalue
- the value, or null if the property is to be removedpublic Object removeProperty(Object propertyId)
propertyId
- the property identifierpublic boolean hasProperty(PlanNode.Property propertyId)
propertyId
- the property identifierpublic boolean hasCollectionProperty(PlanNode.Property propertyId)
propertyId
- the property identifierpublic boolean hasBooleanProperty(PlanNode.Property propertyId)
true
boolean value.propertyId
- the property identifiertrue
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 boolean replaceSelector(SelectorName original, SelectorName replacement)
original
- the selector name to be replacedreplacement
- the selector name to replace the originalpublic Set<SelectorName> getSelectors()
public LinkedList<PlanNode> getPathTo(PlanNode descendant)
descendant
- the descendant; may not be null, and must be a descendant of this nodepublic boolean hasAncestorOfType(PlanNode.Type type)
type
- the type; may not be nullpublic boolean hasAncestorOfType(PlanNode.Type firstType, PlanNode.Type... additionalTypes)
firstType
- the first type; may not be nulladditionalTypes
- the additional types; may not be nullpublic boolean hasAncestorOfType(Set<PlanNode.Type> types)
types
- the types; may not be nullpublic 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 instancepublic String getString()
Readable
public PlanNode findAncestor(PlanNode.Type typeToFind)
typeToFind
- the type of the node to find; may not be nullpublic 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 nullpublic PlanNode findAncestor(Set<PlanNode.Type> typesToFind)
typesToFind
- the set of types to find; may not be nullpublic List<PlanNode> findAllFirstNodesAtOrBelow(PlanNode.Type typeToFind)
typeToFind
- the type of node to find; may not be nullpublic void apply(PlanNode.Traversal order, PlanNode.Operation operation, PlanNode.Type type)
order
- the order in which the subtree should be traversed; may not be nulloperation
- the operation that should be applied; may not be nulltype
- the type of node to which the operation should be applied; may not be nullpublic void apply(PlanNode.Traversal order, PlanNode.Operation operation, PlanNode.Type firstType, PlanNode.Type... additionalTypes)
order
- the order in which the subtree should be traversed; may not be nulloperation
- the operation that should be applied; may not be nullfirstType
- the first type of node to which the operation should be applied; may not be nulladditionalTypes
- the additional types of nodes to which the operation should be applied; may not be nullpublic void apply(PlanNode.Traversal order, PlanNode.Operation operation, Set<PlanNode.Type> types)
order
- the order in which the subtree should be traversed; may not be nulloperation
- the operation that should be applied; may not be nulltypes
- the types of nodes to which the operation should be applied; may not be nullpublic void apply(PlanNode.Traversal order, PlanNode.Operation operation)
order
- the order in which the subtree should be traversed; may not be nulloperation
- the operation that should be applied; may not be nullprotected void applyLevelOrder(PlanNode.Traversal order, PlanNode.Operation operation)
public void applyToAncestorsUpTo(PlanNode.Type stopType, PlanNode.Operation operation)
stopType
- the type of node that should not be included in the results; may not be nulloperation
- the operation to apply to each of the ancestor nodes below the given type; may not be nullpublic void applyToAncestors(PlanNode.Operation operation)
operation
- the operation to apply to each of the ancestor nodes; may not be nullpublic List<PlanNode> findAllAtOrBelow()
public List<PlanNode> findAllAtOrBelow(PlanNode.Traversal order)
order
- the order to traverse; may not be nullpublic List<PlanNode> findAllAtOrBelow(PlanNode.Type typeToFind)
typeToFind
- the type of node to find; may not be nullpublic 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 nullpublic List<PlanNode> findAllAtOrBelow(Set<PlanNode.Type> typesToFind)
typesToFind
- the types of node to find; may not be nullpublic 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 nullpublic 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 nullpublic 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 nullpublic PlanNode findAtOrBelow(PlanNode.Type typeToFind)
typeToFind
- the type of node to find; may not be nullpublic 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 nullpublic PlanNode findAtOrBelow(Set<PlanNode.Type> typesToFind)
typesToFind
- the types of node to find; may not be nullpublic 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 nullpublic 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 nullpublic 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 nullpublic void orderChildren(Comparator<PlanNode> comparator)
public void orderChildren(PlanNode.Type type, Comparator<PlanNode> comparator)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.