Package org.exist.dom

Examples of org.exist.dom.Match


     * @param predicate
     *            the predicate based on which the full-text matches are filtered: If the predicate returns true the
     *            match stays, if not the match is removed.
     */
    public static void filterMatches(final NodeProxy node, final F<Match, Boolean> predicate) {
        Match m = node.getMatches();
        node.setMatches(null);
        while (m != null) {
            if (predicate.f(m).booleanValue())
                node.addMatch(m);
            m = m.getNextMatch();
        }
    }
View Full Code Here


     *            the expression id of the matches to be transformed
     * @return the modified node if at least one match with the supplied expression id was not transformed to null or
     *         null otherwise
     */
    public static NodeProxy fmapOwnMatches(final NodeProxy node, final F<Match, Match> f, int ownExpressionId) {
        Match m = node.getMatches();
        node.setMatches(null);
        boolean ownMatch = false;

        while (m != null) {
            if (m.getContextId() != ownExpressionId) {
                node.addMatch(m);
            } else {
                Match nm = f.f(m);
                if (nm != null) {
                    node.addMatch(nm);
                    ownMatch = true;
                }
            }
View Full Code Here

    }

    private NodeProxy getMatchingNode(NodeProxy headNode, NodeProxy tailNode, final int expressionId) {
        NodeProxy result = null;

        Match match = null;
        boolean found = false;

        for (Match headMatch = headNode.getMatches(); headMatch != null && !found; headMatch = headMatch
            .getNextMatch()) {
View Full Code Here

        NodeValue nodeValue = (NodeValue) args[0].itemAt(0);
        if (nodeValue.getImplementationType() != NodeValue.PERSISTENT_NODE) {
            return Sequence.EMPTY_SEQUENCE;
        }
        NodeProxy proxy = (NodeProxy) nodeValue;
        Match match = proxy.getMatches();
        float score = 0.0f;
        while (match != null) {
            if (match.getIndexId() == LuceneIndex.ID) {
                float currentScore = ((LuceneIndexWorker.LuceneMatch)match).getScore();
                score += currentScore;
            }
            match = match.getNextMatch();
        }
        return new FloatValue(score);
    }
View Full Code Here

     *            another nodeset with matches
     * @return a nodeset containing all matches from the head which are directly followed by matches in the tail
     */
    private NodeProxy getContinuousMatches(final NodeProxy head, final NodeProxy tail) {
        // NodeSet result = new ExtArrayNodeSet();
        Match continuousMatch = null;
       
        Match headMatch = head.getMatches();
        while (headMatch != null && continuousMatch == null) {
            Match tailMatch = tail.getMatches();
            while (tailMatch != null && continuousMatch == null) {
                continuousMatch = headMatch.continuedBy(tailMatch);
                tailMatch = tailMatch.getNextMatch();
              }
            headMatch = headMatch.getNextMatch();
            }
        if (continuousMatch != null) {
            NodeProxies.filterMatches(tail, new F<Match, Boolean>() {
View Full Code Here

    } catch (XMLStreamException e) {
      throw new XPathException(this, ErrorCodes.FOER0000, "Exception caught while reading document");
    }
   
    if (nodeId != null) {
      Match match = new NGramMatch(getContextId(), node.getNodeId(), matchStr);
      match.addOffset(0, matchStr.length());
      node.addMatch(match);
    }
    return node;
  }
View Full Code Here

        return getMatchListener(broker, proxy, null);
    }

    public MatchListener getMatchListener(DBBroker broker, NodeProxy proxy, NGramMatchCallback callback) {
        boolean needToFilter = false;
        Match nextMatch = proxy.getMatches();
        while (nextMatch != null) {
            if (nextMatch.getIndexId() == org.exist.indexing.ngram.NGramIndex.ID) {
                needToFilter = true;
                break;
            }
            nextMatch = nextMatch.getNextMatch();
        }
        if (!needToFilter)
            return null;
        if (matchListener == null)
            matchListener = new NGramMatchListener(broker, proxy);
View Full Code Here

             * in the current node. For example, if the indexed node is &lt;a>abc&lt;b>de&lt;/b></a>
             * and we query for //a[text:ngram-contains(., 'de')]/b, proxy will be a &lt;b> node, but
             * the offsets of the matches are relative to the start of &lt;a>.
             */
            NodeSet ancestors = null;
            Match nextMatch = this.match;
            while (nextMatch != null) {
                if (proxy.getNodeId().isDescendantOf(nextMatch.getNodeId())) {
                    if (ancestors == null)
                        ancestors = new ExtArrayNodeSet();
                    ancestors.add(new NodeProxy(proxy.getDocument(), nextMatch.getNodeId()));
                }
                nextMatch = nextMatch.getNextMatch();
            }
            if (ancestors != null && !ancestors.isEmpty()) {
                for (NodeProxy p : ancestors) {
                    int startOffset = 0;
                    try {
View Full Code Here

            }
        }

        @Override
        public void startElement(QName qname, AttrList attribs) throws SAXException {
            Match nextMatch = match;
            // check if there are any matches in the current element
            // if yes, push a NodeOffset object to the stack to track
            // the node contents
            while (nextMatch != null) {
                if (nextMatch.getNodeId().equals(getCurrentNode().getNodeId())) {
                    if (offsetStack == null)
                        offsetStack = new Stack<NodeOffset>();
                    offsetStack.push(new NodeOffset(nextMatch.getNodeId()));
                    break;
                }
                nextMatch = nextMatch.getNextMatch();
            }
            super.startElement(qname, attribs);
        }
View Full Code Here

            super.startElement(qname, attribs);
        }

        @Override
        public void endElement(QName qname) throws SAXException {
            Match nextMatch = match;
            // check if we need to pop the stack
            while (nextMatch != null) {
                if (nextMatch.getNodeId().equals(getCurrentNode().getNodeId())) {
                    offsetStack.pop();
                    break;
                }
                nextMatch = nextMatch.getNextMatch();
            }
            super.endElement(qname);
        }
View Full Code Here

TOP

Related Classes of org.exist.dom.Match

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.