public class Reader extends Object
Modifier and Type | Field and Description |
---|---|
ByteBuffer |
byteBuffer |
Constructor and Description |
---|
Reader(ByteBuffer byteBuffer) |
Modifier and Type | Method and Description |
---|---|
void |
appendPacket(RawPacket rawPacket)
Add stream to bytebuffer.
|
void |
appendPacket(RawPacket rawPacket,
long encLength)
If next data length is not contain in byteBuffer, add stream.
|
byte |
getByteAt(int position) |
long |
getLengthEncodedBinary()
Get next binary data length.
|
byte[] |
getLengthEncodedBytes()
Get next data bytes with unknown length.
|
byte[] |
getLengthEncodedBytesWithLength(long length)
Get next data bytes with known length.
|
int |
getRemainingSize() |
long |
getSilentLengthEncodedBinary()
Return next binary field length without moving cursor position.
|
String |
getStringLengthEncodedBytes()
Get next String encoded binary from byteBuffer.
|
int |
read24bitword()
Read 24bit encoded length.
|
byte |
readByte()
Reads a byte from the buffer.
|
int |
readInt()
Read a int (4 bytes) from the buffer.
|
long |
readLong()
Read a long (8 bytes) from the buffer.
|
byte[] |
readRawBytes(int numberOfBytes)
Read raw data.
|
short |
readShort()
Read a short (2 bytes) from the buffer.
|
String |
readString(Charset charset)
Reads a string from the buffer, looks for a 0 to end the string.
|
void |
skipByte() |
long |
skipBytes(int bytesToSkip) |
Reader |
skipLengthEncodedBytes()
Skip next length encode binary data.
|
public ByteBuffer byteBuffer
public Reader(ByteBuffer byteBuffer)
public String readString(Charset charset)
charset
- the charset to use, for example ASCIIpublic short readShort()
public int readInt()
public long readLong()
public byte readByte()
public byte[] readRawBytes(int numberOfBytes)
numberOfBytes
- raw data length.public void skipByte()
public long skipBytes(int bytesToSkip)
public Reader skipLengthEncodedBytes()
public int read24bitword()
public long getLengthEncodedBinary()
public byte[] getLengthEncodedBytes() throws IOException
IOException
- if connection problem occurpublic String getStringLengthEncodedBytes() throws IOException
IOException
- if connection problem occurpublic byte[] getLengthEncodedBytesWithLength(long length)
length
- binary data lengthpublic byte getByteAt(int position) throws IOException
IOException
public int getRemainingSize()
public void appendPacket(RawPacket rawPacket)
rawPacket
- stream to add if neededpublic void appendPacket(RawPacket rawPacket, long encLength)
rawPacket
- stream to add if neededencLength
- next data remaining length to fetchpublic long getSilentLengthEncodedBinary()
Copyright © 2015. All rights reserved.