Share this page

# LrSqsMessageAttributeValue.doubleValue

Returns the value of the attribute as a double.

`public double doubleValue ()`

## Return values

This function returns a double that represents the value of the attribute.

## General information

This function returns the value of the attribute as a double if the data type of the attribute is Double. If the data type is not Double, then the function converts the value to a double if possible. If the value cannot be converted, an exception is thrown.

## Example

Copy code

    public int action() throws Throwable {

            LrSqsClient.initClient(region, standardQueueUrl);

            LrSqsMessageAttributeValue intValue = LrSqsClient.createMessageAttributeValueInt(24);
            lr.output_message("type: " + intValue.dataType());
            if (intValue.dataType()=="Number"){
                int num = intValue.intValue();
                String s = intValue.stringValue();
                double d = intValue.doubleValue();
            }

            LrSqsMessageAttributeValue stringVal = LrSqsClient.createMessageAttributeValueString("2.4");
            lr.output_message("type: " + stringVal.dataType());
            double d = stringVal.doubleValue();        // the value can be converted to double

            LrSqsMessageAttributeValue stringVal2 = LrSqsClient.createMessageAttributeValueString("myAttribute");
            lr.output_message("type: " + stringVal2.dataType());
            //double d = stringVal2.doubleValue();        // this line will throw exception - value cannot be converted to double.
            //byte[] b = stringVal2.binaryValue();        // if the attribute is not binary, an exception will be thrown.

            LrSqsMessageAttributeValue binaryVal = LrSqsClient.createMessageAttributeValueBinary("binaryAttrib");
            lr.output_message("type: " + binaryVal.dataType());
            byte[] b = binaryVal.binaryValue();
            byte[] b_copy = binaryVal.binaryValueCopy();

            LrSqsClient.closeClient();

            return 0;
        }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: