Package org.exist.xquery.value

Examples of org.exist.xquery.value.FunctionReference.analyze()


           
            //convert the arguments
            final org.exist.xquery.value.Sequence[] fnArgs = convertToExistFunctionArguments(xqueryContext, fn, arguments);
           
            //execute the function call
            fnRef.analyze(new AnalyzeContextInfo());
            final org.exist.xquery.value.Sequence result = fnRef.evalFunction(null, null, fnArgs);
           
            return new SequenceAdapter(result);
        } catch(final URISyntaxException use) {
            throw new RestXqServiceException(use.getMessage(), use);
View Full Code Here


  public Sequence eval(Sequence[] args, Sequence contextSequence)
      throws XPathException {
        Sequence result = new ValueSequence();
        if (isCalledAs("map")) {
            final FunctionReference ref = (FunctionReference) args[0].itemAt(0);
            ref.analyze(cachedContextInfo);
            for (final SequenceIterator i = args[1].iterate(); i.hasNext(); ) {
                final Item item = i.nextItem();
                final Sequence r = ref.evalFunction(contextSequence, null, new Sequence[]{item.toSequence()});
                result.addAll(r);
            }
View Full Code Here

                final Sequence r = ref.evalFunction(contextSequence, null, new Sequence[]{item.toSequence()});
                result.addAll(r);
            }
        } else if (isCalledAs("for-each")) {
            final FunctionReference ref = (FunctionReference) args[1].itemAt(0);
            ref.analyze(cachedContextInfo);
            for (final SequenceIterator i = args[0].iterate(); i.hasNext(); ) {
                final Item item = i.nextItem();
                final Sequence r = ref.evalFunction(contextSequence, null, new Sequence[]{item.toSequence()});
                result.addAll(r);
            }
View Full Code Here

            } else {
                ref = (FunctionReference) args[0].itemAt(0);
                seq = args[1];
            }

            ref.analyze(cachedContextInfo);
          for (final SequenceIterator i = seq.iterate(); i.hasNext(); ) {
            final Item item = i.nextItem();
            final Sequence r = ref.evalFunction(contextSequence, null, new Sequence[] { item.toSequence() });
            if (r.effectiveBooleanValue())
              {result.add(item);}
View Full Code Here

            if (r.effectiveBooleanValue())
              {result.add(item);}
          }
        } else if (isCalledAs("fold-left")) {
            final FunctionReference ref = (FunctionReference) args[2].itemAt(0);
            ref.analyze(cachedContextInfo);
          Sequence zero = args[1];
          Sequence input = args[0];
          while (!input.isEmpty()) {
            final SequenceIterator i = input.iterate();
            zero = ref.evalFunction(contextSequence, null, new Sequence[] { zero, i.nextItem().toSequence() });
View Full Code Here

            input = tail;
          }
          result = zero;
        } else if (isCalledAs("fold-right")) {
            final FunctionReference ref = (FunctionReference) args[2].itemAt(0);
            ref.analyze(cachedContextInfo);
          final Sequence zero = args[1];
          final Sequence input = args[0];
          result = foldRight(ref, zero, input, contextSequence);
        } else if (isCalledAs("map-pairs")) {
            final FunctionReference ref = (FunctionReference) args[0];
View Full Code Here

          final Sequence zero = args[1];
          final Sequence input = args[0];
          result = foldRight(ref, zero, input, contextSequence);
        } else if (isCalledAs("map-pairs")) {
            final FunctionReference ref = (FunctionReference) args[0];
            ref.analyze(cachedContextInfo);
          final SequenceIterator i1 = args[1].iterate();
          final SequenceIterator i2 = args[2].iterate();
          while (i1.hasNext() && i2.hasNext()) {
            final Sequence r = ref.evalFunction(contextSequence, null,
                new Sequence[] { i1.nextItem().toSequence(), i2.nextItem().toSequence() });
View Full Code Here

                new Sequence[] { i1.nextItem().toSequence(), i2.nextItem().toSequence() });
            result.addAll(r);
          }
        } else if (isCalledAs("for-each-pair")) {
            final FunctionReference ref = (FunctionReference) args[2].itemAt(0);
            ref.analyze(cachedContextInfo);
            final SequenceIterator i1 = args[0].iterate();
            final SequenceIterator i2 = args[1].iterate();
            while (i1.hasNext() && i2.hasNext()) {
                final Sequence r = ref.evalFunction(contextSequence, null,
                        new Sequence[] { i1.nextItem().toSequence(), i2.nextItem().toSequence() });
View Full Code Here

        final List<Expression> params = new ArrayList<Expression>(getArgumentCount() - 1);
        for(int i = 1; i < getArgumentCount(); i++) {
            params.add(getArgument(i));
        }
        ref.setArguments(params);
        ref.analyze(new AnalyzeContextInfo(this, 0));
        // Evaluate the function
        return ref.eval(contextSequence);
    }
}
View Full Code Here

          }
        } else {
          ref.setArguments(arguments);
            // need to create a new AnalyzeContextInfo to avoid memory leak
            // cachedContextInfo will stay in memory
          ref.analyze(new AnalyzeContextInfo(cachedContextInfo));
          // Evaluate the function
          final Sequence result = ref.eval(contextSequence);
            ref.resetState(false);
            return result;
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.