Interface ContextSearchNode
-
- All Known Implementing Classes:
ContextSearchNodeReference,ContextSearchProgress,ContextSearchTree,DefaultContextSearchNode
public interface ContextSearchNodeRepresents single search request node.Searching for contexts is performed by traversing through context tree in regards to
merge-byattributes, obligatory merge attributes and/or appropriateCockpitConfigurationContextStrategy. Each step down the tree means that any contexts found are a little bit less relevant to actual request.This interface represents such single step of search
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<ContextSearchNode>DEC_RELEVANCE_COMPARATORstatic java.util.Comparator<ContextSearchNode>INC_RELEVANCE_COMPARATOR
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddChild(ContextSearchNode child)Adds new child search node.booleanaddNodeResult(Context result)Adds new search result to current node.voidcommit()Marks node as committed.java.util.Collection<ContextSearchNode>getChildren()Gets all child search nodes.intgetLevel()Return a level on which the node is situated - minimum number of steps needed to come from original request to this.java.util.List<Context>getNodeResult()Gets search results bound to this node.NodeRelevancegetNotEmptyRelevance()Gets highest relevance of all children with any result in regards to original requestContextSearchNodegetParent()Gets parent search node.NodeRelevancegetRelevance()Gets relevance of this node in regards to original requestjava.util.List<Context>getResult()Gets search results bound to this node and its children.ContextSearchNeedlegetSearchNeedle()Search request represented by this nodebooleanisCommitted()Checks if node is committed.booleanisEgalitarian()Checks how node is interpreting children results.voidremoveChild(ContextSearchNode child)Removes a child search node.voidsetEgalitarian(boolean egalitarian)Informs a node how it should interpret its children's results.voidsetParent(ContextSearchNode parent)Updates parent search node.voidtoXML(java.io.OutputStream os)Writes XML representation of search node to provided stream
-
-
-
Field Detail
-
INC_RELEVANCE_COMPARATOR
static final java.util.Comparator<ContextSearchNode> INC_RELEVANCE_COMPARATOR
-
DEC_RELEVANCE_COMPARATOR
static final java.util.Comparator<ContextSearchNode> DEC_RELEVANCE_COMPARATOR
-
-
Method Detail
-
getRelevance
NodeRelevance getRelevance()
Gets relevance of this node in regards to original request- Returns:
- node relevance
-
getNotEmptyRelevance
NodeRelevance getNotEmptyRelevance()
Gets highest relevance of all children with any result in regards to original request- Returns:
- node's relevance if any result is bound to it, highest relevance of children with result or
nullif no result is bound to this branch
-
getLevel
int getLevel()
Return a level on which the node is situated - minimum number of steps needed to come from original request to this.- Returns:
0for root level and 1 more for each level of relevance
-
getSearchNeedle
ContextSearchNeedle getSearchNeedle()
Search request represented by this node- Returns:
- search request or
nullif node is only container for other requests
-
isEgalitarian
boolean isEgalitarian()
Checks how node is interpreting children results. If a node is egalitarian, then result of all children are considered as a result of this node. Otherwise only a child with highest relevance is taken under consideration.- Returns:
trueif node is egalitarian- See Also:
getNotEmptyRelevance(),getResult()
-
setEgalitarian
void setEgalitarian(boolean egalitarian) throws java.lang.IllegalStateExceptionInforms a node how it should interpret its children's results. If a node is egalitarian, then result of all children are considered as a result of this node. Otherwise only a child with highest relevance is taken under consideration.- Parameters:
egalitarian-trueif node should be egalitarian- Throws:
java.lang.IllegalStateException- thrown if node is already committed and should not be changed
-
addNodeResult
boolean addNodeResult(Context result) throws java.lang.IllegalStateException
Adds new search result to current node.- Parameters:
result- context that matches node's request- Returns:
trueif result has not yet been known and changed nodes result set.- Throws:
java.lang.IllegalStateException- thrown if node is already committed and should not be changed
-
getNodeResult
java.util.List<Context> getNodeResult()
Gets search results bound to this node.- Returns:
- list of contexts that matches this node's needle
-
getResult
java.util.List<Context> getResult()
Gets search results bound to this node and its children. Result should be ordered by their relevance (from most relevant to least).- Returns:
- list of contexts that matches all requests in this branch
- See Also:
isEgalitarian()
-
getParent
ContextSearchNode getParent()
Gets parent search node.Parent node is a search needle that caused search represented by this node.
- Returns:
- parent search node or
nullif it is root search
-
setParent
void setParent(ContextSearchNode parent) throws java.lang.IllegalStateException
Updates parent search node.Parent node is a search needle that caused search represented by this node.
- Parameters:
parent- parent search node ornullif it is root search- Throws:
java.lang.IllegalStateException- thrown if node is already committed and should not be changed
-
addChild
void addChild(ContextSearchNode child) throws java.lang.IllegalStateException
Adds new child search node.A child search node is a search that is related to this node and comes from its dependencies.
- Parameters:
child- child node- Throws:
java.lang.IllegalStateException- thrown if node is already committed and should not be changed
-
removeChild
void removeChild(ContextSearchNode child) throws java.lang.IllegalStateException
Removes a child search node.A child search node is a search that is related to this node and comes from its dependencies.
- Parameters:
child- child node- Throws:
java.lang.IllegalStateException- thrown if node is already committed and should not be changed
-
getChildren
java.util.Collection<ContextSearchNode> getChildren()
Gets all child search nodes.A child search node is a search that is related to this node and comes from its dependencies.
- Returns:
- collection of child nodes
-
toXML
void toXML(java.io.OutputStream os) throws java.io.IOExceptionWrites XML representation of search node to provided stream- Parameters:
os- destination stream- Throws:
java.io.IOException- thrown, if there were problems during writing to stream
-
isCommitted
boolean isCommitted()
Checks if node is committed.Search node should be committed after all searches bound to this node has been performed, all results has been assigned and nothing should be changed regarding this node and all its children.
Committed node becomes immutable and any action that may change it's result will result in
IllegalStateException.- Returns:
trueif search bound to this node has been performed and finished
-
commit
void commit()
Marks node as committed.Search node should be committed after all searches bound to this node has been performed, all results has been assigned and nothing should be changed regarding this node and all its children.
Committed node becomes immutable and any action that may change it's result will result in
IllegalStateException.
-
-