Package com.volantis.xml.expression.atomic.numeric

Examples of com.volantis.xml.expression.atomic.numeric.DoubleValue


     * Sequence argument
     * @throws Exception if an error occurs
     */
    public void testNumberWithEmptySequence() throws Exception {
        // invoke the method
        DoubleValue result = PipelineExpressionHelper.fnNumber(Sequence.EMPTY,
                                                       factory);
        // check the result
        assertTrue("unexpected number result",
                   Double.isNaN(result.asJavaDouble()));

    }
View Full Code Here


     * of one "NaN" StringValue Item
     * @throws Exception if an error occurs
     */
    public void testNumberWithNaNStringValueItem() throws Exception {
        Sequence seq = factory.createStringValue("NaN").getSequence();
        DoubleValue result = PipelineExpressionHelper.fnNumber(seq, factory);
        assertTrue("number('NaN') should return NaN DoubleValue",
                   Double.isNaN(result.asJavaDouble()));
    }
View Full Code Here

     * of one invalid double StringValue Item
     * @throws Exception if an error occurs
     */
    public void testNumberWithinValidDoubleStringValueItem() throws Exception {
        Sequence seq = factory.createStringValue("fred").getSequence();
        DoubleValue result = PipelineExpressionHelper.fnNumber(seq, factory);
        assertTrue("number('fred') should return NaN DoubleValue",
                   Double.isNaN(result.asJavaDouble()));
    }
View Full Code Here

     * @throws Exception if an error occurs
     */
    public void doTestNumber(Sequence sequence, double expected)
            throws Exception {
        // invoke the method
        DoubleValue result = PipelineExpressionHelper.fnNumber(sequence, factory);
        // check the result
        assertEquals("unexpected number result",
                     expected,
                     result.asJavaDouble(),
                     0.1);

    }
View Full Code Here

        // obtain length of sequence
        int length = sequence.getLength();

        // value of operand cast to a double
        DoubleValue eval = DoubleValue.NOT_A_NUMBER;

        // if length is zero then we return NaN
        if (length == 1) {
            // if length is 1 (ie atomic value) then the following rules apply
            Value sv = sequence.getItem(1);
View Full Code Here

     * @param value The value to get as an integer.
     * @return The value as an int.
     */
    private int getIntRound(Value value) {
        if (value instanceof DoubleValue) {
            DoubleValue doubleValue = (DoubleValue) value;
            return (int) Math.round(doubleValue.asJavaDouble());
        } else if (value instanceof IntValue) {
            IntValue intValue = (IntValue) value;
            return intValue.asJavaInt();
        } else {
            throw new IllegalArgumentException(
View Full Code Here

                            new Item[sequenceItems.size()]));
        }

        // javadoc inhertied
        public void visit(ImmutableNumberValue immutableNumberValue) {
            DoubleValue doubleValue =
                    expressionFactory.createDoubleValue(
                        immutableNumberValue.getValueAsNumber().doubleValue());
            if (sequenceItems == null) {
                // not creating a sequence of items set the value to be
                // the double
View Full Code Here

        // retrieve the usable display height in pixels from the repository
        double usableHeight = retrieveLengthValue(accessor,
                DevicePolicyConstants.USABLE_HEIGHT_IN_PIXELS, name);

        DoubleValue actualValue;
        try {
            if (!PX.equalsIgnoreCase(name)) {
                double usableHeightInMm = calculateUsableLengthInMillimetres(
                        accessor, DevicePolicyConstants.USABLE_HEIGHT_IN_PIXELS,
                        DevicePolicyConstants.ACTUAL_HEIGHT_IN_PIXELS,
View Full Code Here

        // retrieve the usable display width in pixels from the repository
        double usableWidth = retrieveLengthValue(accessor,
                DevicePolicyConstants.USABLE_WIDTH_IN_PIXELS, name);

        DoubleValue actualValue;
        try {
            if (!PX.equalsIgnoreCase(name)) {
                double usableWidthInMm = calculateUsableLengthInMillimetres(
                        accessor, DevicePolicyConstants.USABLE_WIDTH_IN_PIXELS,
                        DevicePolicyConstants.ACTUAL_WIDTH_IN_PIXELS,
View Full Code Here

        } else {
            deviceWidth = retrieveLengthValue(accessor,
                DevicePolicyConstants.ACTUAL_WIDTH_IN_MM, name);
        }

        DoubleValue actualValue = new SimpleDoubleValue(
                expressionContext.getFactory(), deviceWidth);

        return calculateLength(expressionContext, accessor, name, defaultValue,
                actualValue);
    }
View Full Code Here

TOP

Related Classes of com.volantis.xml.expression.atomic.numeric.DoubleValue

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.