Interface ContextSearchNode

    • 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 null if 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:
        0 for root level and 1 more for each level of relevance
      • getSearchNeedle

        ContextSearchNeedle getSearchNeedle()
        Search request represented by this node
        Returns:
        search request or null if 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:
        true if node is egalitarian
        See Also:
        getNotEmptyRelevance(), getResult()
      • setEgalitarian

        void setEgalitarian​(boolean egalitarian)
                     throws java.lang.IllegalStateException
        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.
        Parameters:
        egalitarian - true if 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:
        true if 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 null if 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 or null if 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.IOException
        Writes 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:
        true if 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.