Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.sqs.model;
 

An Amazon SQS message.

 
 public class Message implements SerializableCloneable {

    
A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.
 
     private String messageId;

    
An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.
 
     private String receiptHandle;

    
An MD5 digest of the non-URL-encoded message body string.
 
     private String mD5OfBody;

    
The message's contents (not URL-encoded).
 
     private String body;

    
SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.
 
     private java.util.Map<String,Stringattributes;

    
An MD5 digest of the non-URL-encoded message attribute string. This can be used to verify that Amazon SQS received the message correctly. Amazon SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html.
 
     private String mD5OfMessageAttributes;

    
Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.
 
Default constructor for a new Message object. Callers should use the setter or fluent setter (with...) methods to initialize this object after creating it.
 
     public Message() {}
    
    
A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.

Returns:
A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.
 
     public String getMessageId() {
         return ;
     }
    
    
A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.

Parameters:
messageId A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.
    public void setMessageId(String messageId) {
        this. = messageId;
    }
    
    
A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.

Returns a reference to this object so that method calls can be chained together.

Parameters:
messageId A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Message withMessageId(String messageId) {
        this. = messageId;
        return this;
    }

    
An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.

Returns:
An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.
    public String getReceiptHandle() {
        return ;
    }
    
    
An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.

Parameters:
receiptHandle An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.
    public void setReceiptHandle(String receiptHandle) {
        this. = receiptHandle;
    }
    
    
An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.

Returns a reference to this object so that method calls can be chained together.

Parameters:
receiptHandle An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Message withReceiptHandle(String receiptHandle) {
        this. = receiptHandle;
        return this;
    }

    
An MD5 digest of the non-URL-encoded message body string.

Returns:
An MD5 digest of the non-URL-encoded message body string.
    public String getMD5OfBody() {
        return ;
    }
    
    
An MD5 digest of the non-URL-encoded message body string.

Parameters:
mD5OfBody An MD5 digest of the non-URL-encoded message body string.
    public void setMD5OfBody(String mD5OfBody) {
        this. = mD5OfBody;
    }
    
    
An MD5 digest of the non-URL-encoded message body string.

Returns a reference to this object so that method calls can be chained together.

Parameters:
mD5OfBody An MD5 digest of the non-URL-encoded message body string.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Message withMD5OfBody(String mD5OfBody) {
        this. = mD5OfBody;
        return this;
    }

    
The message's contents (not URL-encoded).

Returns:
The message's contents (not URL-encoded).
    public String getBody() {
        return ;
    }
    
    
The message's contents (not URL-encoded).

Parameters:
body The message's contents (not URL-encoded).
    public void setBody(String body) {
        this. = body;
    }
    
    
The message's contents (not URL-encoded).

Returns a reference to this object so that method calls can be chained together.

Parameters:
body The message's contents (not URL-encoded).
Returns:
A reference to this updated object so that method calls can be chained together.
    public Message withBody(String body) {
        this. = body;
        return this;
    }

    
SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.

Returns:
SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.
    public java.util.Map<String,StringgetAttributes() {
        
        if ( == null) {
             = new java.util.HashMap<String,String>();
        }
        return ;
    }
    
    
SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.

Parameters:
attributes SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.
    public void setAttributes(java.util.Map<String,Stringattributes) {
        this. = attributes;
    }
    
    
SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.

Returns a reference to this object so that method calls can be chained together.

Parameters:
attributes SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Message withAttributes(java.util.Map<String,Stringattributes) {
        setAttributes(attributes);
        return this;
    }

    
SenderId, SentTimestamp, ApproximateReceiveCount, and/or ApproximateFirstReceiveTimestamp. SentTimestamp and ApproximateFirstReceiveTimestamp are each returned as an integer representing the epoch time in milliseconds.

The method adds a new key-value pair into Attributes parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into Attributes.
value The corresponding value of the entry to be added into Attributes.
  public Message addAttributesEntry(String keyString value) {
    if (null == this.) {
      this. = new java.util.HashMap<String,String>();
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into Attributes.

Returns a reference to this object so that method calls can be chained together.

    this. = null;
    return this;
  }
  
    
An MD5 digest of the non-URL-encoded message attribute string. This can be used to verify that Amazon SQS received the message correctly. Amazon SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html.

Returns:
An MD5 digest of the non-URL-encoded message attribute string. This can be used to verify that Amazon SQS received the message correctly. Amazon SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html.
    public String getMD5OfMessageAttributes() {
        return ;
    }
    
    
An MD5 digest of the non-URL-encoded message attribute string. This can be used to verify that Amazon SQS received the message correctly. Amazon SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html.

Parameters:
mD5OfMessageAttributes An MD5 digest of the non-URL-encoded message attribute string. This can be used to verify that Amazon SQS received the message correctly. Amazon SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html.
    public void setMD5OfMessageAttributes(String mD5OfMessageAttributes) {
        this. = mD5OfMessageAttributes;
    }
    
    
An MD5 digest of the non-URL-encoded message attribute string. This can be used to verify that Amazon SQS received the message correctly. Amazon SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html.

Returns a reference to this object so that method calls can be chained together.

Parameters:
mD5OfMessageAttributes An MD5 digest of the non-URL-encoded message attribute string. This can be used to verify that Amazon SQS received the message correctly. Amazon SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Message withMD5OfMessageAttributes(String mD5OfMessageAttributes) {
        this. = mD5OfMessageAttributes;
        return this;
    }

    
Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.

Returns:
Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.
        
        if ( == null) {
             = new java.util.HashMap<String,MessageAttributeValue>();
        }
        return ;
    }
    
    
Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.

Parameters:
messageAttributes Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.
    public void setMessageAttributes(java.util.Map<String,MessageAttributeValuemessageAttributes) {
        this. = messageAttributes;
    }
    
    
Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.

Returns a reference to this object so that method calls can be chained together.

Parameters:
messageAttributes Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Message withMessageAttributes(java.util.Map<String,MessageAttributeValuemessageAttributes) {
        setMessageAttributes(messageAttributes);
        return this;
    }

    
Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.

The method adds a new key-value pair into MessageAttributes parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into MessageAttributes.
value The corresponding value of the entry to be added into MessageAttributes.
    if (null == this.) {
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into MessageAttributes.

Returns a reference to this object so that method calls can be chained together.

    this. = null;
    return this;
  }
  
    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getMessageId() != nullsb.append("MessageId: " + getMessageId() + ",");
        if (getReceiptHandle() != nullsb.append("ReceiptHandle: " + getReceiptHandle() + ",");
        if (getMD5OfBody() != nullsb.append("MD5OfBody: " + getMD5OfBody() + ",");
        if (getBody() != nullsb.append("Body: " + getBody() + ",");
        if (getAttributes() != nullsb.append("Attributes: " + getAttributes() + ",");
        if (getMD5OfMessageAttributes() != nullsb.append("MD5OfMessageAttributes: " + getMD5OfMessageAttributes() + ",");
        if (getMessageAttributes() != nullsb.append("MessageAttributes: " + getMessageAttributes() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getMessageId() == null) ? 0 : getMessageId().hashCode()); 
        hashCode = prime * hashCode + ((getReceiptHandle() == null) ? 0 : getReceiptHandle().hashCode()); 
        hashCode = prime * hashCode + ((getMD5OfBody() == null) ? 0 : getMD5OfBody().hashCode()); 
        hashCode = prime * hashCode + ((getBody() == null) ? 0 : getBody().hashCode()); 
        hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); 
        hashCode = prime * hashCode + ((getMD5OfMessageAttributes() == null) ? 0 : getMD5OfMessageAttributes().hashCode()); 
        hashCode = prime * hashCode + ((getMessageAttributes() == null) ? 0 : getMessageAttributes().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof Message == falsereturn false;
        Message other = (Message)obj;
        
        if (other.getMessageId() == null ^ this.getMessageId() == nullreturn false;
        if (other.getMessageId() != null && other.getMessageId().equals(this.getMessageId()) == falsereturn false
        if (other.getReceiptHandle() == null ^ this.getReceiptHandle() == nullreturn false;
        if (other.getReceiptHandle() != null && other.getReceiptHandle().equals(this.getReceiptHandle()) == falsereturn false
        if (other.getMD5OfBody() == null ^ this.getMD5OfBody() == nullreturn false;
        if (other.getMD5OfBody() != null && other.getMD5OfBody().equals(this.getMD5OfBody()) == falsereturn false
        if (other.getBody() == null ^ this.getBody() == nullreturn false;
        if (other.getBody() != null && other.getBody().equals(this.getBody()) == falsereturn false
        if (other.getAttributes() == null ^ this.getAttributes() == nullreturn false;
        if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == falsereturn false
        if (other.getMD5OfMessageAttributes() == null ^ this.getMD5OfMessageAttributes() == nullreturn false;
        if (other.getMD5OfMessageAttributes() != null && other.getMD5OfMessageAttributes().equals(this.getMD5OfMessageAttributes()) == falsereturn false
        if (other.getMessageAttributes() == null ^ this.getMessageAttributes() == nullreturn false;
        if (other.getMessageAttributes() != null && other.getMessageAttributes().equals(this.getMessageAttributes()) == falsereturn false
        return true;
    }
    
    @Override
    public Message clone() {
        try {
            return (Messagesuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X