public class Message extends Object implements Iterable<Message.Frame>
Modifier and Type | Class and Description |
---|---|
static class |
Message.Frame
Represents a single frame of data within a message.
|
static class |
Message.FrameBuilder
Builder for constructing efficient binary representations of multi-value
data frames using a dynamically sized buffer.
|
Modifier and Type | Field and Description |
---|---|
static Charset |
CHARSET
Default charset, to be customized by the application, or set via property.
|
static Message.Frame |
EMPTY_FRAME
A handy reference to an empty
Message.Frame . |
Constructor and Description |
---|
Message()
Construct an empty message.
|
Message(byte[] firstFrame)
Construct a message with a single
byte[] frame. |
Message(int firstFrame)
Construct a message with a single
int frame. |
Message(List<Message.Frame> frames)
Construct a message with the given frames.
|
Message(long firstFrame)
Construct a message with a single
long frame. |
Message(Message.Frame firstFrame)
Construct a message with a single frame.
|
Message(Message message)
Construct a message by cloning the given message's frames.
|
Message(String firstFrame)
Construct a message with a single String frame.
|
Modifier and Type | Method and Description |
---|---|
Message |
addBuffer(ByteBuffer frame)
Add a frame containing bytes in the given Buffer to the end of the list.
|
Message |
addByte(byte frame)
Add a frame containing a
byte to the end of the list. |
Message |
addBytes(byte[] frame)
Add a frame containing the given bytes to the end of the list.
|
Message |
addClobs(List<String> strings)
Add a frame containing a List of String values to the end of the list.
|
Message |
addEmptyFrame()
Add an empty frame to the end of the list.
|
Message |
addFrame(Message.Frame frame)
Add a frame to the end of the list.
|
Message |
addFrames(List<Message.Frame> frames)
Add the given frames to the end of the list.
|
Message |
addFrames(Message payload)
Add all frames from the given Message to the end of the list.
|
Message |
addInt(int frame)
Add a frame containing an
int value to the end of the list. |
Message |
addLong(long frame)
Add a frame containing a
long value to the end of the list. |
Message |
addMap(Map<String,String> map)
Add a frame containing a Map of String pairs to the end of the list.
|
Message |
addShort(short frame)
Add a frame containing a
short value to the end of the list. |
Message |
addString(String frame)
Add a frame containing a String value to the end of the list.
|
Message |
addStrings(List<String> strings)
Add a frame containing a List of String values to the end of the list.
|
protected StringBuilder |
dump(StringBuilder sb)
Dump the message in human readable format.
|
Message.Frame |
getFirstFrame()
Return the first frame in the list.
|
List<Message.Frame> |
getFrames()
Return a copy of the list of frames contained in this message.
|
boolean |
isEmpty()
Returns
true if this message contains no frames. |
boolean |
isMissing()
An alias for
isEmpty() . |
Iterator<Message.Frame> |
iterator()
Returns an iterator over the frames in this message.
|
byte |
popByte()
Remove a frame from the beginning of the list and convert to a
byte . |
byte[] |
popBytes()
Remove a frame from the beginning of the list and convert to a
byte[] . |
List<String> |
popClobs()
Remove a frame containing a List of String values from the beginning of the list.
|
Message.Frame |
popFrame()
Remove a frame from the beginning of the list.
|
int |
popInt()
Remove a frame from the beginning of the list and convert to an
int . |
long |
popLong()
Remove a frame from the beginning of the list and convert to a
long . |
Map<String,String> |
popMap()
Remove a frame containing a Map of String pairs from the beginning of the list.
|
short |
popShort()
Remove a frame from the beginning of the list and convert to a
short . |
String |
popString()
Remove a frame containing a String value from the beginning of the list.
|
List<String> |
popStrings()
Remove a frame containing a List of String values from the beginning of the list.
|
Message |
pushBuffer(ByteBuffer frame)
Add a frame containing bytes in the given Buffer to the beginning of the list.
|
Message |
pushByte(byte frame)
Add a frame containing a
byte to the beginning of the list. |
Message |
pushBytes(byte[] frame)
Add a frame containing the given bytes to the beginning of the list.
|
Message |
pushClobs(List<String> strings)
Add a frame containing a List of String values to the beginning of the list.
|
Message |
pushFrame(Message.Frame frame)
Add a frame to the beginning of the list.
|
Message |
pushFrames(List<Message.Frame> frames)
Add frames to the beginning of the list, in reverse order, such that the
elements are in the same order as in the original List.
|
Message |
pushFrames(Message payload)
Add frames to the beginning of the list, in reverse order, such that
the elements are in the same order as in the original Message.
|
Message |
pushInt(int frame)
Add a frame containing an
int value to the beginning of the list. |
Message |
pushLong(long frame)
Add a frame containing a
long value to the beginning of the list. |
Message |
pushMap(Map<String,String> map)
Add a frame containing a Map of String pairs to the beginning of the list.
|
Message |
pushShort(short frame)
Add a frame containing a
short value to the beginning of the list. |
Message |
pushString(String frame)
Add a frame containing a String value to the beginning of the list.
|
Message |
pushStrings(List<String> strings)
Add a frame containing a List of String values to the beginning of the list.
|
int |
size()
Returns the number of frames in this message.
|
String |
toString()
Convert the message to a string, for use in debugging.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static Charset CHARSET
public static final Message.Frame EMPTY_FRAME
Message.Frame
.public Message()
public Message(String firstFrame)
firstFrame
- The first frame in the new messagepublic Message(byte[] firstFrame)
byte[]
frame.firstFrame
- The first frame in the new messagepublic Message(int firstFrame)
int
frame.firstFrame
- The first frame in the new messagepublic Message(long firstFrame)
long
frame.firstFrame
- The first frame in the new messagepublic Message(Message.Frame firstFrame)
firstFrame
- The first frame in the new messagepublic Message(List<Message.Frame> frames)
frames
- The initial list of frames to populate the messagepublic Message(Message message)
message
- The original message to clonepublic List<Message.Frame> getFrames()
public Message addFrame(Message.Frame frame)
frame
- The frame to be addedpublic Message addEmptyFrame()
public Message.Frame getFirstFrame()
public Message pushFrame(Message.Frame frame)
frame
- The frame to be addedpublic Message.Frame popFrame()
public Message addString(String frame)
frame
- The frame to be added, as a Stringpublic Message pushString(String frame)
frame
- The frame to be added, as a Stringpublic String popString()
public Message addStrings(List<String> strings)
strings
- The frame to be added, as a List of Stringspublic Message pushStrings(List<String> strings)
strings
- The frame to be added, as a List of Stringspublic List<String> popStrings()
public Message addClobs(List<String> strings)
strings
- The frame to be added, as a List of Stringspublic Message pushClobs(List<String> strings)
strings
- The frame to be added, as a List of Stringspublic List<String> popClobs()
public Message addMap(Map<String,String> map)
map
- The frame to be added, as a Mappublic Message pushMap(Map<String,String> map)
map
- The frame to be addedpublic Map<String,String> popMap()
public Message addInt(int frame)
int
value to the end of the list.frame
- The frame to be addedpublic Message pushInt(int frame)
int
value to the beginning of the list.frame
- The frame to be addedpublic int popInt()
int
.public Message addLong(long frame)
long
value to the end of the list.frame
- The frame to be addedpublic Message pushLong(long frame)
long
value to the beginning of the list.frame
- The frame to be addedpublic long popLong()
long
.public Message addShort(short frame)
short
value to the end of the list.frame
- The frame to be addedpublic Message pushShort(short frame)
short
value to the beginning of the list.frame
- The frame to be addedpublic short popShort()
short
.public Message addByte(byte frame)
byte
to the end of the list.frame
- The frame to be addedpublic Message pushByte(byte frame)
byte
to the beginning of the list.frame
- The frame to be addedpublic byte popByte()
byte
.public Message addBuffer(ByteBuffer frame)
frame
- The frame to be addedpublic Message pushBuffer(ByteBuffer frame)
frame
- The frame to be addedpublic Message addBytes(byte[] frame)
frame
- The frame to be addedpublic Message pushBytes(byte[] frame)
frame
- The frame to be addedpublic byte[] popBytes()
byte[]
.public Message addFrames(List<Message.Frame> frames)
frames
- The frames to be addedpublic Message addFrames(Message payload)
payload
- The original message, containing frames to be addedpublic Message pushFrames(List<Message.Frame> frames)
frames
- The frames to be addedpublic Message pushFrames(Message payload)
payload
- The original message, containing frames to be addedpublic boolean isMissing()
isEmpty()
.public boolean isEmpty()
true
if this message contains no frames.public int size()
public Iterator<Message.Frame> iterator()
iterator
in interface Iterable<Message.Frame>
protected StringBuilder dump(StringBuilder sb)
This should only be used for debugging and tracing, inefficient in handling large messages.
sb
- The StringBuilderCopyright © 2019. All rights reserved.