Package org.exist.dom

Examples of org.exist.dom.Match


          if(Type.subTypeOf(next.getType(), Type.NODE)) {
              final NodeValue nv = (NodeValue)next;
              if(nv.getImplementationType() != NodeValue.PERSISTENT_NODE)
                {throw new XPathException(this, getName() + " cannot be applied to in-memory nodes.");}
              final NodeProxy np = (NodeProxy)nv;
              Match match = np.getMatches();
              while (match != null) {
                if (match.getNodeId().isDescendantOrSelfOf(np.getNodeId())) {
                  count += match.getFrequency();
                }
                match = match.getNextMatch();
           }
          }
      }
      result = new IntegerValue(count);
    }
View Full Code Here


    private final void processText(MemTreeBuilder builder, NodeProxy proxy, Sequence result,
            FunctionReference callback, Sequence extraArgs)
    throws DOMException, XPathException {
        final TextImpl text = (TextImpl) proxy.getNode();
        final Match match = proxy.getMatches();
        int nodeNr;
        if (match == null) {
            nodeNr = builder.characters(text.getXMLString());
            result.add(builder.getDocument().getNode(nodeNr));
        } else {
            List<Match.Offset> offsets = null;
            Match next = match;
            while (next != null) {
                if (next.getNodeId().equals(text.getNodeId())) {
                    if (offsets == null)
                        {offsets = new ArrayList<Match.Offset>();}
                    final int freq = next.getFrequency();
                    for (int i = 0; i < freq; i++) {
                        offsets.add(next.getOffset(i));
                    }
                }
                next = next.getNextMatch();
            }
           
            if (offsets != null) {
                FastQSort.sort(offsets, 0, offsets.size() - 1);
               
View Full Code Here

      if(val.getImplementationType() == NodeValue.IN_MEMORY_NODE)
        {throw new XPathException(this, getName() + " cannot be applied to in-memory nodes.");}
      final NodeProxy proxy = (NodeProxy)val;  // this is a persistent node, so casting is safe
 
      int freq = 0;
      Match nextMatch = proxy.getMatches();
      // we just count the number of distinct terms matched
      while(nextMatch != null) {
        freq += nextMatch.getFrequency();
        nextMatch = nextMatch.getNextMatch();
      }
      result = new DoubleValue(freq);
    }
   
        if (context.getProfiler().isEnabled())
View Full Code Here

    private final String processAttribute(String data, NodeId nodeId, Match match) {
        if (match == null) {return data;}
        // prepare a regular expression to mark match-terms
        StringBuilder expr = null;
        Match next = match;
        while (next != null) {
            if (next.getNodeId().equals(nodeId)) {
                if (expr == null) {
                    expr = new StringBuilder();
                    expr.append("\\b(");
                }
                if (expr.length() > 5) {expr.append('|');}
                expr.append("");
            }
            next = next.getNextMatch();
        }
        if (expr != null) {
            expr.append(")\\b");
            final Pattern pattern = Pattern.compile(expr.toString(), Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
            final Matcher matcher = pattern.matcher(data);
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.