Package org.exist.dom

Examples of org.exist.dom.ExtArrayNodeSet$CollectionIterator


  }

  protected Sequence nodeSetCompare(NodeSet nodes, Sequence contextSequence) throws XPathException {   
        if (context.getProfiler().isEnabled())
            {context.getProfiler().message(this, Profiler.OPTIMIZATION_FLAGS, "OPTIMIZATION CHOICE", "nodeSetCompare");}   
    final NodeSet result = new ExtArrayNodeSet();
        final Collator collator = getCollator(contextSequence);
        if (contextSequence != null && !contextSequence.isEmpty()) {
            for (final Iterator<NodeProxy> i = nodes.iterator(); i.hasNext();) {
                final NodeProxy current = i.next();
                ContextItem context = current.getContext();
                if (context==null) {
                   throw new XPathException(this,"Context is missing for node set comparison");
                }
                do {
                    final AtomicValue lv = current.atomize();
                    final Sequence rs = getRight().eval(context.getNode().toSequence());                   
                    if (!rs.hasOne())
                        {throw new XPathException(this,
                                "Type error: sequence with less or more than one item is not allowed here");}                   
                    if (compareAtomic(collator, lv, rs.itemAt(0).atomize(), Constants.TRUNC_NONE, relation))
                        {result.add(current);}
                } while ((context = context.getNextDirect()) != null);
            }
        } else {
            final Sequence rs = getRight().eval(null);
            if (!rs.hasOne())
                {throw new XPathException(this,
                        "Type error: sequence with less or more than one item is not allowed here");}
            final AtomicValue rv = rs.itemAt(0).atomize();
            for (final Iterator<NodeProxy> i = nodes.iterator(); i.hasNext();) {
                final NodeProxy current = i.next();
                final AtomicValue lv = current.atomize();
                if (compareAtomic(collator, lv, rv, Constants.TRUNC_NONE, Constants.EQ))
                    {result.add(current);}
            }
        }
        return result;
  }
View Full Code Here


            }

            if (processInMem)
                {result = new ValueSequence();}
            else
                {result = new ExtArrayNodeSet();}

            for(final SequenceIterator i = idval.iterate(); i.hasNext(); ) {
          nextId = i.nextItem().getStringValue();
                if (nextId.length() == 0)
                    {continue;}
View Full Code Here

   
    if (seq == null)
      {throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");}

        if (seq.isPersistentSet())
            {result = new ExtArrayNodeSet(seq.getItemCount());}
        else
            {result = new ValueSequence(seq.getItemCount());}

    for (final SequenceIterator i = seq.iterate(); i.hasNext(); ) {
      item = i.nextItem();
View Full Code Here

        //Otherwise we have to walk through each item in the context
        } else {
            Item current;
            String arg;
            NodeSet nodes;
            result = new ExtArrayNodeSet();
            Sequence temp;
            for (final SequenceIterator i = contextSequence.iterate(); i.hasNext();) {
                current = i.nextItem();
                arg = searchTerm.eval(current.toSequence()).getStringValue();
                nodes = path == null ? contextSequence.toNodeSet() :
View Full Code Here

        if (pos < 1 || pos > seq.getItemCount())
                {result= seq;}
            else {
            pos--;
            if (seq instanceof NodeSet) {
              result = new ExtArrayNodeSet();
              result.addAll((NodeSet) seq);
              result = ((NodeSet)result).except((NodeSet) seq.itemAt(pos));
            } else {
              result = new ValueSequence();
              for (int i = 0; i < seq.getItemCount(); i++) {
View Full Code Here

                {throw new RemoteException("result set unknown or timed out");}
            String xml[] = null;
            if (Type.subTypeOf(qr.getItemType(), Type.NODE)) {
                // Fix typecast exception RMT
//        NodeList resultSet = (NodeSet)qr;
                final ExtArrayNodeSet hitsByDoc = new ExtArrayNodeSet();
                NodeProxy p;
                String ppath;
                for (final SequenceIterator i = qr.iterate(); i.hasNext(); ) {
//        for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext();) {
                    p = (NodeProxy) i.nextItem();
                    ///TODO : use dedicated function in XmldbURI
                    ppath = p.getDocument().getCollection().getURI().toString() + '/' + p.getDocument().getFileURI();
                    if (ppath.equals(path))
                        {hitsByDoc.add(p);}
                }
                --start;
                if (start < 0 || start > hitsByDoc.getLength())
                    {throw new RemoteException(
                            "index " + start + "out of bounds (" + hitsByDoc.getLength() + ")");}
                if (start + howmany >= hitsByDoc.getLength())
                    {howmany = hitsByDoc.getLength() - start;}
                final Serializer serializer = broker.getSerializer();
                serializer.reset();
                serializer.setProperty(OutputKeys.INDENT, indent ? "yes" : "no");
                serializer.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, xinclude ? "yes" : "no");
                serializer.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, highlight);
View Full Code Here

        return hasWildcards ? patternMatch(context, terms, hits) : exactMatch(context, terms, hits);
    }

    private Sequence exactMatch(XQueryContext context, String[] terms, NodeSet result) {
        //Walk through hits and calculate term-distances
        final NodeSet r = new ExtArrayNodeSet();
        final Tokenizer tok = context.getBroker().getTextEngine().getTokenizer();
        String term;
        for (final NodeProxy current : result) {
            final String value = current.getNodeValueSeparated();
            tok.setText(value);
            int j = 0;
            if (j < terms.length) {
                term = terms[j];
            } else {
                break;
            }
            int current_distance = -1;
            TextToken token;
            while ((token = tok.nextToken()) != null) {
                final String word = token.getText().toLowerCase();
                if (current_distance > max_distance) {
                    // reset
                    j = 0;
                    term = terms[j];
                    current_distance = -1;
                } //That else would cause some words to be ignored in the matching
                if (word.equalsIgnoreCase(term)) {
                    final boolean withIn = current_distance >= min_distance;
                    current_distance = 0;
                    j++;
                    if (j == terms.length) {
                        //All terms found
                        if (withIn) {
                            r.add(current);
                        }
                        break;
                    } else {
                        term = terms[j];
                    }
View Full Code Here

            } catch (final PatternSyntaxException e) {
                throw new XPathException("Malformed pattern: " + patterns[i]);
            }
        }
        //Walk through hits and calculate term-distances
        final ExtArrayNodeSet r = new ExtArrayNodeSet(100);
        final Tokenizer tok = context.getBroker().getTextEngine().getTokenizer();
        Matcher matcher;
        TextToken token;
        for (final NodeProxy current : result) {
            final String value = current.getNodeValueSeparated();
            tok.setText(value);
            int j = 0;
            if (j < patterns.length) {
                matcher = matchers[j];
            } else {
                break;
            }
            int current_distance = -1;
            while ((token = tok.nextToken()) != null) {
                final String word = token.getText().toLowerCase();
                if (current_distance > max_distance) {
                    //Reset
                    j = 0;
                    matcher = matchers[j];
                    current_distance = -1;
                }
                matcher.reset(word);
                matchers[0].reset(word);
                if (matcher.matches()) {
                    final boolean withIn = current_distance >= min_distance ? true : false;
                    current_distance = 0;
                    j++;
                    if (j == patterns.length) {
                        //All terms found
                        if (withIn) {
                            r.add(current);
                        }
                        break;
                    } else {
                        matcher = matchers[j];
                    }
View Full Code Here

    } else {
      Item current;
      final @SuppressWarnings("unused")
      String arg;
      NodeSet nodes;
      result = new ExtArrayNodeSet();
      Sequence temp;
      for (final SequenceIterator i = contextSequence.iterate(); i.hasNext();) {
        current = i.nextItem();
        final List<String> terms = getSearchTerms(contextSequence);
        nodes =
View Full Code Here

      tmp = Sequence.EMPTY_SEQUENCE;
    } else if (isCalledAs("head")) {
      tmp = seq.itemAt(0).toSequence();
    } else {
            if (seq instanceof NodeSet) {
                tmp = new ExtArrayNodeSet();
                ((ExtArrayNodeSet)tmp).keepUnOrdered(unordered);
            } else {
                tmp = new ValueSequence();
                ((ValueSequence)tmp).keepUnOrdered(unordered);
            }
View Full Code Here

TOP

Related Classes of org.exist.dom.ExtArrayNodeSet$CollectionIterator

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.