Package org.apache.cayenne.query
Class PrefetchTreeNode
java.lang.Object
org.apache.cayenne.query.PrefetchTreeNode
- All Implemented Interfaces:
- Serializable,- XMLSerializable
Defines a node in a prefetch tree.
- Since:
- 1.2
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Collection<PrefetchTreeNode>static final intstatic final intprotected Stringprotected Stringstatic final intprotected Stringprotected PrefetchTreeNodeprotected booleanprotected intstatic final int
- 
Constructor SummaryConstructorsModifierConstructorDescriptionCreates a root node of the prefetch tree.protectedPrefetchTreeNode(PrefetchTreeNode parent, String name) Creates a phantom PrefetchTreeNode, initializing it with parent node and a name of a relationship segment connecting this node with the parent.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddChild(PrefetchTreeNode child) Adds a "path" with specified semantics to this prefetch node.addPath(CayennePath path) Adds a "path" with specified semantics to this prefetch node.Returns a subset of nodes with "joint" semantics that are to be prefetched in the same query as the current node.Returns a clone of subtree that includes all joint children starting from this node itself and till the first occurrence of non-joint nodeReturns a collection of PrefetchTreeNodes with disjoint semanticsReturns a collection of PrefetchTreeNodes with disjoint semantics.voidencodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) Prints itself as XML to the provided XMLEncoder.protected PrefetchTreeNodeReturns an unmodifiable collection of children.getName()Looks up an existing node in the tree described by the dot-separated path.getNode(CayennePath path) Looks up an existing node in the tree described by the path.getPath()Returns full prefetch path, that is a dot separated String of node names starting from root and up to and including this node.getPath(PrefetchTreeNode upTillParent) Returns full prefetch path, that is a dot separated String of node names starting from root and up to and including this node.getRoot()Returns the root of the node tree.intbooleanbooleanbooleanbooleanbooleanReturns a collection of PrefetchTreeNodes in this tree with joint semantics.voidmerge(PrefetchTreeNode node) MergesPrefetchTreeNodeinto the current prefetch tree, cloning the nodes added to this tree.Returns a collection of PrefetchTreeNodes that are not phantoms.protected Objectprotected voidremoveChild(String segment) voidremoveChild(PrefetchTreeNode child) voidremovePath(String path) Removes or makes phantom a node defined by this path.voidsetEjbqlPathEntityId(String ejbqlPathEntityId) voidsetEntityName(String entityName) voidsetPhantom(boolean phantom) voidsetSemantics(int semantics) voidtraverse(PrefetchProcessor processor) Traverses the tree depth-first, invoking callback methods of the processor when passing through the nodes.static PrefetchTreeNodeCreates and returns a prefetch tree spanning a single path.static PrefetchTreeNodewithPath(CayennePath path, int semantics) Creates and returns a prefetch tree spanning a single path.
- 
Field Details- 
UNDEFINED_SEMANTICSpublic static final int UNDEFINED_SEMANTICS- See Also:
 
- 
JOINT_PREFETCH_SEMANTICSpublic static final int JOINT_PREFETCH_SEMANTICS- See Also:
 
- 
DISJOINT_PREFETCH_SEMANTICSpublic static final int DISJOINT_PREFETCH_SEMANTICS- See Also:
 
- 
DISJOINT_BY_ID_PREFETCH_SEMANTICSpublic static final int DISJOINT_BY_ID_PREFETCH_SEMANTICS- See Also:
 
- 
name
- 
phantomprotected boolean phantom
- 
semanticsprotected int semantics
- 
ejbqlPathEntityId
- 
entityName
- 
parent
- 
children
 
- 
- 
Constructor Details- 
PrefetchTreeNodepublic PrefetchTreeNode()Creates a root node of the prefetch tree. Children can be added to the parent by calling "addPath".
- 
PrefetchTreeNodeCreates a phantom PrefetchTreeNode, initializing it with parent node and a name of a relationship segment connecting this node with the parent.
 
- 
- 
Method Details- 
withPathCreates and returns a prefetch tree spanning a single path. The tree is made of phantom nodes, up to the leaf node, which is non-phantom and has specified semantics.- Since:
- 4.0
 
- 
withPathCreates and returns a prefetch tree spanning a single path. The tree is made of phantom nodes, up to the leaf node, which is non-phantom and has specified semantics.- Since:
- 5.0
 
- 
encodeAsXMLDescription copied from interface:XMLSerializablePrints itself as XML to the provided XMLEncoder.- Specified by:
- encodeAsXMLin interface- XMLSerializable
 
- 
getRootReturns the root of the node tree. Root is the topmost parent node that itself has no parent set.
- 
getPathReturns full prefetch path, that is a dot separated String of node names starting from root and up to and including this node.
 Note that root "name" is considered to be an empty string.- Returns:
- path from the root
- Since:
- 5.0 returns CayennePathinstead of a plainString
 
- 
getPathReturns full prefetch path, that is a dot separated String of node names starting from root and up to and including this node.
 Note that root "name" is considered to be an empty string.- Parameters:
- upTillParent- parent we need to stop at, if- nullreturns path up to the root
- Returns:
- path from the specified parent node
- Since:
- 5.0 returns CayennePathinstead of a plainString
 
- 
adjacentJointNodesReturns a subset of nodes with "joint" semantics that are to be prefetched in the same query as the current node. Result excludes this node, regardless of its semantics.
- 
jointNodesReturns a collection of PrefetchTreeNodes in this tree with joint semantics.
- 
disjointNodesReturns a collection of PrefetchTreeNodes with disjoint semantics.
- 
disjointByIdNodesReturns a collection of PrefetchTreeNodes with disjoint semantics- Since:
- 3.1
 
- 
nonPhantomNodesReturns a collection of PrefetchTreeNodes that are not phantoms.
- 
cloneJointSubtreeReturns a clone of subtree that includes all joint children starting from this node itself and till the first occurrence of non-joint node- Since:
- 3.1
 
- 
traverseTraverses the tree depth-first, invoking callback methods of the processor when passing through the nodes.
- 
getNodeLooks up an existing node in the tree described by the path. Will return null if no matching child exists.- Parameters:
- path- expression to look up node for
- Returns:
- found node or null if non exists
- Since:
- 5.0
 
- 
getNodeLooks up an existing node in the tree described by the dot-separated path. Will return null if no matching child exists.- Parameters:
- path- expression to look up node for
- Returns:
- found node or null if non exists
 
- 
addPathAdds a "path" with specified semantics to this prefetch node. All yet non-existent nodes in the created path will be marked as phantom.- Returns:
- the last segment in the created path.
- Since:
- 5.0
 
- 
addPathAdds a "path" with specified semantics to this prefetch node. All yet non-existent nodes in the created path will be marked as phantom.- Returns:
- the last segment in the created path.
 
- 
mergeMergesPrefetchTreeNodeinto the current prefetch tree, cloning the nodes added to this tree. Merged nodes semantics (if defined) and non-phantom status are applied to the nodes of this tree.- Parameters:
- node- a root node of a tree to merge into this tree. The path of the merged node within the resulting tree is determined from its name.
- Since:
- 4.0
 
- 
removePathRemoves or makes phantom a node defined by this path. If the node for this path doesn't have any children, it is removed, otherwise it is made phantom.
- 
addChild
- 
removeChild
- 
removeChild
- 
getChild
- 
getParent
- 
getChildrenReturns an unmodifiable collection of children.
- 
hasChildrenpublic boolean hasChildren()
- 
getName
- 
isPhantompublic boolean isPhantom()
- 
setPhantompublic void setPhantom(boolean phantom) 
- 
getSemanticspublic int getSemantics()
- 
setSemanticspublic void setSemantics(int semantics) 
- 
isJointPrefetchpublic boolean isJointPrefetch()
- 
isDisjointPrefetchpublic boolean isDisjointPrefetch()
- 
isDisjointByIdPrefetchpublic boolean isDisjointByIdPrefetch()
- 
getEjbqlPathEntityId
- 
setEjbqlPathEntityId
- 
getEntityName
- 
setEntityName
- 
readResolve- Throws:
- ObjectStreamException
 
 
-