Package com.volantis.xml.expression.sequence

Examples of com.volantis.xml.expression.sequence.Sequence


            final ExpressionContext expressionContext,
            String expressionAsString)
            throws ExtendedSAXException {
        ExpressionFactory factory = expressionContext.getFactory();
        ExpressionParser parser = factory.createExpressionParser();
        Sequence sequence;
        try {
            Expression expression = parser.parse(expressionAsString);
            Value value = expression.evaluate(expressionContext);
            sequence = value.getSequence();
        } catch (ExpressionException e) {
View Full Code Here


   
    // javadoc inherited   
    public Value invoke(ExpressionContext exprContext, Value[] values)
            throws ExpressionException {
        FunctionArgumentsValidationHelper.checkArgumentsCount(NAME, 1, values.length);
        Sequence sequence = values[0].getSequence();
        int result = sequence.getLength() > 0 ?
                values[0].stringValue().asJavaString().length() : 0;
        return exprContext.getFactory().createIntValue(result);
    }
View Full Code Here

        if (arguments.length != 1) {
            throw new IllegalArgumentException("empty() takes only one argument");
        }

        Sequence sequence = arguments[0].getSequence();
        boolean empty = (sequence.getLength() == 0);

        return empty ? BooleanValue.TRUE : BooleanValue.FALSE;
    }
View Full Code Here

    // javadoc inherited
    public Value invoke(ExpressionContext context, Value[] arguments)
            throws ExpressionException {
        FunctionArgumentsValidationHelper.checkArgumentsCount(getName(), 1,
                arguments.length);
        Sequence sequence = arguments[0].getSequence();
        Value result;
        if (sequence.getLength() == 0) {
            result = Sequence.EMPTY;
        } else {
            result = sequence.getItem(1);
            for (int i = 2; i <= sequence.getLength(); i++) {
                Value currentItem = sequence.getItem(i);
                CompareResult compareResult = PipelineExpressionHelper.compare(
                        result, currentItem);
                if (compareResult == getExtremeValueComparisonResult()) {
                    result = currentItem;
                } else if (compareResult == CompareResult.INCOMPARABLE) {
View Full Code Here

            throw new IllegalArgumentException(
                    "subsequence() takes two or three arguments");
        }

        // First argument is a sequence.
        Sequence sequence = arguments[0].getSequence();

        // Second argument is a number.
        int length = sequence.getLength();
        int start = getIntRound(arguments[1]);
        int end;
        if (arguments.length == 3) {
            end = start + getIntRound(arguments[2]);
        } else {
            end = length;
        }

        // If the start is before the first item then make it the first item.
        if (start < 1) {
            start = 1;
        }

        // If the end is after the last item then make it the last item.
        if (end > length + 1) {
            end = length + 1;
        }

        Sequence subsequence;

        // The result sequence will be empty if:
        // 1) The input sequence is empty.
        // 2) The start is after the end of the sequence.
        // 3) The end is before or the same as the start.
View Full Code Here

        if (arguments.length != 1) {
            throw new IllegalArgumentException("empty() takes only one argument");
        }

        Sequence sequence = arguments[0].getSequence();
        boolean empty = (sequence.getLength() == 0);

        return empty ? BooleanValue.FALSE : BooleanValue.TRUE;
    }
View Full Code Here

    // javadoc inherited   
    public Value invoke(ExpressionContext context, Value[] arguments)
            throws ExpressionException {
        FunctionArgumentsValidationHelper.checkArgumentsCount(NAME, 2, 3, arguments.length);
        Value result;
        Sequence sequence = arguments[0].getSequence();
        if (sequence.getLength() == 0) {
            result = context.getFactory().createStringValue("");
        } else {
            result = context.getFactory().createStringValue(
                    getSubstring(arguments[0], arguments[1],
                            arguments.length == 2 ?
View Full Code Here

     * Test that the function returns true for an empty sequence.
     */
    public void testEmptySequence() throws Exception {

        // Create an empty sequence.
        Sequence sequence = factory.createSequence(new Item[0]);

        Function function = new EmptyFunction();
        Value result =
                function.invoke(expressionContextMock, new Value[] {sequence});
        assertSame(result, BooleanValue.TRUE);
View Full Code Here

     * Test that the function returns false for a non-empty sequence.
     */
    public void testNonEmptySequence() throws Exception {

        // Create a non empty sequence.
        Sequence sequence = factory.createSequence(new Item[] {
            BooleanValue.TRUE
        });

        Function function = new EmptyFunction();
        Value result =
View Full Code Here

            // evaluate the current operand
            operandEval = args[i].computeValue(evalContext);

            try {
                // convert the result to a sequence
                Sequence sequence = JXPathExpression.asValue(
                        factory, operandEval).getSequence();

                // convert the sequence to the "effective boolean value"
                eval = PipelineExpressionHelper.fnBoolean(sequence);
            } catch (ExpressionException e) {
View Full Code Here

TOP

Related Classes of com.volantis.xml.expression.sequence.Sequence

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.