Package org.apache.cayenne.query
Class PrefetchTreeNode
java.lang.Object
org.apache.cayenne.query.PrefetchTreeNode
- All Implemented Interfaces:
Serializable,XMLSerializable
public class PrefetchTreeNode extends Object implements Serializable, XMLSerializable
Defines a node in a prefetch tree.
- Since:
- 1.2
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected Collection<PrefetchTreeNode>childrenstatic intDISJOINT_BY_ID_PREFETCH_SEMANTICSstatic intDISJOINT_PREFETCH_SEMANTICSprotected StringejbqlPathEntityIdprotected StringentityNamestatic intJOINT_PREFETCH_SEMANTICSprotected Stringnameprotected PrefetchTreeNodeparentprotected booleanphantomprotected intsemanticsstatic intUNDEFINED_SEMANTICS -
Constructor Summary
Constructors Modifier Constructor Description PrefetchTreeNode()Creates 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 Summary
Modifier and Type Method Description voidaddChild(PrefetchTreeNode child)PrefetchTreeNodeaddPath(String path)Adds a "path" with specified semantics to this prefetch node.Collection<PrefetchTreeNode>adjacentJointNodes()Returns a subset of nodes with "joint" semantics that are to be prefetched in the same query as the current node.PrefetchTreeNodecloneJointSubtree()Returns a clone of subtree that includes all joint children starting from this node itself and till the first occurrence of non-joint nodeCollection<PrefetchTreeNode>disjointByIdNodes()Returns a collection of PrefetchTreeNodes with disjoint semanticsCollection<PrefetchTreeNode>disjointNodes()Returns a collection of PrefetchTreeNodes with disjoint semantics.voidencodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)Prints itself as XML to the provided XMLEncoder.protected PrefetchTreeNodegetChild(String segment)Collection<PrefetchTreeNode>getChildren()Returns an unmodifiable collection of children.StringgetEjbqlPathEntityId()StringgetEntityName()StringgetName()PrefetchTreeNodegetNode(String path)Looks up an existing node in the tree desribed by the dot-separated path.PrefetchTreeNodegetParent()StringgetPath()Returns full prefetch path, that is a dot separated String of node names starting from root and up to and including this node.StringgetPath(PrefetchTreeNode upTillParent)PrefetchTreeNodegetRoot()Returns the root of the node tree.intgetSemantics()booleanhasChildren()booleanisDisjointByIdPrefetch()booleanisDisjointPrefetch()booleanisJointPrefetch()booleanisPhantom()Collection<PrefetchTreeNode>jointNodes()Returns 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.Collection<PrefetchTreeNode>nonPhantomNodes()Returns a collection of PrefetchTreeNodes that are not phantoms.protected ObjectreadResolve()protected 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 PrefetchTreeNodewithPath(String path, int semantics)Creates and returns a prefetch tree spanning a single path.
-
Field Details
-
UNDEFINED_SEMANTICS
public static final int UNDEFINED_SEMANTICS- See Also:
- Constant Field Values
-
JOINT_PREFETCH_SEMANTICS
public static final int JOINT_PREFETCH_SEMANTICS- See Also:
- Constant Field Values
-
DISJOINT_PREFETCH_SEMANTICS
public static final int DISJOINT_PREFETCH_SEMANTICS- See Also:
- Constant Field Values
-
DISJOINT_BY_ID_PREFETCH_SEMANTICS
public static final int DISJOINT_BY_ID_PREFETCH_SEMANTICS- See Also:
- Constant Field Values
-
name
-
phantom
protected boolean phantom -
semantics
protected int semantics -
ejbqlPathEntityId
-
entityName
-
parent
-
children
-
-
Constructor Details
-
PrefetchTreeNode
public PrefetchTreeNode()Creates a root node of the prefetch tree. Children can be added to the parent by calling "addPath". -
PrefetchTreeNode
Creates a phantom PrefetchTreeNode, initializing it with parent node and a name of a relationship segment connecting this node with the parent.
-
-
Method Details
-
withPath
Creates 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
-
encodeAsXML
Description copied from interface:XMLSerializablePrints itself as XML to the provided XMLEncoder.- Specified by:
encodeAsXMLin interfaceXMLSerializable
-
getRoot
Returns the root of the node tree. Root is the topmost parent node that itself has no parent set. -
getPath
Returns 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. -
getPath
-
adjacentJointNodes
Returns 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. -
jointNodes
Returns a collection of PrefetchTreeNodes in this tree with joint semantics. -
disjointNodes
Returns a collection of PrefetchTreeNodes with disjoint semantics. -
disjointByIdNodes
Returns a collection of PrefetchTreeNodes with disjoint semantics- Since:
- 3.1
-
nonPhantomNodes
Returns a collection of PrefetchTreeNodes that are not phantoms. -
cloneJointSubtree
Returns 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
-
traverse
Traverses the tree depth-first, invoking callback methods of the processor when passing through the nodes. -
getNode
Looks up an existing node in the tree desribed by the dot-separated path. Will return null if no matching child exists. -
addPath
Adds 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.
-
merge
MergesPrefetchTreeNodeinto 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
-
removePath
Removes 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
-
getChildren
Returns an unmodifiable collection of children. -
hasChildren
public boolean hasChildren() -
getName
-
isPhantom
public boolean isPhantom() -
setPhantom
public void setPhantom(boolean phantom) -
getSemantics
public int getSemantics() -
setSemantics
public void setSemantics(int semantics) -
isJointPrefetch
public boolean isJointPrefetch() -
isDisjointPrefetch
public boolean isDisjointPrefetch() -
isDisjointByIdPrefetch
public boolean isDisjointByIdPrefetch() -
getEjbqlPathEntityId
-
setEjbqlPathEntityId
-
getEntityName
-
setEntityName
-
readResolve
- Throws:
ObjectStreamException
-