Package org.exist.xquery.value

Examples of org.exist.xquery.value.FunctionReference


    public Sequence eval(Sequence[] args, Sequence contextSequence)
            throws XPathException {
        if (args[0].isEmpty())
            {return Sequence.EMPTY_SEQUENCE;}
       
        final FunctionReference call = (FunctionReference) args[2].itemAt(0);
       
        FunctionReference resultCallback = null;
        if (getArgumentCount() == 5) {
            resultCallback = (FunctionReference) args[3].itemAt(0);
        }
       
        final int width = ((IntegerValue)args[1].itemAt(0)).getInt();
View Full Code Here


        if(arg0.getCardinality() != Cardinality.EXACTLY_ONE)
            {throw new XPathException(this, "Expected exactly one item for first argument");}
        final Item item0 = arg0.itemAt(0);
        if(item0.getType() != Type.FUNCTION_REFERENCE)
            {throw new XPathException(this, "Type error: expected function, got " + Type.getTypeName(item0.getType()));}
        final FunctionReference ref = (FunctionReference)item0;
       
        // pass the remaining parameters to the function call
        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

    public Sequence eval(Sequence[] args, Sequence contextSequence)
            throws XPathException {
        if (args[0].isEmpty())
            {return Sequence.EMPTY_SEQUENCE;}
       
        final FunctionReference func = (FunctionReference) args[1].itemAt(0);
       
        context.pushDocumentContext();
       
        final MemTreeBuilder builder = context.getDocumentBuilder();
        final ValueSequence result = new ValueSequence();
View Full Code Here

                ". Expression: " + ExpressionDumper.dump(functionExpr));}
        final Item item0 = funcSeq.itemAt(0);
        if (!Type.subTypeOf(item0.getType(), Type.FUNCTION_REFERENCE))
            {throw new XPathException(this, ErrorCodes.XPTY0004,
                "Type error: expected function, got " + Type.getTypeName(item0.getType()));}
        final FunctionReference ref = (FunctionReference)item0;
        // if the call is a partial application, create a new function
        if (isPartial) {
          try {
            final FunctionCall call = ref.getCall();
            call.setArguments(arguments);
            final PartialFunctionApplication partialApp = new PartialFunctionApplication(context, call);
                partialApp.analyze(new AnalyzeContextInfo(cachedContextInfo));
            return partialApp.eval(contextSequence, contextItem);
          } catch (final XPathException e) {
        e.setLocation(line, column, getSource());
        throw e;
          }
        } 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

Related Classes of org.exist.xquery.value.FunctionReference

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.