public class Payload
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static int |
PAYLOAD_SIZE_POSITION |
protected static int |
PAYLOAD_START_POSITION |
protected RequestResponseCode |
requestResponseCode |
Modifier | Constructor and Description |
---|---|
protected |
Payload(byte[] packet)
Constructor used to create a Payload (when no more specific subclasses exists) using packet as parameter.
|
|
Payload(RequestResponseCode requestResponseCode)
Consructor used to create Payload with a payload size of zero using a RRCode.
|
Modifier and Type | Method and Description |
---|---|
private void |
checkRequestResponseCode()
Used to check RRCode used is compatible with this class use, or if a more specific subclass is required.
|
protected static int |
getPayloadSize(byte[] packet)
Get payload’s size from a Packet.
|
RequestResponseCode |
getRequestResponseCode()
RRCode getter.
|
protected static void |
setPayloadSize(int size,
byte[] packet)
Set payload’s size in a Packet.
|
protected byte[] |
toPacket()
Returns a byte[] containing Packet with padding.
|
protected RequestResponseCode requestResponseCode
protected static final int PAYLOAD_SIZE_POSITION
protected static final int PAYLOAD_START_POSITION
public Payload(RequestResponseCode requestResponseCode) throws InternalError
requestResponseCode
- Request/Response code associated with the payloadInternalError
protected Payload(byte[] packet) throws SizeError, ProtocolError, InternalError, TransmissionError
packet
- the full packet receivedProtocolError
InternalError
TransmissionError
SizeError
private void checkRequestResponseCode() throws InternalError
InternalError
protected byte[] toPacket() throws InternalError
InternalError
protected static void setPayloadSize(int size, byte[] packet) throws InternalError
size
- integer representing payload sizepacket
- Packet to be completedInternalError
protected static int getPayloadSize(byte[] packet) throws SizeError
packet
- the full Packet receivedSizeError
public RequestResponseCode getRequestResponseCode()