Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.ExpressionFactory


            int index = 0;
            for (int i = start; i < end; i += 1) {
                items[index] = sequence.getItem(i);
                index += 1;
            }
            ExpressionFactory factory = context.getFactory();
            subsequence = factory.createSequence(items);
        }

        return subsequence;
    }
View Full Code Here


            throw new ExpressionException(EXCEPTION_LOCALIZER.format(
                "invalid-num-of-args",
                new Object[]{NAME, 1, arguments.length}));
        }

        ExpressionFactory expressionFactory = context.getFactory();
        ExpressionParser parser = expressionFactory.createExpressionParser();

        Expression expression = parser.parse(arguments[0].stringValue().asJavaString());
        return expression.evaluate(context);
    }
View Full Code Here

        Value result = Sequence.EMPTY;

        if (args[0] != Sequence.EMPTY && args[1] != Sequence.EMPTY) {
            final Sequence inputSequence = args[0].getSequence();
            final String searchStr = args[1].stringValue().asJavaString();
            final ExpressionFactory factory = context.getFactory();

            // Allocate enough space for the return sequence as we know the
            // maximum number of possible matches.
            final Item [] items = new Item[inputSequence.getLength()];
            int numMatches = 0;
            for (int i = 1; i <= inputSequence.getLength(); i++) {
                Item item = inputSequence.getItem(i);
                if (searchStr.equals(item.stringValue().asJavaString())) {

                    // save a match
                    items[numMatches++] = factory.createIntValue(i);
                }
            }
            if (numMatches > 0) {
                // Create the sequence of match indices, if any
                final Item[] matched = new Item[numMatches];
                System.arraycopy(items, 0, matched, 0, numMatches);
                result = factory.createSequence(matched);
            }
        }

        return result;
    }
View Full Code Here

            if (strToTokenize.length() == 0) {
                // If there is no input string, return the empty sequence.
                result = Sequence.EMPTY;
            } else {
                final ExpressionFactory factory = context.getFactory();

                // If the input matches the pattern then the result is a
                // sequence with one empty string.
                final boolean matchesPattern =
                        strToTokenize.matches('^' + pattern + '$');
                if (matchesPattern) {
                    result = factory.createSequence(
                            new Item[]{factory.createStringValue("")});
                } else {

                    // Surround the input string with the binary delimiter and
                    // split it.
                    final String[] tokens =
                            (BINARY_DELIM + strToTokenize + BINARY_DELIM).
                                    split(pattern);

                    // Remove the dummy delimiter.
                    tokens[0] = tokens[0].substring(1);
                    final String lastToken = tokens[tokens.length - 1];
                    tokens[tokens.length - 1] = lastToken.
                            substring(0, lastToken.length() - 1);

                    // Create the items for the result sequence
                    final Item[] items = new Item[tokens.length];
                    for (int i = 0; i < tokens.length; i++) {
                        items[i] = factory.createStringValue(tokens[i]);
                    }

                    result = factory.createSequence(items);
                }
            }
        }

        return result;
View Full Code Here

            INTERNAL_DEVICE_FACTORY.createInternalDevice(dev);
        session.setDevice(internalDevice);
        pageContext.setDevice(session.getDevice());

        // Create an expression context for the environment context.
        final ExpressionFactory factory = ExpressionFactory.getDefaultInstance();
        final EnvironmentInteractionTracker simpleTracker =
                new SimpleEnvironmentInteractionTracker();
        final ExpressionContext exprContext = factory.
                createExpressionContext(simpleTracker,
                        new DefaultNamespacePrefixTracker());

        // Associate the expression context with the environment context.
        envContext.setExpressionContext(exprContext);
View Full Code Here

                public Object perform(MethodActionEvent event) throws Throwable {
                    return outputBufferStack.peek();
                }
            }).any();

        final ExpressionFactory expressionFactory =
            ExpressionFactory.getDefaultInstance();
        final NamespacePrefixTracker prefixTracker =
            NamespaceFactory.getDefaultInstance().createPrefixTracker();
        prefixTracker.startPrefixMapping("meta-property",
            XDIMESchemata.XDIME2_MCS_NAMESPACE);
        final ExpressionContext expressionContext =
            expressionFactory.createExpressionContext(null, prefixTracker);

        final EnvironmentContextMock environmentContextMock =
            new EnvironmentContextMock("environmentContextMock", expectations);
        environmentContextMock.expects.getExpressionContext()
                .returns(expressionContext).any();
View Full Code Here

    protected Value execute(
            ExpressionContext expressionContext,
            MarinerRequestContext requestContext, String name,
            Value defaultValue) {

        ExpressionFactory factory = expressionContext.getFactory();
                               
        Value value = defaultValue;

        String params [] = requestContext.getParameterValues(name);
        if (params != null && params.length > 0) {
            Item[] items = new Item[params.length];

            for (int i = 0; i < params.length; i++) {
                items[i] = factory.createStringValue(params[i]);
            }

            value = factory.createSequence(items);

            // Add dependency information if necessary.
            DependencyContext context = expressionContext.getDependencyContext();
            if (context.isTrackingDependencies()) {
                List list = Arrays.asList(params);
View Full Code Here

        }
    }

    private ExpressionParser getExpressionParser() {
        if (expressionParser == null) {
            ExpressionFactory factory = ExpressionFactory.getDefaultInstance();
            expressionParser = factory.createExpressionParser();
        }

        return expressionParser;
    }
View Full Code Here

        // Initialise expression context.

        ContextInternals.setEnvironmentContext(requestContext,
                environmentContext);

        ExpressionFactory expressionFactory = ExpressionFactory.getDefaultInstance();

        ExpressionContext expressionContext =
                expressionFactory.createExpressionContext(
                        null,
                        NamespaceFactory.getDefaultInstance()
                        .createPrefixTracker());

        expressionContext.setProperty(MarinerRequestContext.class,
View Full Code Here

        PipelineInitialization pipelineInitialization =
                volantisBean.getPipelineInitialization();
        XMLPipelineFactory xmlFactory =
                pipelineInitialization.getPipelineFactory();

        ExpressionFactory factory =
                xmlFactory.getExpressionFactory();

        // obtain the default EnvironmentFactory
        EnvironmentFactory environmentFactory =
                EnvironmentFactory.getDefaultInstance();

        // factor an EnvironmentInteractionTracker
        EnvironmentInteractionTracker envTracker =
                environmentFactory.createInteractionTracker();
       
        // obtain the rootEnvironmentInteraction and push onto the tracker
        EnvironmentInteraction envInteraction =
            environmentContext.createRootEnvironmentInteraction();
        envTracker.pushEnvironmentInteraction(envInteraction);

        environmentContext.pushEnvironmentInteraction(envTracker);

        // See if an expression context already exists or not; an expression
        // context is shared throughout the lifetime of the request but is
        // lazily instantiated
        ExpressionContext expressionContext =
                MCSExpressionHelper.getExpressionContext(context);

        if (expressionContext == null) {
            // create the expression context, register the functions that are
            // needed and store this expression context away in the page
            // context
            expressionContext =
                    factory.createExpressionContext(
                            envTracker,
                            NamespaceFactory.getDefaultInstance().
                    createPrefixTracker());

            registerFunctions(expressionContext);
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.