public interface Message
Modifier and Type | Field and Description |
---|---|
static byte |
EMPTY_FIELD
Byte value reserved for representing and empty field in a character based
message.
|
static char |
EMPTY_FIELD_CHAR
Character representation of
EMPTY_FIELD . |
static String |
EMPTY_FIELD_STRING
String representation of
EMPTY_FIELD . |
static byte |
FIELD_DELIMITER
Byte value reserved for use as a field delimiter in character based
Messages.
|
static char |
FIELD_DELIMITER_CHAR
Character representation of
FIELD_DELIMITER . |
static String |
FIELD_DELIMITER_STRING
String representation of
FIELD_DELIMITER . |
static byte |
FIELD_MU
Byte value reserved for representing a single empty field record.
|
static byte |
LIST_DELIMITER
Byte value reserved for use as a list delimiter used for separating the
elements of a list in character based Messages.
|
static char |
LIST_DELIMITER_CHAR
Character representation of
LIST_DELIMITER . |
static String |
LIST_DELIMITER_STRING
String representation of
LIST_DELIMITER . |
static byte |
MESSAGE_SEPARATOR
Byte value reserved for delimiting multiple character based Messages in
buffers.
|
static char |
MESSAGE_SEPARATOR_CHAR
Character representation of
MESSAGE_SEPARATOR . |
static byte |
RECORD_DELIMITER
Byte value reserved for use as a record delimiter in character based
Messages.
|
static char |
RECORD_DELIMITER_CHAR
Character representation of
RECORD_DELIMITER . |
static String |
RECORD_DELIMITER_STRING
String representation of
RECORD_DELIMITER . |
static byte |
RECORD_MU
Byte value reserved for representing a single empty record.
|
Modifier and Type | Method and Description |
---|---|
String |
getHeader(int index)
Returns a header value.
|
List<String> |
getHeaders()
Returns a list of user defined headers.
|
boolean |
isTopicMessage()
Returns true if this is a topic message.
|
void |
setHeaders(List<String> headers)
Sets user defined headers.
|
void |
setHeaders(String... headers)
Sets user defined headers.
|
int |
size()
The total current message size in bytes.
|
String |
toMessage(boolean full)
Returns a string representation of the Message.
|
String |
toString()
Returns a full string representation of the Message.
|
static final byte MESSAGE_SEPARATOR
static final char MESSAGE_SEPARATOR_CHAR
MESSAGE_SEPARATOR
.static final byte RECORD_DELIMITER
static final char RECORD_DELIMITER_CHAR
RECORD_DELIMITER
.static final String RECORD_DELIMITER_STRING
RECORD_DELIMITER
. Useful for
String.split operations.static final byte FIELD_DELIMITER
static final char FIELD_DELIMITER_CHAR
FIELD_DELIMITER
.static final String FIELD_DELIMITER_STRING
FIELD_DELIMITER
. Useful for
String.split operations.static final byte EMPTY_FIELD
static final char EMPTY_FIELD_CHAR
EMPTY_FIELD
.static final String EMPTY_FIELD_STRING
EMPTY_FIELD
. Useful for String
comparisons.static final byte RECORD_MU
If a message contains this value only then it is interpreted as containing a single empty record.
static final byte FIELD_MU
If this value is used as the only value in a record within a message then it is interpreted as a single empty value (i.e. a zero length string) and so may be used to distinguish between a record that has a single empty value and a record with no values.
static final byte LIST_DELIMITER
static final char LIST_DELIMITER_CHAR
LIST_DELIMITER
.static final String LIST_DELIMITER_STRING
LIST_DELIMITER
. Useful for String.split
operations.boolean isTopicMessage()
TopicMessage
void setHeaders(String... headers) throws MessageException
One or more separate headers may be set as required.
Headers may be set once and only once after constructing a message and before any data is added to the message.
headers
- a list of user defined header values.MessageException
- if unable to set headers, possibly because data
has already been written to the message.void setHeaders(List<String> headers) throws MessageException
One or more separate headers may be set as required.
Headers may be set once and only once after constructing a message and before any data is added to the message.
headers
- a list of user defined header values.MessageException
- if unable to set headers, possibly because data
has already been written to the message.List<String> getHeaders()
String getHeader(int index)
index
- the header index (first header has index 0).int size()
This is deemed to be the header length (fixed+user headers) plus the current length of any data in bytes.
String toString()
This will show Length, Type, Encoding, any headers and any data. This is
effectively the same as calling toMessage(boolean)
with
full=true.
String toMessage(boolean full)
This will show Length, Type, Encoding, any headers and optionally any data.
full
- if this is false then any data associated with the Message
will not be returned. If true then data is included (which is the
equivalent of calling toString()
.Copyright © 2016 Push Technology Ltd. All Rights Reserved.