public abstract class Message
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Message.Direction
The message direction with respect to the device.
|
static class |
Message.MessageBuilder<T extends Message.MessageBuilder<T>>
This is an abstract class for different message builders.
|
static class |
Message.Priority
The priority of the message.
|
static class |
Message.Reliability
Reliability of the message
|
static class |
Message.Type
The message type.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DIAG_CLIENT_ADDRESS
Client address diagnostic value.
|
static java.lang.String |
DIAG_CREATED_TIME
Created time of the message diagnostic value.
|
Modifier and Type | Method and Description |
---|---|
static java.util.List<Message.MessageBuilder> |
createBuilderFromJson(byte[] messagesByteArray)
Convert a byte array to a
List of
Message.MessageBuilder s. |
boolean |
equals(java.lang.Object o) |
static java.util.List<Message> |
fromJson(byte[] messagesByteArray)
Convert a byte array to a
List of Message s. |
static java.util.List<Message> |
fromJson(java.lang.Object structure)
|
static java.util.List<Message> |
fromJson(java.lang.String jsonString)
Convert a json string to a
List of Message s. |
java.lang.String |
getClientId()
Get client's unique ID for a message.
|
java.lang.String |
getDestination()
Get message destination (Endpoint Id to which the message is originated).
|
java.util.Map<java.lang.String,java.lang.Object> |
getDiagnostics()
Get message diagnostics
|
java.lang.Object |
getDiagnosticValue(java.lang.String diagName) |
Message.Direction |
getDirection()
Get message direction.
|
java.lang.Long |
getEventTime()
Get event time of the message
|
java.lang.String |
getId()
Get unique ID for a message.
|
long |
getOrdinal()
Get the order in which this message was created.
|
Message.Priority |
getPriority()
Get message priority.
|
MessageProperties |
getProperties()
Get message properties.
|
java.lang.Long |
getReceivedTime()
Get message received time.
|
Message.Reliability |
getReliability()
Get message reliability
|
int |
getRemainingRetries()
Not intended for general use.
|
java.lang.String |
getSender()
Get message sender (Endpoint Id from which the message is sent from).
|
java.lang.Long |
getSentTime()
Get message sent time.
|
java.lang.String |
getSource()
Get message source (Endpoint Id from which the message is originated).
|
abstract Message.Type |
getType()
Abstract method to return message type.
|
int |
hashCode() |
static java.lang.String |
prettyPrintJson(byte[] json) |
static java.lang.String |
prettyPrintJson(org.json.JSONArray json) |
static java.lang.String |
prettyPrintJson(org.json.JSONObject json) |
static java.lang.String |
prettyPrintJson(java.lang.String jsonString) |
void |
setRemainingRetries(int remainingRetries)
Not intended for general use.
|
org.json.JSONObject |
toJson()
Export the basic properties of the message to
JSONObject . |
static org.json.JSONArray |
toJson(java.util.List<? extends Message> messages)
Convert a
List of messages into a JSONArray . |
static org.json.JSONArray |
toJson(java.util.List<Message> messages,
boolean expand)
|
java.lang.String |
toString()
Exports common data from
Message to String using JSON interpretation of the message. |
public static final java.lang.String DIAG_CREATED_TIME
Long
that
contains the epoch value in milliseconds.public static final java.lang.String DIAG_CLIENT_ADDRESS
String
public final java.lang.String getId()
String
), never null
public abstract Message.Type getType()
null
.public final java.lang.String getClientId()
String
), never null
public final java.lang.String getSource()
null
if the message was sent from server.public final java.lang.String getDestination()
null
if the message was sent to server.public final Message.Priority getPriority()
null
.public final Message.Reliability getReliability()
null
.public final java.lang.Long getEventTime()
null
.public final MessageProperties getProperties()
null
public final java.lang.String getSender()
public final long getOrdinal()
public final int getRemainingRetries()
public void setRemainingRetries(int remainingRetries)
remainingRetries
- the new number of remaining retriespublic final java.util.Map<java.lang.String,java.lang.Object> getDiagnostics()
null
public final java.lang.Object getDiagnosticValue(java.lang.String diagName)
public final Message.Direction getDirection()
null
public final java.lang.Long getReceivedTime()
null
public final java.lang.Long getSentTime()
null
public java.lang.String toString()
Message
to String
using JSON interpretation of the message.toString
in class java.lang.Object
String
.public org.json.JSONObject toJson()
JSONObject
.null
public static org.json.JSONArray toJson(java.util.List<? extends Message> messages)
List
of messages into a JSONArray
.public static org.json.JSONArray toJson(java.util.List<Message> messages, boolean expand)
public static java.util.List<Message> fromJson(byte[] messagesByteArray)
List
of Message
s.messagesByteArray
- byte[]
containing json interpretation of Message
sList
of Message
s from the byte[]
MessageParsingException
- when messageArray is null
.public static java.util.List<Message> fromJson(java.lang.String jsonString)
List
of Message
s.jsonString
- String
containing json interpretation of
Message
sList
of Message
s from the jsonString.MessageParsingException
- when jsonString is null
.public static java.util.List<Message> fromJson(java.lang.Object structure)
structure
- Object
containing Message
sList
of Message
sMessageParsingException
- when structure is null
or
when other exception occur during parsingpublic static java.util.List<Message.MessageBuilder> createBuilderFromJson(byte[] messagesByteArray)
List
of
Message.MessageBuilder
s.messagesByteArray
- byte[]
containing json interpretation
of Message
sList
of
Message.MessageBuilder
s from
the byte[]
MessageParsingException
- when messageArray is null
.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static java.lang.String prettyPrintJson(org.json.JSONObject json)
public static java.lang.String prettyPrintJson(org.json.JSONArray json)
public static java.lang.String prettyPrintJson(java.lang.String jsonString)
public static java.lang.String prettyPrintJson(byte[] json)