Class ContextSearchNodeReference

  • All Implemented Interfaces:
    ContextSearchNode

    public class ContextSearchNodeReference
    extends java.lang.Object
    implements ContextSearchNode
    Represents a reference to other search node.

    Searching for contexts is performed by traversing through context tree in regards to merge-by attributes, obligatory merge attributes and/or appropriate CockpitConfigurationContextStrategy. Each step down the tree means that any contexts found are a little bit less relevant to actual request.

    During this traverse it is possible that some searches are required more then once. To avoid performing them once again, the reference may be put into tree instead.

    • Constructor Detail

      • ContextSearchNodeReference

        public ContextSearchNodeReference​(ContextSearchNode reference)
        Parameters:
        reference - search node to be referenced
    • Method Detail

      • getNotEmptyRelevance

        public NodeRelevance getNotEmptyRelevance()
        Description copied from interface: ContextSearchNode
        Gets highest relevance of all children with any result in regards to original request
        Specified by:
        getNotEmptyRelevance in interface ContextSearchNode
        Returns:
        node's relevance if any result is bound to it, highest relevance of children with result or null if no result is bound to this branch
      • getLevel

        public int getLevel()
        Description copied from interface: ContextSearchNode
        Return a level on which the node is situated - minimum number of steps needed to come from original request to this.
        Specified by:
        getLevel in interface ContextSearchNode
        Returns:
        0 for root level and 1 more for each level of relevance
      • setEgalitarian

        public void setEgalitarian​(boolean egalitarian)
        Description copied from interface: ContextSearchNode
        Informs 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.
        Specified by:
        setEgalitarian in interface ContextSearchNode
        Parameters:
        egalitarian - true if node should be egalitarian
      • addNodeResult

        public boolean addNodeResult​(Context result)
        Description copied from interface: ContextSearchNode
        Adds new search result to current node.
        Specified by:
        addNodeResult in interface ContextSearchNode
        Parameters:
        result - context that matches node's request
        Returns:
        true if result has not yet been known and changed nodes result set.
      • getNodeResult

        public java.util.List<Context> getNodeResult()
        Description copied from interface: ContextSearchNode
        Gets search results bound to this node.
        Specified by:
        getNodeResult in interface ContextSearchNode
        Returns:
        list of contexts that matches this node's needle
      • getParent

        public ContextSearchNode getParent()
        Description copied from interface: ContextSearchNode
        Gets parent search node.

        Parent node is a search needle that caused search represented by this node.

        Specified by:
        getParent in interface ContextSearchNode
        Returns:
        parent search node or null if it is root search
      • setParent

        public void setParent​(ContextSearchNode parent)
        Description copied from interface: ContextSearchNode
        Updates parent search node.

        Parent node is a search needle that caused search represented by this node.

        Specified by:
        setParent in interface ContextSearchNode
        Parameters:
        parent - parent search node or null if it is root search
      • addChild

        public void addChild​(ContextSearchNode child)
        Description copied from interface: ContextSearchNode
        Adds new child search node.

        A child search node is a search that is related to this node and comes from its dependencies.

        Specified by:
        addChild in interface ContextSearchNode
        Parameters:
        child - child node
      • removeChild

        public void removeChild​(ContextSearchNode child)
        Description copied from interface: ContextSearchNode
        Removes a child search node.

        A child search node is a search that is related to this node and comes from its dependencies.

        Specified by:
        removeChild in interface ContextSearchNode
        Parameters:
        child - child node
      • getChildren

        public java.util.Collection<ContextSearchNode> getChildren()
        Description copied from interface: ContextSearchNode
        Gets all child search nodes.

        A child search node is a search that is related to this node and comes from its dependencies.

        Specified by:
        getChildren in interface ContextSearchNode
        Returns:
        collection of child nodes
      • toXML

        public void toXML​(java.io.OutputStream os)
                   throws java.io.IOException
        Description copied from interface: ContextSearchNode
        Writes XML representation of search node to provided stream
        Specified by:
        toXML in interface ContextSearchNode
        Parameters:
        os - destination stream
        Throws:
        java.io.IOException - thrown, if there were problems during writing to stream
      • commit

        public void commit()
        Description copied from interface: ContextSearchNode
        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.

        Specified by:
        commit in interface ContextSearchNode
      • isCommitted

        public boolean isCommitted()
        Description copied from interface: ContextSearchNode
        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.

        Specified by:
        isCommitted in interface ContextSearchNode
        Returns:
        true if search bound to this node has been performed and finished
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object