public abstract class FrameWriter
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.nio.ByteBuffer |
frameBytes |
| Constructor and Description |
|---|
FrameWriter() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.nio.ByteBuffer |
buildFrame(byte[] header,
int headerOffset,
int headerLength,
byte[] payload,
int payloadOffset,
int payloadLength) |
void |
clear()
Release the byte buffer.
|
boolean |
isComplete() |
void |
withHeaderAndPayload(byte[] header,
byte[] payload)
Provide (maybe empty) header and payload to the frame.
|
void |
withHeaderAndPayload(byte[] header,
int headerOffset,
int headerLength,
byte[] payload,
int payloadOffset,
int payloadLength)
Provide extra header and payload to the frame.
|
void |
withOnlyPayload(byte[] payload)
Provide only payload to the frame.
|
abstract void |
withOnlyPayload(byte[] payload,
int offset,
int length)
Provide only payload to the frame.
|
void |
write(TNonblockingTransport transport)
Nonblocking write to the underlying transport.
|
public void withHeaderAndPayload(byte[] header,
byte[] payload)
header - Some extra header bytes (without the 4 bytes for payload length), which will be
the start of the frame. It can be empty, depending on the message formatpayload - Payload as a byte arrayjava.lang.IllegalStateException - if it is called when isComplete returns falsejava.lang.IllegalArgumentException - if header or payload is invalidpublic void withHeaderAndPayload(byte[] header,
int headerOffset,
int headerLength,
byte[] payload,
int payloadOffset,
int payloadLength)
header - byte array containing the extra headerheaderOffset - starting offset of the header portitionheaderLength - length of the extra headerpayload - byte array containing the payloadpayloadOffset - starting offset of the payload portionpayloadLength - length of the payloadjava.lang.IllegalStateException - if preivous frame is not yet complete (isComplete returns fals)java.lang.IllegalArgumentException - if header or payload is invalidpublic void withOnlyPayload(byte[] payload)
payload - payload as a byte arraypublic abstract void withOnlyPayload(byte[] payload,
int offset,
int length)
payload - The underlying byte array as a recipient of the payloadoffset - The offset in the byte array starting from where the payload is locatedlength - The length of the payloadprotected abstract java.nio.ByteBuffer buildFrame(byte[] header,
int headerOffset,
int headerLength,
byte[] payload,
int payloadOffset,
int payloadLength)
public void write(TNonblockingTransport transport) throws TTransportException
TTransportExceptionpublic boolean isComplete()
public void clear()