Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.ExpressionFactory


     * of empty strings (one for each match, plus one extra) results.
     */
    public void testStringEqualsMultipleSingleLetterPattern()
            throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"xxxxxxxxxx"});
        Value pattern = factory.createStringValue("x");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

View Full Code Here


     * of empty strings (one for each match, plus one extra) results.
     */
    public void testStringEqualsMultipleMultipleLetterPattern()
            throws Exception {
        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();

View Full Code Here

     * 'leftover', that each match generates an empty string and the last
     * sequence member is the leftover bit.
     */
    public void testRemainderX() throws Exception {
        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();

View Full Code Here

     * Tests that failure occurs when function is given one argument.
     */
    public void testOneArgument() throws Exception {
        try {
            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");
View Full Code Here

     * Tests that failure occurs when function is given three arguments.
     */
    public void testThreeArguments() throws Exception {
        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 static boolean evaluateExpression(
            XMLPipelineContext pipelineContext,
            String expressionString)
            throws ExpressionException {

        ExpressionFactory expressionFactory =
                ExpressionFactory.getDefaultInstance();

        ExpressionContext expressionContext =
                pipelineContext.getExpressionContext();

        Expression expression =
                expressionFactory.createExpressionParser().parse(
                    expressionString);
        Value result = expression.evaluate(expressionContext);
        return PipelineExpressionHelper.fnBoolean(result.getSequence())
                .asJavaBoolean();
    }
View Full Code Here

public class ErrorCodeNameFunction 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 codeName = pipelineException.getErrorCodeName();
            if (codeName != null) {
                result = factory.createStringValue(codeName);
            }
        }

        return result;
    }
View Full Code Here

public class ErrorMessageFunction 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 != null) {
            result = factory.createStringValue(x.getMessage());           
        }

        return result;
    }
View Full Code Here

        String expr = attributes.getValue("expr");
        if (expr == null) {
            forwardError(dynamicProcess,
                    "'expr' attribute must be specified on " + element);
        } else {
            ExpressionFactory factory = ExpressionFactory.getDefaultInstance();
            ExpressionParser parser = factory.createExpressionParser();
            try {
                // Parse, and evaluate the expression.
                Expression expression = parser.parse(expr);
                Value value = expression.evaluate(context);
View Full Code Here

                = new DynamicRuleProcess(this, configuration);

        // initalize the parser that will be use to parse XPath expressions
        XMLPipelineFactory pipelineFactory =
                getPipelineContext().getPipelineFactory();
        ExpressionFactory expressionFactory =
                pipelineFactory.getExpressionFactory();
        ExpressionParser parser = expressionFactory.createExpressionParser();

        // create a process that can evaluate expressions
        ExpressionProcess expressionProcess = createExpressionProcess(parser);

        DISelectConditionalProcess diSelectProcess = new DISelectConditionalProcess(parser);
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.