Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Value


    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 codeURI = pipelineException.getErrorCodeURI();
            if (codeURI != null) {
View Full Code Here


     *                             unsupported type
     */
    private static Value convertToValue(ExpressionFactory factory,
                                        NodeSet nodeSet)
            throws ExpressionException {
        Value result = null;

        List values = nodeSet.getValues();

        // Provide some optimizations to avoid unnecessary garbage generation
        if (values.size() == 0) {
View Full Code Here

     *                             unsupported java type
     */
    private static Value convertToValue(ExpressionFactory factory,
                                        Object object)
            throws ExpressionException {
        Value result = null;

        if (object instanceof Boolean) {
            result = factory.
                    createBooleanValue(((Boolean)object).booleanValue());
        } else if (object instanceof String) {
View Full Code Here

    /**
     * Tests if function works with two arguments
     */
    public void testTwoArguments() throws ExpressionException {
        final Function function = new SubstringFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createStringValue("123456"), factory.createIntValue(3)});
        assertTrue(result instanceof StringValue);
        assertEquals("3456", ((StringValue) result).asJavaString());
    }
View Full Code Here

    /**
     * Tests if function works correctly when substring start is negative
     */
    public void testTwoArgumentsStartNegative() throws ExpressionException {
        final Function function = new SubstringFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createStringValue("123456"), factory.createIntValue(-3)});
        assertTrue(result instanceof StringValue);
        assertEquals("123456", ((StringValue) result).asJavaString());
    }
View Full Code Here

     * Tests if function works correctly when substring start is greater
     * than original string's length
     */
    public void testTwoArgumentsStartGreaterThanLength() throws ExpressionException {
        final Function function = new SubstringFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createStringValue("123456"), factory.createIntValue(10)});
        assertTrue(result instanceof StringValue);
        assertEquals("", ((StringValue) result).asJavaString());
    }
View Full Code Here

    /**
     * Tests if empty string is returned for empty sequence
     */
    public void testEmptySequence() throws ExpressionException {
        final Function function = new SubstringFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createSequence(new Item[]{}),
                factory.createIntValue(1)});
        assertTrue(result instanceof StringValue);
        assertEquals("", ((StringValue) result).asJavaString());
    }
View Full Code Here

    /**
     * Tests if function works with three arguments
     */
    public void testThreeArguments() throws ExpressionException {
        final Function function = new SubstringFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createStringValue("123456"),
                factory.createIntValue(3), factory.createIntValue(2)});
        assertTrue(result instanceof StringValue);
        assertEquals("34", ((StringValue) result).asJavaString());
    }
View Full Code Here

    /**
     * Tests if number passed to function is casted to string
     */
    public void testSubstringOfNumber() throws ExpressionException {
        final Function function = new SubstringFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createIntValue(123456),
                factory.createIntValue(3), factory.createIntValue(2)});
        assertTrue(result instanceof StringValue);
        assertEquals("34", ((StringValue) result).asJavaString());
    }
View Full Code Here

     * Tests if substring start and length are correctly rounded when
     * specified as doubles
     */
    public void testBoundariesAsDoubles() throws ExpressionException {
        final Function function = new SubstringFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createStringValue("123456"),
                factory.createDoubleValue(3.5), factory.createDoubleValue(2.2)});
        assertTrue(result instanceof StringValue);
        assertEquals("45", ((StringValue) result).asJavaString());
    }
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.