LrSqsMessageAttributeValue.intValue
Returns the value of the attribute as an Integer.
public int intValue()
Return values
This function returns an integer that represents the value of the attribute.
General information
This function returns the value of the attribute as an integer if the data type of the attribute is Integer. If the data type is not Integer, then the function converts the value to an integer if possible. If the value cannot be converted, an exception is thrown.
Example
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;
}