Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.ExpressionFactory


public class ErrorCodeURIFunction extends AbstractErrorFunction {

    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) {
                result = factory.createStringValue(codeURI);
            }
        }
       
        return result;
    }
View Full Code Here


    // javadoc inherited from interface
    public void startProcess() throws SAXException {
        // initalize the parser that will be use to parse XPath expressions
        XMLPipelineFactory pipelineFactory =
                getPipelineContext().getPipelineFactory();
        ExpressionFactory expressionFactory =
                pipelineFactory.getExpressionFactory();
        parser = expressionFactory.createExpressionParser();
    }
View Full Code Here

                }
            }
        }

        // Create a sequence to return.
        ExpressionFactory factory = expressionContext.getFactory();
        return factory.createSequence(items);
    }
View Full Code Here

    /**
     * Tests that the search string is found where expected.
     */
    public void testSearchPresent() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function indexOf = new IndexOfFunction();
        Sequence sequence = createStringSequence(factory,
                new String[]{"a", "dog", "and", "a", "duck"});
        Value search = factory.createStringValue("a");
        Value retVal = indexOf.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned (1, 4)
View Full Code Here

    /**
     * Tests that the search string is not found.
     */
    public void testSearchNotPresent() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function indexOf = new IndexOfFunction();
        Sequence sequence = createStringSequence(factory,
                new String[]{"a", "dog", "and", "a", "duck"});
        Value search = factory.createStringValue("cat");
        Value retVal = indexOf.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned ()
View Full Code Here

    /**
     * Tests that the search string is found at all positions.
     */
    public void testAllItemsMatch() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function indexOf = new IndexOfFunction();
        Sequence sequence = createStringSequence(factory,
                new String[]{"abc", "abc", "abc", "abc", "abc"});
        Value search = factory.createStringValue("abc");
        Value retVal = indexOf.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned (1, 2, 3, 4, 5)
View Full Code Here

     * Tests that an empty search string causes the empty sequence to be
     * returned.
     */
    public void testEmptySearch() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function indexOf = new IndexOfFunction();
        Sequence sequence = createStringSequence(factory,
                new String[]{"abc", "abc", "abc", "abc", "abc"});
        Value search = factory.createStringValue("");
        Value retVal = indexOf.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned ()
View Full Code Here

     * Tests that an empty sequence causes the empty sequence to be
     * returned.
     */
    public void testEmptySequence() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function indexOf = new IndexOfFunction();
        Sequence sequence = createStringSequence(factory, null);
        Value search = factory.createStringValue("peter");
        Value retVal = indexOf.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned ()
View Full Code Here

     * Tests that an empty sequence and empty search string causes the empty
     * sequence to be returned.
     */
    public void testEmptySequenceEmptySearch() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function indexOf = new IndexOfFunction();
        Sequence sequence = createStringSequence(factory, null);
        Value search = factory.createStringValue("");
        Value retVal = indexOf.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned ()
View Full Code Here

     * Tests that the search integer is found where expected.
     * ((15, 40, 25, 40, 10), 40)
     */
    public void testIntegerSequence() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function indexOf = new IndexOfFunction();
        Sequence sequence = createIntegerSequence(factory,
                new int[]{15, 40, 25, 40, 10});
        Value search = factory.createIntValue(40);
        Value retVal = indexOf.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned (2, 4)
View Full Code Here

TOP

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

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.