public class MqttMessage extends Object
| Constructor and Description | 
|---|
| MqttMessage()Constructs a message with an empty payload, and all other values set to defaults. | 
| MqttMessage(byte[] payload)Constructs a message with the specified byte array as a payload, and all other values set to defaults. | 
| Modifier and Type | Method and Description | 
|---|---|
| byte[] | getPayload()Returns the payload as a byte array. | 
| int | getQos()Returns the quality of service for this message. | 
| boolean | isRetained()Returns whether or not this message should be/was retained by the server. | 
| void | setPayload(byte[] payload)Sets the payload of this message to be the specified byte array. | 
| void | setQos(int qos)Sets the quality of service for this message. | 
| void | setRetained(boolean retained)Whether or not the publish message should be retained by the messaging engine. | 
| String | toString()Returns a string representation of this message's payload. | 
| static void | validateQos(int qos)Utility method to validate the supplied QoS value. | 
public MqttMessage()
public MqttMessage(byte[] payload)
payload - The Bytearray of the payload. Important Note : The array is not cloned for memory efficiency
            reasons. Be careful with it.public byte[] getPayload()
public int getQos()
setQos(int)public boolean isRetained()
true if the message should be, or was, retained by the server.setRetained(boolean)public void setPayload(byte[] payload)
payload - the payload for this message. Important Note : The array is not cloned for memory efficiency
            reasons. Be careful with it.public void setQos(int qos)
qos - the "quality of service" to use. Set to 0 or 1.IllegalArgumentException - if value of QoS is not 0 or 1.IllegalStateException - if this message cannot be editedpublic void setRetained(boolean retained)
true and with an empty byte array as the payload e.g. new byte[0] will clear the
 retained message from the server. The default value is falseretained - whether or not the messaging engine should retain the message.public String toString()
public static void validateQos(int qos)
qos - The QoS LevelIllegalArgumentException - if value of QoS is not 0, 1 or 2.