Package org.exist.xquery.value

Examples of org.exist.xquery.value.SequenceType


        }
        if(!type.checkType(value))
          {throw new XPathException( Messages.getMessage( Error.VAR_TYPE_MISMATCH,
                toString(),
                type.toString(),
                new SequenceType(value.getItemType(), value.getCardinality()).toString()
            )
          );}
    }
View Full Code Here


     */
    protected void checkArguments() throws XPathException {
        if (!argumentsChecked) {
            final SequenceType[] argumentTypes = mySignature.getArgumentTypes();
            Expression next;
            SequenceType argType = null;
            for (int i = 0; i < getArgumentCount(); i++) {
                if (argumentTypes != null && i < argumentTypes.length)
                    {argType = argumentTypes[i];}
                next = checkArgument(getArgument(i), argType, i + 1);
                steps.set(i, next);
View Full Code Here

            final StringBuilder description = new StringBuilder();
            description.append(signature.getDescription());

            description.append("\n\n");
           
            final SequenceType argumentTypes[] = signature.getArgumentTypes();
           
            if(argumentTypes != null && argumentTypes.length>0){

                final StringBuilder args = new StringBuilder();
                int noArgs=0;
               
                for (final SequenceType argumentType : argumentTypes) {
                    if (argumentType instanceof FunctionParameterSequenceType) {
                        noArgs++;
                        final FunctionParameterSequenceType fp
                                = (FunctionParameterSequenceType) argumentType;
                        args.append("$");
                        args.append(fp.getAttributeName());
                        args.append(" : ");
                        args.append(fp.getDescription());
                        args.append("\n");
                    }
                }

                // only add if there were good arguments
                if(noArgs>0){
                    description.append("Parameters:\n");
                    description.append(args);
                }
            }

            final SequenceType returnType = signature.getReturnType();
            if(returnType != null){            
                if (returnType instanceof FunctionReturnSequenceType) {
                    description.append("\n");
                    description.append("Returns ");
                    final FunctionReturnSequenceType fp
View Full Code Here

    }

    protected void enhance(FunctionSignature signature) {
        signature.setDescription(description.toString());
        if (returnValue != null) {
            final SequenceType returnType = signature.getReturnType();
            final FunctionReturnSequenceType newType =
                    new FunctionReturnSequenceType(returnType.getPrimaryType(), returnType.getCardinality(), returnValue);
            signature.setReturnType(newType);
        }
        final SequenceType[] args = signature.getArgumentTypes();
        for (final SequenceType type : args) {
            if (type instanceof FunctionParameterSequenceType) {
View Full Code Here

    private void setFunction(UserDefinedFunction functionDef) {
        this.functionDef = (UserDefinedFunction) functionDef.clone();
        this.mySignature = this.functionDef.getSignature();
        this.expression = this.functionDef;
        this.functionDef.setCaller(this);
        final SequenceType returnType = this.functionDef.getSignature().getReturnType();
       
        // add return type checks
        if(returnType.getCardinality() != Cardinality.ZERO_OR_MORE) {
                expression = new DynamicCardinalityCheck(context, returnType.getCardinality(), expression, new Error(Error.FUNC_RETURN_CARDINALITY));
        }
       
        if(Type.subTypeOf(returnType.getPrimaryType(), Type.ATOMIC)) {
                expression = new Atomize(context, expression);
        }
       
        if(Type.subTypeOf(returnType.getPrimaryType(), Type.NUMBER)) {
                expression = new UntypedValueCheck(context, returnType.getPrimaryType(), expression, new Error(Error.FUNC_RETURN_TYPE));
        } else if(returnType.getPrimaryType() != Type.ITEM) {
                expression = new DynamicTypeCheck(context, returnType.getPrimaryType(), expression);
        }
    }
View Full Code Here

        //mocks for evalFunction()
        Sequence mockContextSequence = EasyMock.createMock(Sequence.class);
        Item mockContextItem = EasyMock.createMock(Item.class);
        Sequence[] mockSeq = { Sequence.EMPTY_SEQUENCE };
        int nextExpressionId = 1234;
        SequenceType[] mockArgumentTypes = { new SequenceType(Type.NODE, Cardinality.ZERO) };
       
        //mock for functionDef
        FunctionSignature mockFunctionSignature = EasyMock.createMock(FunctionSignature.class);
        SequenceType mockReturnType = EasyMock.createMock(SequenceType.class);
        LocalVariable mockMark = EasyMock.createMock(LocalVariable.class);
        Expression mockExpression = EasyMock.createMock(Expression.class);
       
        //expectations for UserDefinedFunction constructor
        expect(mockContext.nextExpressionId()).andReturn(nextExpressionId++);
        expect(mockExpression.simplify()).andReturn(mockExpression);
       
        //expectations for FunctionCall constructor
        expect(mockContext.nextExpressionId()).andReturn(nextExpressionId++);
       
        //expectations for FunctionCall.setFunction
        expect(mockFunctionSignature.getReturnType()).andReturn(mockReturnType);
        expect(mockReturnType.getCardinality()).andReturn(Cardinality.ZERO_OR_MORE);
        expect(mockReturnType.getPrimaryType()).andReturn(Type.NODE).times(4);
        expect(mockContext.nextExpressionId()).andReturn(nextExpressionId++);
       
        //expectations for functionCall.evalFunction
        expect(mockContext.isProfilingEnabled()).andReturn(false);
        expect(mockContext.getPDP()).andReturn(null);
View Full Code Here

TOP

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

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.