public interface BufferInput<T extends BufferInput<?>> extends AutoCloseable
This interface exposes methods for reading from a byte buffer. Readable buffers maintain a small amount of state
regarding current cursor positions and limits similar to the behavior of ByteBuffer.
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
hasRemaining()
Returns a boolean value indicating whether the input has bytes remaining.
|
int |
position()
Returns the buffer's current read/write position.
|
T |
read(Buffer buffer)
Reads bytes into the given buffer.
|
T |
read(byte[] bytes)
Reads bytes into the given byte array.
|
T |
read(byte[] bytes,
int offset,
int length)
Reads bytes into the given byte array starting at current position up to the given length.
|
T |
read(Bytes bytes)
Reads bytes into the given byte array.
|
T |
read(Bytes bytes,
int offset,
int length)
Reads bytes into the given byte array starting at the current position.
|
boolean |
readBoolean()
Reads a 1 byte boolean from the buffer at the current position.
|
int |
readByte()
Reads a byte from the buffer at the current position.
|
default byte[] |
readBytes(int length)
Reads a byte array.
|
char |
readChar()
Reads a 16-bit character from the buffer at the current position.
|
double |
readDouble()
Reads a double-precision 64-bit floating point number from the buffer at the current position.
|
float |
readFloat()
Reads a single-precision 32-bit floating point number from the buffer at the current position.
|
int |
readInt()
Reads a 32-bit signed integer from the buffer at the current position.
|
long |
readLong()
Reads a 64-bit signed integer from the buffer at the current position.
|
int |
readMedium()
Reads a 24-bit signed integer from the buffer at the current position.
|
short |
readShort()
Reads a 16-bit signed integer from the buffer at the current position.
|
String |
readString()
Reads a string from the buffer at the current position.
|
String |
readString(Charset charset)
Reads a string from the buffer at the current position.
|
int |
readUnsignedByte()
Reads an unsigned byte from the buffer at the current position.
|
long |
readUnsignedInt()
Reads a 32-bit unsigned integer from the buffer at the current position.
|
int |
readUnsignedMedium()
Reads a 24-bit unsigned integer from the buffer at the current position.
|
int |
readUnsignedShort()
Reads a 16-bit unsigned integer from the buffer at the current position.
|
String |
readUTF8()
Reads a UTF-8 string from the buffer at the current position.
|
int |
remaining()
Returns the number of bytes remaining in the input.
|
T |
skip(int bytes)
Skips the given number of bytes in the input.
|
int position()
The position is an internal cursor that tracks where to write/read bytes in the underlying storage implementation. As bytes are written to or read from the buffer, the position will advance based on the number of bytes read.
int remaining()
boolean hasRemaining()
T skip(int bytes)
bytes - The number of bytes to attempt to skip.T read(Bytes bytes)
bytes - The byte array into which to read bytes.T read(byte[] bytes)
bytes - The byte array into which to read bytes.T read(Bytes bytes, int offset, int length)
bytes - The byte array into which to read bytes.offset - The offset at which to write bytes into the given bufferT read(byte[] bytes, int offset, int length)
bytes - The byte array into which to read bytes.offset - The offset at which to write bytes into the given bufferT read(Buffer buffer)
buffer - The buffer into which to read bytes.default byte[] readBytes(int length)
length - The byte array lengthint readByte()
int readUnsignedByte()
char readChar()
short readShort()
int readUnsignedShort()
int readMedium()
int readUnsignedMedium()
int readInt()
long readUnsignedInt()
long readLong()
float readFloat()
double readDouble()
boolean readBoolean()
String readString()
String readString(Charset charset)
charset - The character set with which to decode the string.String readUTF8()
void close()
close in interface AutoCloseableCopyright © 2013–2018. All rights reserved.