public final class PacketUtils extends Object
|Modifier and Type||Method and Description|
Check the length of the input buffer is appropriate given the offset and length parameters.
Check that there are enough bytes in the buffer to read some number of bytes that we need to read a full header.
Check the input parameters are sane and there's enough bytes to read the required length.
public static void checkBufferLength(int byteLength, int offset, int length) throws DeserializationException
byteLength- length of the input buffer array
offset- offset given to begin reading bytes from
length- length given to read up until
DeserializationException- if the input parameters don't match up (i.e we can't read that many bytes from the buffer at the given offest)
public static void checkHeaderLength(int givenLength, int requiredLength) throws DeserializationException
givenLength- given size of the buffer
requiredLength- number of bytes we need to read some header fully
DeserializationException- if there aren't enough bytes
public static void checkInput(byte data, int offset, int length, int requiredLength) throws DeserializationException
data- input byte buffer
offset- offset of the start of the header
length- length given to deserialize the header
requiredLength- length needed to deserialize header
DeserializationException- if we're unable to deserialize the packet based on the input parameters