Returns the value of the attribute as a String.

public String stringValue()

Return values

This function returns a String object that represents the value of the attribute.

General information

This function returns the value of the attribute as a String if the data type of the attribute is String. If the data type is not String, then the function converts the value to a String if possible.


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 exeption will be thrown.
        LrSqsMessageAttributeValue binaryVal = LrSqsClient.createMessageAttributeValueBinary("binaryAttrib");
        lr.output_message("type: " + binaryVal.dataType());
        byte[] b = binaryVal.binaryValue();
        byte[] b_copy = binaryVal.binaryValueCopy();

        return 0;