|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.perforce.p4java.impl.mapbased.rpc.packet.RpcPacketPreamble
public class RpcPacketPreamble
The five byte preamble appended to every text packet payload.
The format (as divined from the C++ API) is designed to provide a very simple sanity check checksum and encode the length in bytes of the accompanying RPC payload:
byte[1] = ( payload_length / 0x1 ) % 0x100; byte[2] = ( payload_length / 0x100 ) % 0x100; byte[3] = ( payload_length / 0x10000 ) % 0x100; byte[4] = ( payload_length / 0x1000000 ) % 0x100; byte[0] = byte[1] ^ byte[2] ^ byte[3] ^ byte[4];This can generally only be calculated after the other packet elements have been serialized, which is irritating but not too annoying.
Field Summary | |
---|---|
static int |
RPC_PREAMBLE_CHKSUM_SIZE
Size in bytes of the preamble checksum. |
static int |
RPC_PREAMBLE_SIZE
The size in bytes of the standard text packet RPC packet preamble. |
Method Summary | |
---|---|
static RpcPacketPreamble |
constructPreamble(ByteBuffer payload)
Calculate and construct a suitable preamble for the passed-in payload buffer. |
static RpcPacketPreamble |
constructPreamble(int payloadLength)
Calculate and construct a suitable preamble for the passed-in payload buffer length. |
int |
getPayloadSize()
Return the payload size (in bytes) specified by this preamble. |
boolean |
isValidChecksum()
Return true iff the simple checksum checks out. |
ByteBuffer |
marshal()
Return a ByteBuffer representing the marshaled version of this preamble. |
byte[] |
marshalAsBytes()
|
static RpcPacketPreamble |
retrievePreamble(byte[] bytes)
Retrieve the preamble from raw bytes. |
static RpcPacketPreamble |
retrievePreamble(ByteBuffer payload)
Retrieve a preamble from the passed-in payload byte buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RPC_PREAMBLE_CHKSUM_SIZE
public static final int RPC_PREAMBLE_SIZE
Method Detail |
---|
public static RpcPacketPreamble constructPreamble(ByteBuffer payload)
payload
- non-null byte buffer representing the payload
public static RpcPacketPreamble constructPreamble(int payloadLength)
public static RpcPacketPreamble retrievePreamble(ByteBuffer payload)
payload
- non-null payload
public static RpcPacketPreamble retrievePreamble(byte[] bytes)
public int getPayloadSize()
public boolean isValidChecksum()
public ByteBuffer marshal()
public byte[] marshalAsBytes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |