Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Value


        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"abcabcabcabcabcabcabcabcabcabc"});
        Value pattern = factory.createStringValue("abc");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq,
                new String[]{"", "", "", "", "", "", "", "", "", "", ""});
    }
View Full Code Here


        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"xxxxxxxxxx"});
        Value pattern = factory.createStringValue("xxx");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq, new String[]{"", "", "", "x"});
    }
View Full Code Here

     */
    public void testNoArguments() throws Exception {
        try {
            ExpressionContext context = createExpressionContext();
            Function tokenize = new TokenizeFunction();
            Value retVal = tokenize.invoke(context, new Value[]{});
            fail("Should have failed when invoked with no arguments");
        } catch (ExpressionException expected) {
        }
    }
View Full Code Here

            ExpressionContext context = createExpressionContext();
            ExpressionFactory factory = context.getFactory();
            Sequence sequence = createSequence(factory,
                    new String[]{"xxxxxxxxxx"});
            Function tokenize = new TokenizeFunction();
            Value retVal = tokenize.invoke(context, new Value[]{sequence});
            fail("Should have failed when invoked with only one argument");
        } catch (ExpressionException expected) {
        }
    }
View Full Code Here

        try {
            ExpressionContext context = createExpressionContext();
            ExpressionFactory factory = context.getFactory();
            Sequence sequence = createSequence(factory,
                    new String[]{"xxxxxxxxxx"});
            Value pattern = factory.createStringValue("xxx");
            Function tokenize = new TokenizeFunction();
            Value retVal = tokenize.invoke(context,
                    new Value[]{sequence, pattern, pattern});
            fail("Should have failed when invoked with three arguments");
        } catch (ExpressionException expected) {
        }
    }
View Full Code Here

    public Value invoke(ExpressionContext context, Value[] arguments) throws ExpressionException {
        assertArgumentCount(arguments, 0);
        SAXParseException x = getException(context);
        ExpressionFactory factory = context.getFactory();
        Value result = Sequence.EMPTY;

        if (x instanceof XMLPipelineException) {
            XMLPipelineException pipelineException = (XMLPipelineException) x;
            String codeName = pipelineException.getErrorCodeName();
            if (codeName != null) {
View Full Code Here

    public Value invoke(ExpressionContext context, Value[] arguments) throws ExpressionException {
        assertArgumentCount(arguments, 0);
        SAXParseException x = getException(context);
        ExpressionFactory factory = context.getFactory();
        Value result = Sequence.EMPTY;

        if (x != null) {
            result = factory.createStringValue(x.getMessage());           
        }
View Full Code Here

        items[2] = factory.createStringValue("c");    
        context.getCurrentScope().declareVariable(
                   new ImmutableExpandedName("", "myVar"),
                   factory.createSequence(items));
       Expression exp = compileExpression("$myVar=(\"a\",\"b\",\"c\")");
       Value result = exp.evaluate(context);   
 
       assertTrue("Sequence comparison failed :" +
           "'(\"a\",\"b\",\"c\")=(\"a\",\"d\")'",
            ((BooleanValue) result).asJavaBoolean());

       Expression exp2 = compileExpression("$myVar=(\"a\",\"d\")");
       Value result2 = exp2.evaluate(context);   

       assertTrue("Sequence comparison failed: " +
           "'(\"a\",\"b\",\"c\")=(\"a\",\"d\")'",
            ((BooleanValue) result2).asJavaBoolean());    
      
       Expression exp3 = compileExpression("2=(3, 4 div 2)");
       Value result3 = exp3.evaluate(context);   

       assertTrue("Sequence comparison failed : '2=(3, 4 div 2)'",
            ((BooleanValue) result3).asJavaBoolean());       
    }
View Full Code Here

    /**
     * Tests if empty sequence is returned for empty sequence
     */
    public void testEmptySequence() throws ExpressionException {
        final Function function = new MinFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createSequence(new Item[]{})});
        assertTrue(result instanceof Sequence);
        assertEquals(0, result.getSequence().getLength());
    }
View Full Code Here

        context.getCurrentScope().declareVariable(
            new ImmutableExpandedName("", "right"),
            factory.createSequence(right));

        Expression exp = compileExpression("$left = (($right))");
        Value result = exp.evaluate(context);     
        assertTrue("Nested variable comparison failed",
            ((BooleanValue) result).asJavaBoolean());
    }
View Full Code Here

TOP

Related Classes of com.volantis.xml.expression.Value

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.