public abstract class AbstractBuffer extends Object implements Buffer
| Modifier and Type | Method and Description |
|---|---|
Buffer |
acquire()
Acquires a reference.
|
Buffer |
asReadOnlyBuffer()
Returns a read-only view of the buffer.
|
Bytes |
bytes()
Returns the bytes underlying the buffer.
|
long |
capacity()
Returns the buffer's capacity.
|
Buffer |
capacity(long capacity)
Updates the buffer capacity.
|
Buffer |
clear()
Clears the buffer.
|
void |
close()
Closes the buffer.
|
Buffer |
compact()
Compacts the buffer, moving bytes from the current position to the end of the buffer to the head of the buffer.
|
Buffer |
flip()
Flips the buffer.
|
Buffer |
flush()
Flushes the bytes to the underlying persistence layer.
|
boolean |
hasRemaining()
Returns a boolean indicating whether the buffer has bytes remaining.
|
boolean |
isDirect()
Returns a boolean value indicating whether the buffer is a direct buffer.
|
boolean |
isFile()
Returns a boolean value indicating whether the buffer is backed by a file.
|
boolean |
isReadOnly()
Returns a boolean value indicating whether the buffer is a read-only buffer.
|
long |
limit()
Returns the buffer's read/write limit.
|
Buffer |
limit(long limit)
Sets the buffer's read/write limit.
|
Buffer |
mark()
Sets a mark at the current position.
|
long |
maxCapacity()
Returns the maximum allowed capacity for the buffer.
|
long |
offset()
Returns the buffer's starting offset within the underlying
Bytes. |
ByteOrder |
order()
Returns the byte order.
|
Buffer |
order(ByteOrder order)
Sets the byte order, returning a new swapped
Buffer instance. |
long |
position()
Returns the buffer's current read/write position.
|
Buffer |
position(long position)
Sets the buffer's current read/write position.
|
Buffer |
read(Buffer buffer)
Reads bytes into the given buffer.
|
Buffer |
read(byte[] bytes)
Reads bytes into the given byte array.
|
Buffer |
read(byte[] bytes,
long offset,
long length)
Reads bytes into the given byte array starting at current position up to the given length.
|
Buffer |
read(Bytes bytes)
Reads bytes into the given byte array.
|
Buffer |
read(Bytes bytes,
long offset,
long length)
Reads bytes into the given byte array starting at the current position.
|
Buffer |
read(long srcOffset,
byte[] bytes,
long dstOffset,
long length)
Reads bytes into the given byte array starting at the given offset up to the given length.
|
Buffer |
read(long srcOffset,
Bytes bytes,
long dstOffset,
long length)
Reads bytes into the given byte array starting at the given offset up to the given length.
|
boolean |
readBoolean()
Reads a 1 byte boolean from the buffer at the current position.
|
boolean |
readBoolean(long offset)
Reads a 1 byte boolean from the buffer at the given offset.
|
int |
readByte()
Reads a byte from the buffer at the current position.
|
int |
readByte(long offset)
Reads a byte from the buffer at the given offset.
|
char |
readChar()
Reads a 16-bit character from the buffer at the current position.
|
char |
readChar(long offset)
Reads a 16-bit character from the buffer at the given offset.
|
double |
readDouble()
Reads a double-precision 64-bit floating point number from the buffer at the current position.
|
double |
readDouble(long offset)
Reads a double-precision 64-bit floating point number from the buffer at the given offset.
|
float |
readFloat()
Reads a single-precision 32-bit floating point number from the buffer at the current position.
|
float |
readFloat(long offset)
Reads a single-precision 32-bit floating point number from the buffer at the given offset.
|
int |
readInt()
Reads a 32-bit signed integer from the buffer at the current position.
|
int |
readInt(long offset)
Reads a 32-bit signed integer from the buffer at the given offset.
|
long |
readLong()
Reads a 64-bit signed integer from the buffer at the current position.
|
long |
readLong(long offset)
Reads a 64-bit signed integer from the buffer at the given offset.
|
int |
readMedium()
Reads a 24-bit signed integer from the buffer at the current position.
|
int |
readMedium(long offset)
Reads a 24-bit signed integer from the buffer at the given offset.
|
short |
readShort()
Reads a 16-bit signed integer from the buffer at the current position.
|
short |
readShort(long offset)
Reads a 16-bit signed integer from the buffer at the given offset.
|
String |
readString()
Reads a string from the buffer at the current position.
|
String |
readString(long offset)
Reads a string from the buffer at the given offset.
|
int |
readUnsignedByte()
Reads an unsigned byte from the buffer at the current position.
|
int |
readUnsignedByte(long offset)
Reads an unsigned byte from the buffer at the given offset.
|
long |
readUnsignedInt()
Reads a 32-bit unsigned integer from the buffer at the current position.
|
long |
readUnsignedInt(long offset)
Reads a 32-bit unsigned integer from the buffer at the given offset.
|
int |
readUnsignedMedium()
Reads a 24-bit unsigned integer from the buffer at the current position.
|
int |
readUnsignedMedium(long offset)
Reads a 24-bin unsigned integer from the buffer at the given offset.
|
int |
readUnsignedShort()
Reads a 16-bit unsigned integer from the buffer at the current position.
|
int |
readUnsignedShort(long offset)
Reads a 16-bit unsigned integer from the buffer at the given offset.
|
String |
readUTF8()
Reads a UTF-8 string from the buffer at the current position.
|
String |
readUTF8(long offset)
Reads a UTF-8 string from the buffer at the given offset.
|
int |
references()
Returns the number of open references.
|
boolean |
release()
Releases a reference.
|
long |
remaining()
Returns the number of bytes remaining in the buffer until the
Buffer.limit() is reached. |
Buffer |
reset()
Resets the buffer's position to the previously-marked position.
|
Buffer |
rewind()
Rewinds the buffer.
|
Buffer |
skip(long length)
Advances the buffer's
position length bytes. |
Buffer |
slice()
Returns a view of this buffer starting at the current position.
|
Buffer |
slice(long length)
Returns a view of this buffer of the given length starting at the current position.
|
Buffer |
slice(long offset,
long length)
Returns a view of this buffer starting at the given offset with the given length.
|
Buffer |
write(Buffer buffer)
Writes a buffer to the buffer.
|
Buffer |
write(byte[] bytes)
Writes an array of bytes to the buffer.
|
Buffer |
write(byte[] bytes,
long offset,
long length)
Writes an array of bytes to the buffer.
|
Buffer |
write(Bytes bytes)
Writes an array of bytes to the buffer.
|
Buffer |
write(Bytes bytes,
long offset,
long length)
Writes an array of bytes to the buffer.
|
Buffer |
write(long offset,
byte[] bytes,
long srcOffset,
long length)
Writes an array of bytes to the buffer.
|
Buffer |
write(long offset,
Bytes bytes,
long srcOffset,
long length)
Writes an array of bytes to the buffer.
|
Buffer |
writeBoolean(boolean b)
Writes a 1 byte boolean to the buffer at the current position.
|
Buffer |
writeBoolean(long offset,
boolean b)
Writes a 1 byte boolean to the buffer at the given offset.
|
Buffer |
writeByte(int b)
Writes a byte to the buffer at the current position.
|
Buffer |
writeByte(long offset,
int b)
Writes a byte to the buffer at the given offset.
|
Buffer |
writeChar(char c)
Writes a 16-bit character to the buffer at the current position.
|
Buffer |
writeChar(long offset,
char c)
Writes a 16-bit character to the buffer at the given offset.
|
Buffer |
writeDouble(double d)
Writes a double-precision 64-bit floating point number to the buffer at the current position.
|
Buffer |
writeDouble(long offset,
double d)
Writes a double-precision 64-bit floating point number to the buffer at the given offset.
|
Buffer |
writeFloat(float f)
Writes a single-precision 32-bit floating point number to the buffer at the current position.
|
Buffer |
writeFloat(long offset,
float f)
Writes a single-precision 32-bit floating point number to the buffer at the given offset.
|
Buffer |
writeInt(int i)
Writes a 32-bit signed integer to the buffer at the current position.
|
Buffer |
writeInt(long offset,
int i)
Writes a 32-bit signed integer to the buffer at the given offset.
|
Buffer |
writeLong(long l)
Writes a 64-bit signed integer to the buffer at the current position.
|
Buffer |
writeLong(long offset,
long l)
Writes a 64-bit signed integer to the buffer at the given offset.
|
Buffer |
writeMedium(int m)
Writes a 24-bit signed integer to the buffer.
|
Buffer |
writeMedium(long offset,
int m)
Writes a 24-bit signed integer to the buffer at the given offset.
|
Buffer |
writeShort(long offset,
short s)
Writes a 16-bit signed integer to the buffer at the given offset.
|
Buffer |
writeShort(short s)
Writes a 16-bit signed integer to the buffer at the current position.
|
Buffer |
writeString(long offset,
String s)
Writes a string to the buffer at the given offset.
|
Buffer |
writeString(String s)
Writes a string to the buffer.
|
Buffer |
writeUnsignedByte(int b)
Writes an unsigned byte to the buffer at the current position.
|
Buffer |
writeUnsignedByte(long offset,
int b)
Writes an unsigned byte to the buffer at the given offset.
|
Buffer |
writeUnsignedInt(long i)
Writes a 32-bit signed integer to the buffer at the current position.
|
Buffer |
writeUnsignedInt(long offset,
long i)
Writes a 32-bit signed integer to the buffer at the given offset.
|
Buffer |
writeUnsignedMedium(int m)
Writes a 24-bit unsigned integer to the buffer.
|
Buffer |
writeUnsignedMedium(long offset,
int m)
Writes a 24-bit unsigned integer to the buffer at the given offset.
|
Buffer |
writeUnsignedShort(int s)
Writes a 16-bit signed integer to the buffer at the current position.
|
Buffer |
writeUnsignedShort(long offset,
int s)
Writes a 16-bit signed integer to the buffer at the given offset.
|
Buffer |
writeUTF8(long offset,
String s)
Writes a UTF-8 string to the buffer at the given offset.
|
Buffer |
writeUTF8(String s)
Writes a UTF-8 string to the buffer at the current position.
|
Buffer |
zero()
Zeros out all bytes in the array.
|
Buffer |
zero(long offset)
Zeros out all bytes starting at the given offset in the array.
|
Buffer |
zero(long offset,
long length)
Zeros out bytes starting at the given offset up to the given length.
|
public Buffer acquire()
ReferenceCountedacquire in interface ReferenceCounted<Buffer>public boolean release()
ReferenceCountedrelease in interface ReferenceCounted<Buffer>public int references()
ReferenceCountedreferences in interface ReferenceCounted<Buffer>public ByteOrder order()
Buffer
For consistency with ByteBuffer, all buffer implementations are initially in ByteOrder.BIG_ENDIAN order.
public Buffer order(ByteOrder order)
BufferBuffer instance.
By default, all buffers are read and written in ByteOrder.BIG_ENDIAN order. This provides complete
consistency with ByteBuffer. To flip buffers to ByteOrder.LITTLE_ENDIAN order, this
buffer's Bytes instance is decorated by a SwappedBytes instance which will reverse
read and written bytes using, e.g. Integer.reverseBytes(int).
public boolean isDirect()
Bufferpublic boolean isFile()
Bufferpublic boolean isReadOnly()
BufferisReadOnly in interface Bufferpublic Buffer asReadOnlyBuffer()
Buffer
The returned buffer will share the underlying Bytes with which buffer, but the buffer's limit,
capacity, and position will be independent of this buffer.
asReadOnlyBuffer in interface Bufferpublic Buffer compact()
Bufferpublic Buffer slice()
Buffer
The returned buffer will contain the same underlying Bytes instance as this buffer, but its pointers will
be offset by the current position of this buffer at the time the slice is created. Calls to
Buffer.rewind() and similar methods on the resulting Buffer will result in
the buffer's position being reset to the position of this buffer at the time the slice was created.
The returned buffer is reference counted separately from this buffer. Therefore, closing the returned buffer will
release the buffer back to the internal buffer poll and will not result in this buffer being closed. Users should
always call Buffer.close() once finished using the buffer slice.
slice in interface BufferBuffer.slice(long),
Buffer.slice(long, long)public Buffer slice(long length)
Buffer
The returned buffer will contain the same underlying Bytes instance as this buffer, but its pointers will
be offset by the current position of this buffer at the time the slice is created. Calls to
Buffer.rewind() and similar methods on the resulting Buffer will result in
the buffer's position being reset to the position of this buffer at the time the slice was created.
The returned buffer is reference counted separately from this buffer. Therefore, closing the returned buffer will
release the buffer back to the internal buffer poll and will not result in this buffer being closed. Users should
always call Buffer.close() once finished using the buffer slice.
slice in interface Bufferlength - The length of the slice.Buffer.slice(),
Buffer.slice(long, long)public Buffer slice(long offset, long length)
Buffer
The returned buffer will contain the same underlying Bytes instance as this buffer, but its pointers will
be offset by the given offset and its length limited by the given length. Calls to
Buffer.rewind() and similar methods on the resulting Buffer will result in
the buffer's position being reset to the given offset.
The returned buffer is reference counted separately from this buffer. Therefore, closing the returned buffer will
release the buffer back to the internal buffer poll and will not result in this buffer being closed. Users should
always call Buffer.close() once finished using the buffer slice.
slice in interface Bufferoffset - The offset at which to begin the slice.length - The number of bytes in the slice.Buffer.slice(),
Buffer.slice(long)public long offset()
Bufferpublic long capacity()
Buffer
The capacity represents the total amount of storage space allocated to the buffer by the underlying storage
implementation. As bytes are written to the buffer, the buffer's capacity may grow up to Buffer.maxCapacity().
public Buffer capacity(long capacity)
public long maxCapacity()
Buffer
The maximum capacity is the limit up to which this buffer's capacity can be expanded.
While the capacity grows, the maximum capacity is fixed from the moment the buffer is created and cannot change.
maxCapacity in interface Bufferpublic long position()
BufferThe 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.
public Buffer position(long position)
BufferThe position is an internal cursor that tracks where to write/read bytes in the underlying storage implementation.
public long limit()
Buffer
The limit dictates the highest position to which bytes can be read from or written to the buffer. If the limit is
not explicitly set then it will always equal the buffer's maxCapacity. Note that the
limit may be set by related methods such as Buffer.flip()
public Buffer limit(long limit)
Buffer
The limit dictates the highest position to which bytes can be read from or written to the buffer. The limit must
be within the bounds of the buffer, i.e. greater than 0 and less than or equal to Buffer.capacity()
public long remaining()
BufferBuffer.limit() is reached.
The bytes remaining is calculated by buffer.limit() - buffer.position(). If no limit is set on the buffer
then the maxCapacity will be used.
remaining in interface Bufferremaining in interface BufferInput<Buffer>public boolean hasRemaining()
Buffer
If Buffer.remaining() is greater than 0 then this method will return true, otherwise
false
hasRemaining in interface BufferhasRemaining in interface BufferInput<Buffer>true if Buffer.remaining() is
greater than 0, false otherwise.public Buffer flip()
BufferThe limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded.
assert buffer.writeLong(1234).flip().readLong() == 1234;
public Buffer mark()
BufferThe mark is a simple internal reference to the buffer's current position. Marks can be used to reset the buffer to a specific position after some operation.
buffer.mark();
buffer.writeInt(1).writeBoolean(true);
buffer.reset();
assert buffer.readInt() == 1;
public Buffer rewind()
Bufferpublic Buffer reset()
BufferInvoking this method neither changes nor discards the mark's value.
public Buffer skip(long length)
Bufferposition length bytes.skip in interface Bufferskip in interface BufferInput<Buffer>length - The number of bytes to advance this buffer's position.public Buffer clear()
BufferThe position is set to zero, the limit is set to the capacity, and the mark is discarded.
public Buffer zero()
BytesOutputzero in interface BytesOutput<Buffer>public Buffer zero(long offset)
BytesOutputzero in interface BytesOutput<Buffer>offset - The offset at which to start zeroing out bytes.public Buffer zero(long offset, long length)
BytesOutputzero in interface BytesOutput<Buffer>offset - The offset at which to start zeroing out bytes.length - THe total number of bytes to zero out.public Buffer read(Buffer buffer)
Buffer
Bytes will be read starting at the current buffer position until either Buffer.limit() has been reached.
If Buffer.remaining() is less than the Buffer.remaining() of the given buffer, a
BufferUnderflowException will be thrown.
read in interface Bufferread in interface BufferInput<Buffer>buffer - The buffer into which to read bytes.public Buffer read(Bytes bytes)
Buffer
Bytes will be read starting at the current buffer position until either the byte array length or the
Buffer.limit() has been reached. If Buffer.remaining()
is less than the length of the given byte array, a BufferUnderflowException will be
thrown.
read in interface Bufferread in interface BufferInput<Buffer>bytes - The byte array into which to read bytes.Buffer.read(Bytes, long, long),
Buffer.read(long, Bytes, long, long)public Buffer read(Bytes bytes, long offset, long length)
Buffer
Bytes will be read from the current position up to the given length. If the provided length is
greater than Buffer.remaining() then a BufferUnderflowException will
be thrown. If the offset is out of bounds of the buffer then an IndexOutOfBoundsException
will be thrown.
read in interface Bufferread in interface BufferInput<Buffer>bytes - The byte array into which to read bytes.offset - The offset at which to write bytes into the given bufferBuffer.read(Bytes),
Buffer.read(long, Bytes, long, long)public Buffer read(long srcOffset, Bytes bytes, long dstOffset, long length)
Buffer
Bytes will be read from the given starting offset up to the given length. If the provided length is
greater than - srcOffset then a BufferUnderflowException will
be thrown. If the srcOffset is out of bounds of the buffer then an IndexOutOfBoundsException
will be thrown.
read in interface Bufferread in interface BytesInput<Buffer>srcOffset - The offset from which to start reading bytes.bytes - The byte array into which to read bytes.dstOffset - The offset at which to write bytes into the given bufferlength - The total number of bytes to read.Buffer.read(Bytes),
Buffer.read(Bytes, long, long)public Buffer read(byte[] bytes)
Buffer
Bytes will be read starting at the current buffer position until either the byte array length or the
Buffer.limit() has been reached. If Buffer.remaining()
is less than the length of the given byte array, a BufferUnderflowException will be
thrown.
read in interface Bufferread in interface BufferInput<Buffer>bytes - The byte array into which to read bytes.Buffer.read(byte[], long, long),
Buffer.read(long, byte[], long, long)public Buffer read(byte[] bytes, long offset, long length)
Buffer
Bytes will be read from the current position up to the given length. If the provided length is
greater than Buffer.remaining() then a BufferUnderflowException will
be thrown. If the offset is out of bounds of the buffer then an IndexOutOfBoundsException
will be thrown.
read in interface Bufferread in interface BufferInput<Buffer>bytes - The byte array into which to read bytes.offset - The offset at which to write bytes into the given bufferBuffer.read(byte[]),
Buffer.read(long, byte[], long, long)public Buffer read(long srcOffset, byte[] bytes, long dstOffset, long length)
Buffer
Bytes will be read from the given starting offset up to the given length. If the provided length is
greater than Buffer.remaining() then a BufferUnderflowException will
be thrown. If the offset is out of bounds of the buffer then an IndexOutOfBoundsException
will be thrown.
read in interface Bufferread in interface BytesInput<Buffer>srcOffset - The offset from which to start reading bytes.bytes - The byte array into which to read bytes.dstOffset - The offset at which to write bytes into the given bufferlength - The total number of bytes to read.Buffer.read(byte[]),
Buffer.read(byte[], long, long)public int readByte()
Buffer
When the byte is read from the buffer, the buffer's position will be advanced by Bytes.BYTE. If
there are no bytes remaining in the buffer then a BufferUnderflowException will be thrown.
readByte in interface BufferreadByte in interface BufferInput<Buffer>Buffer.readByte(long)public int readByte(long offset)
Buffer
The byte will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readByte in interface BufferreadByte in interface BytesInput<Buffer>offset - The offset at which to read the byte.Buffer.readByte()public int readUnsignedByte()
Buffer
When the byte is read from the buffer, the buffer's position will be advanced by Bytes.BYTE. If
there are no bytes remaining in the buffer then a BufferUnderflowException will be thrown.
readUnsignedByte in interface BufferreadUnsignedByte in interface BufferInput<Buffer>Buffer.readUnsignedByte(long)public int readUnsignedByte(long offset)
Buffer
The byte will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readUnsignedByte in interface BufferreadUnsignedByte in interface BytesInput<Buffer>offset - The offset at which to read the byte.Buffer.readUnsignedByte()public char readChar()
Buffer
When the character is read from the buffer, the buffer's position will be advanced by Bytes.CHARACTER.
If there are less than Bytes.CHARACTER bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readChar in interface BufferreadChar in interface BufferInput<Buffer>Buffer.readChar(long)public char readChar(long offset)
Buffer
The character will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readChar in interface BufferreadChar in interface BytesInput<Buffer>offset - The offset at which to read the character.Buffer.readChar()public short readShort()
Buffer
When the short is read from the buffer, the buffer's position will be advanced by Bytes.SHORT.
If there are less than Bytes.SHORT bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readShort in interface BufferreadShort in interface BufferInput<Buffer>Buffer.readShort(long)public short readShort(long offset)
Buffer
The short will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readShort in interface BufferreadShort in interface BytesInput<Buffer>offset - The offset at which to read the short.Buffer.readShort()public int readUnsignedShort()
Buffer
When the short is read from the buffer, the buffer's position will be advanced by Bytes.SHORT.
If there are less than Bytes.SHORT bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readUnsignedShort in interface BufferreadUnsignedShort in interface BufferInput<Buffer>Buffer.readUnsignedShort(long)public int readUnsignedShort(long offset)
Buffer
The short will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readUnsignedShort in interface BufferreadUnsignedShort in interface BytesInput<Buffer>offset - The offset at which to read the short.Buffer.readUnsignedShort()public int readMedium()
BufferInputreadMedium in interface BufferInput<Buffer>public int readMedium(long offset)
BytesInputreadMedium in interface BytesInput<Buffer>offset - The offset at which to read the integer.public int readUnsignedMedium()
BufferInputreadUnsignedMedium in interface BufferInput<Buffer>public int readUnsignedMedium(long offset)
BytesInputreadUnsignedMedium in interface BytesInput<Buffer>offset - The offset at which to read the integer.public int readInt()
Buffer
When the integer is read from the buffer, the buffer's position will be advanced by Bytes.INTEGER.
If there are less than Bytes.INTEGER bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readInt in interface BufferreadInt in interface BufferInput<Buffer>Buffer.readInt(long)public int readInt(long offset)
Buffer
The integer will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readInt in interface BufferreadInt in interface BytesInput<Buffer>offset - The offset at which to read the integer.Buffer.readInt()public long readUnsignedInt()
Buffer
When the integer is read from the buffer, the buffer's position will be advanced by Bytes.INTEGER.
If there are less than Bytes.INTEGER bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readUnsignedInt in interface BufferreadUnsignedInt in interface BufferInput<Buffer>Buffer.readUnsignedInt(long)public long readUnsignedInt(long offset)
Buffer
The integer will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readUnsignedInt in interface BufferreadUnsignedInt in interface BytesInput<Buffer>offset - The offset at which to read the integer.Buffer.readUnsignedInt()public long readLong()
Buffer
When the long is read from the buffer, the buffer's position will be advanced by Bytes.LONG.
If there are less than Bytes.LONG bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readLong in interface BufferreadLong in interface BufferInput<Buffer>Buffer.readLong(long)public long readLong(long offset)
Buffer
The long will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readLong in interface BufferreadLong in interface BytesInput<Buffer>offset - The offset at which to read the long.Buffer.readLong()public float readFloat()
Buffer
When the float is read from the buffer, the buffer's position will be advanced by Bytes.FLOAT.
If there are less than Bytes.FLOAT bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readFloat in interface BufferreadFloat in interface BufferInput<Buffer>Buffer.readFloat(long)public float readFloat(long offset)
Buffer
The float will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readFloat in interface BufferreadFloat in interface BytesInput<Buffer>offset - The offset at which to read the float.Buffer.readFloat()public double readDouble()
Buffer
When the double is read from the buffer, the buffer's position will be advanced by Bytes.DOUBLE.
If there are less than Bytes.DOUBLE bytes remaining in the buffer then a
BufferUnderflowException will be thrown.
readDouble in interface BufferreadDouble in interface BufferInput<Buffer>Buffer.readDouble(long)public double readDouble(long offset)
Buffer
The double will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readDouble in interface BufferreadDouble in interface BytesInput<Buffer>offset - The offset at which to read the double.Buffer.readDouble()public boolean readBoolean()
Buffer
When the boolean is read from the buffer, the buffer's position will be advanced by 1.
If there are no bytes remaining in the buffer then a BufferUnderflowException will be thrown.
readBoolean in interface BufferreadBoolean in interface BufferInput<Buffer>Buffer.readBoolean(long)public boolean readBoolean(long offset)
Buffer
The boolean will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readBoolean in interface BufferreadBoolean in interface BytesInput<Buffer>offset - The offset at which to read the boolean.Buffer.readBoolean()public String readString()
BufferInputreadString in interface BufferInput<Buffer>public String readString(long offset)
BytesInputreadString in interface BytesInput<Buffer>offset - The offset at which to read the string.public String readUTF8()
Buffer
When the string is read from the buffer, the buffer's position will be advanced by 2 bytes plus the byte
length of the string. If there are no bytes remaining in the buffer then a BufferUnderflowException
will be thrown.
readUTF8 in interface BufferreadUTF8 in interface BufferInput<Buffer>Buffer.readUTF8(long)public String readUTF8(long offset)
Buffer
The string will be read from the given offset. If the given index is out of the bounds of the buffer then a
IndexOutOfBoundsException will be thrown.
readUTF8 in interface BufferreadUTF8 in interface BytesInput<Buffer>offset - The offset at which to read the boolean.Buffer.readUTF8()public Buffer write(Buffer buffer)
Buffer
When the buffer is written to the buffer, the buffer's position will be advanced by the number of bytes
in the provided buffer. If the provided Buffer.remaining() exceeds Buffer.remaining() then an
BufferOverflowException will be thrown.
write in interface Bufferwrite in interface BufferOutput<Buffer>buffer - The buffer to write.public Buffer write(Bytes bytes)
Buffer
When the bytes are written to the buffer, the buffer's position will be advanced by the number of bytes
in the provided byte array. If the number of bytes exceeds Buffer.limit() then an
BufferOverflowException will be thrown.
write in interface Bufferwrite in interface BufferOutput<Buffer>bytes - The array of bytes to write.Buffer.write(Bytes, long, long),
Buffer.write(long, Bytes, long, long)public Buffer write(Bytes bytes, long offset, long length)
Buffer
The bytes will be written starting at the current position up to the given length. If the length of the byte array
is larger than the provided length then only length bytes will be read from the array. If the
provided length is greater than the remaining bytes in this buffer then a BufferOverflowException
will be thrown.
write in interface Bufferwrite in interface BufferOutput<Buffer>bytes - The array of bytes to write.offset - The offset at which to start writing the bytes.length - The number of bytes from the provided byte array to write to the buffer.Buffer.write(Bytes),
Buffer.write(long, Bytes, long, long)public Buffer write(long offset, Bytes bytes, long srcOffset, long length)
Buffer
The bytes will be written starting at the given offset up to the given length. If the remaining bytes in the byte array
is larger than the provided length then only length bytes will be read from the array. If the
provided length is greater than Buffer.limit() minus offset then a
BufferOverflowException will be thrown.
write in interface Bufferwrite in interface BytesOutput<Buffer>offset - The offset at which to start writing the bytes.bytes - The array of bytes to write.srcOffset - The offset at which to begin reading bytes from the source.length - The number of bytes from the provided byte array to write to the buffer.Buffer.write(Bytes),
Buffer.write(Bytes, long, long)public Buffer write(byte[] bytes)
Buffer
When the bytes are written to the buffer, the buffer's position will be advanced by the number of bytes
in the provided byte array. If the number of bytes exceeds Buffer.limit() then an
BufferOverflowException will be thrown.
write in interface Bufferwrite in interface BufferOutput<Buffer>bytes - The array of bytes to write.Buffer.write(byte[], long, long),
Buffer.write(long, byte[], long, long)public Buffer write(byte[] bytes, long offset, long length)
Buffer
The bytes will be written starting at the current position up to the given length. If the length of the byte array
is larger than the provided length then only length bytes will be read from the array. If the
provided length is greater than the remaining bytes in this buffer then a BufferOverflowException
will be thrown.
write in interface Bufferwrite in interface BufferOutput<Buffer>bytes - The array of bytes to write.offset - The offset at which to start writing the bytes.length - The number of bytes from the provided byte array to write to the buffer.Buffer.write(byte[]),
Buffer.write(long, byte[], long, long)public Buffer write(long offset, byte[] bytes, long srcOffset, long length)
Buffer
The bytes will be written starting at the given offset up to the given length. If the remaining bytes in the byte array
is larger than the provided length then only length bytes will be read from the array. If the
provided length is greater than Buffer.limit() minus offset then a
BufferOverflowException will be thrown.
write in interface Bufferwrite in interface BytesOutput<Buffer>offset - The offset at which to start writing the bytes.bytes - The array of bytes to write.srcOffset - The offset at which to begin reading bytes from the source.length - The number of bytes from the provided byte array to write to the buffer.Buffer.write(byte[]),
Buffer.write(byte[], long, long)public Buffer writeByte(int b)
Buffer
When the byte is written to the buffer, the buffer's position will be advanced by Bytes.BYTE. If
there are no bytes remaining in the buffer then a BufferOverflowException will be thrown.
writeByte in interface BufferwriteByte in interface BufferOutput<Buffer>b - The byte to write.Buffer.writeByte(long, int)public Buffer writeByte(long offset, int b)
Buffer
The byte will be written at the given offset. If there are no bytes remaining in the buffer then a
BufferOverflowException will be thrown.
writeByte in interface BufferwriteByte in interface BytesOutput<Buffer>offset - The offset at which to write the byte.b - The byte to write.Buffer.writeByte(int)public Buffer writeUnsignedByte(int b)
Buffer
When the byte is written to the buffer, the buffer's position will be advanced by Bytes.BYTE. If
there are no bytes remaining in the buffer then a BufferOverflowException will be thrown.
writeUnsignedByte in interface BufferwriteUnsignedByte in interface BufferOutput<Buffer>b - The byte to write.Buffer.writeUnsignedByte(long, int)public Buffer writeUnsignedByte(long offset, int b)
Buffer
The byte will be written at the given offset. If there are no bytes remaining in the buffer then a
BufferOverflowException will be thrown.
writeUnsignedByte in interface BufferwriteUnsignedByte in interface BytesOutput<Buffer>offset - The offset at which to write the byte.b - The byte to write.Buffer.writeUnsignedByte(int)public Buffer writeChar(char c)
Buffer
When the character is written to the buffer, the buffer's position will be advanced by
Bytes.CHARACTER. If less than 2 bytes are remaining in the buffer then a
BufferOverflowException will be thrown.
writeChar in interface BufferwriteChar in interface BufferOutput<Buffer>c - The character to write.Buffer.writeChar(long, char)public Buffer writeChar(long offset, char c)
Buffer
The character will be written at the given offset. If there are less than Bytes.CHARACTER bytes remaining
in the buffer then a BufferOverflowException will be thrown.
writeChar in interface BufferwriteChar in interface BytesOutput<Buffer>offset - The offset at which to write the character.c - The character to write.Buffer.writeChar(char)public Buffer writeShort(short s)
Buffer
When the short is written to the buffer, the buffer's position will be advanced by Bytes.SHORT. If
less than Bytes.SHORT bytes are remaining in the buffer then a BufferOverflowException
will be thrown.
writeShort in interface BufferwriteShort in interface BufferOutput<Buffer>s - The short to write.Buffer.writeShort(long, short)public Buffer writeShort(long offset, short s)
Buffer
The short will be written at the given offset. If there are less than Bytes.SHORT bytes remaining in the buffer
then a BufferOverflowException will be thrown.
writeShort in interface BufferwriteShort in interface BytesOutput<Buffer>offset - The offset at which to write the short.s - The short to write.Buffer.writeShort(short)public Buffer writeUnsignedShort(int s)
Buffer
When the short is written to the buffer, the buffer's position will be advanced by Bytes.SHORT. If
less than Bytes.SHORT bytes are remaining in the buffer then a BufferOverflowException
will be thrown.
writeUnsignedShort in interface BufferwriteUnsignedShort in interface BufferOutput<Buffer>s - The short to write.Buffer.writeUnsignedShort(long, int)public Buffer writeUnsignedShort(long offset, int s)
Buffer
The short will be written at the given offset. If there are less than Bytes.SHORT bytes remaining in the buffer
then a BufferOverflowException will be thrown.
writeUnsignedShort in interface BufferwriteUnsignedShort in interface BytesOutput<Buffer>offset - The offset at which to write the short.s - The short to write.Buffer.writeUnsignedShort(int)public Buffer writeMedium(int m)
BufferOutputwriteMedium in interface BufferOutput<Buffer>m - The integer to write.public Buffer writeMedium(long offset, int m)
BytesOutputwriteMedium in interface BytesOutput<Buffer>offset - The offset at which to write the short.m - The short to write.public Buffer writeUnsignedMedium(int m)
BufferOutputwriteUnsignedMedium in interface BufferOutput<Buffer>m - The integer to write.public Buffer writeUnsignedMedium(long offset, int m)
BytesOutputwriteUnsignedMedium in interface BytesOutput<Buffer>offset - The offset at which to write the short.m - The short to write.public Buffer writeInt(int i)
Buffer
When the integer is written to the buffer, the buffer's position will be advanced by Bytes.INTEGER.
If less than Bytes.INTEGER bytes are remaining in the buffer then a BufferOverflowException
will be thrown.
writeInt in interface BufferwriteInt in interface BufferOutput<Buffer>i - The integer to write.Buffer.writeInt(long, int)public Buffer writeInt(long offset, int i)
Buffer
The integer will be written at the given offset. If there are less than Bytes.INTEGER bytes remaining
in the buffer then a BufferOverflowException will be thrown.
writeInt in interface BufferwriteInt in interface BytesOutput<Buffer>offset - The offset at which to write the integer.i - The integer to write.Buffer.writeInt(int)public Buffer writeUnsignedInt(long i)
Buffer
When the integer is written to the buffer, the buffer's position will be advanced by Bytes.INTEGER.
If less than Bytes.INTEGER bytes are remaining in the buffer then a BufferOverflowException
will be thrown.
writeUnsignedInt in interface BufferwriteUnsignedInt in interface BufferOutput<Buffer>i - The integer to write.Buffer.writeUnsignedInt(long, long)public Buffer writeUnsignedInt(long offset, long i)
Buffer
The integer will be written at the given offset. If there are less than Bytes.INTEGER bytes remaining
in the buffer then a BufferOverflowException will be thrown.
writeUnsignedInt in interface BufferwriteUnsignedInt in interface BytesOutput<Buffer>offset - The offset at which to write the integer.i - The integer to write.Buffer.writeUnsignedInt(long)public Buffer writeLong(long l)
Buffer
When the long is written to the buffer, the buffer's position will be advanced by Bytes.LONG.
If less than Bytes.LONG bytes are remaining in the buffer then a BufferOverflowException
will be thrown.
writeLong in interface BufferwriteLong in interface BufferOutput<Buffer>l - The long to write.Buffer.writeLong(long, long)public Buffer writeLong(long offset, long l)
Buffer
The long will be written at the given offset. If there are less than Bytes.LONG bytes remaining
in the buffer then a BufferOverflowException will be thrown.
writeLong in interface BufferwriteLong in interface BytesOutput<Buffer>offset - The offset at which to write the long.l - The long to write.Buffer.writeLong(long)public Buffer writeFloat(float f)
Buffer
When the float is written to the buffer, the buffer's position will be advanced by Bytes.FLOAT.
If less than Bytes.FLOAT bytes are remaining in the buffer then a BufferOverflowException
will be thrown.
writeFloat in interface BufferwriteFloat in interface BufferOutput<Buffer>f - The float to write.Buffer.writeFloat(long, float)public Buffer writeFloat(long offset, float f)
Buffer
The float will be written at the given offset. If there are less than Bytes.FLOAT bytes remaining
in the buffer then a BufferOverflowException will be thrown.
writeFloat in interface BufferwriteFloat in interface BytesOutput<Buffer>offset - The offset at which to write the float.f - The float to write.Buffer.writeFloat(float)public Buffer writeDouble(double d)
Buffer
When the double is written to the buffer, the buffer's position will be advanced by Bytes.DOUBLE.
If less than Bytes.DOUBLE bytes are remaining in the buffer then a BufferOverflowException
will be thrown.
writeDouble in interface BufferwriteDouble in interface BufferOutput<Buffer>d - The double to write.Buffer.writeDouble(long, double)public Buffer writeDouble(long offset, double d)
Buffer
The double will be written at the given offset. If there are less than Bytes.DOUBLE bytes remaining
in the buffer then a BufferOverflowException will be thrown.
writeDouble in interface BufferwriteDouble in interface BytesOutput<Buffer>offset - The offset at which to write the double.d - The double to write.Buffer.writeDouble(double)public Buffer writeBoolean(boolean b)
Buffer
When the boolean is written to the buffer, the buffer's position will be advanced by 1.
If there are no bytes remaining in the buffer then a BufferOverflowException
will be thrown.
writeBoolean in interface BufferwriteBoolean in interface BufferOutput<Buffer>b - The boolean to write.Buffer.writeBoolean(long, boolean)public Buffer writeBoolean(long offset, boolean b)
Buffer
The boolean will be written as a single byte at the given offset. If there are no bytes remaining in the buffer
then a BufferOverflowException will be thrown.
writeBoolean in interface BufferwriteBoolean in interface BytesOutput<Buffer>offset - The offset at which to write the boolean.b - The boolean to write.Buffer.writeBoolean(boolean)public Buffer writeString(String s)
BufferOutputwriteString in interface BufferOutput<Buffer>s - The string to write.public Buffer writeString(long offset, String s)
BytesOutputwriteString in interface BytesOutput<Buffer>offset - The offset at which to write the string.s - The string to write.public Buffer writeUTF8(String s)
Buffer
The string will be written with a two-byte unsigned byte length followed by the UTF-8 bytes. If there are not enough
bytes remaining in the buffer then a BufferOverflowException will be thrown.
writeUTF8 in interface BufferwriteUTF8 in interface BufferOutput<Buffer>s - The string to write.Buffer.writeUTF8(long, String)public Buffer writeUTF8(long offset, String s)
Buffer
The string will be written with a two-byte unsigned byte length followed by the UTF-8 bytes. If there are not enough
bytes remaining in the buffer then a BufferOverflowException will be thrown.
writeUTF8 in interface BufferwriteUTF8 in interface BytesOutput<Buffer>offset - The offset at which to write the string.s - The string to write.Buffer.writeUTF8(String)public Buffer flush()
BytesOutputflush in interface BufferOutput<Buffer>flush in interface BytesOutput<Buffer>public void close()
Buffer
This method effectively acts as an alias to ReferenceCounted.release() and allows buffers to
be used as resources in try-with-resources statements. When the buffer is closed the internal reference counter
defined by ReferenceCounted will be decremented. However, if references to the
buffer still exist then those references will be allowed to continue to operate on the buffer until all references
have been released.
close in interface AutoCloseableclose in interface Bufferclose in interface BufferInput<Buffer>close in interface BufferOutput<Buffer>close in interface ReferenceCounted<Buffer>Copyright © 2013–2015. All rights reserved.