Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Value


    /**
     * Tests on sequence of dates. Latest date should be returned.
     */
    public void testSequenceOfDates() throws ExpressionException {
        final Function function = new MaxFunction();
        Value result = function.invoke(expressionContextMock, new Value[]{
                factory.createSequence(new Item[]{
                      factory.createDateValue("2008-03-11"),
                      factory.createDateValue("2006-04-16"),
                      factory.createDateValue("2009-01-02")
                })});
View Full Code Here


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

        if (x instanceof XMLPipelineException) {
            XMLPipelineException pipelineException = (XMLPipelineException) x;
            Map errorProperties = pipelineException.getErrorProperties();
            if (errorProperties != null) {
View Full Code Here

    /**
     * Tests on sequence of datetimes. Latest datetime should be returned.
     */
    public void testSequenceOfDatetimes() throws ExpressionException {
        final Function function = new MaxFunction();
        Value result = function.invoke(expressionContextMock, new Value[]{
                factory.createSequence(new Item[]{
                      factory.createDateTimeValue("2004-03-11T07:56:16+00:00"),
                      factory.createDateTimeValue("2006-04-16T12:30:16+00:00"),
                      factory.createDateTimeValue("2006-04-16T06:56:16+00:00"),
                      factory.createDateTimeValue("2005-01-02T02:56:16+00:00")
View Full Code Here

                });

        // Literal numbers are promoted to double values, not ints
        Expression exp = compileExpression("function:test('a', 2, $myVar)");

        Value eval = exp.evaluate(context);

        assertTrue("Expression should result in a string value",
                   eval instanceof StringValue);

        assertEquals("Expression result not as",
                     "a 2 " + result.stringValue().asJavaString(),
                     eval.stringValue().asJavaString());
    }
View Full Code Here

    /**
     * Tests on sequence of times. Latest time should be returned.
     */
    public void testSequenceOfTimeValues() throws ExpressionException {
        final Function function = new MaxFunction();
        Value result = function.invoke(expressionContextMock, new Value[]{
                factory.createSequence(new Item[]{
                      factory.createTimeValue("07:56:16+00:00"),
                      factory.createTimeValue("12:30:16+00:00"),
                      factory.createTimeValue("22:55:21+00:00"),
                      factory.createTimeValue("22:56:16+00:00")
View Full Code Here

        // Compile and execute the function
        Expression exp = compileExpression("function:test()");

        try {
            Value eval = exp.evaluate(context);
            fail("Function should have thrown ExpressionException, but " +
                    "no exception thrown.");
        } catch (ExpressionException ee) {
            // Expected result - test successful
        }
View Full Code Here

     * Test to ensure that an empty sequence is parsed and correctly evaluated
     * @throws Exception an error occurs
     */
    public void testEmptySequence() throws Exception {
        Expression exp = compileExpression("()");
        Value result = exp.evaluate(context);
        // result should be an empty sequence
        assertTrue("Result is not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence) result;
View Full Code Here

     * Test to ensure that an empty sequence inside an empty sequence is evaluated to empty sequence
     * @throws Exception an error occurs
     */
    public void testSequenceContainingEmptySequence() throws Exception {
        Expression exp = compileExpression("(())");
        Value result = exp.evaluate(context);
        // result should be an empty sequence
        assertTrue("Result is not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence) result;
View Full Code Here

     * Test to ensure that empty sequence item is removed after evaluation
     * @throws Exception an error occurs
     */
    public void testSequenceContainingEmptySequenceAndStrings() throws Exception {
        Expression exp = compileExpression("('a', (), 'b')");
        Value result = exp.evaluate(context);
        assertTrue("Result is not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence) result;

View Full Code Here

     * @return the object as a Value
     * @throws ExpressionException if the object cannot be converted
     */
    public static Value asValue(ExpressionFactory factory, Object object)
            throws ExpressionException {
        Value result = null;

        if (object == null) {
            // a result of null indicates a non existent path result which
            // should be represented by an empty sequence.
            result = Sequence.EMPTY;
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.