public class ReadOnlyBuffer extends AbstractBuffer
| Constructor and Description |
|---|
ReadOnlyBuffer(Buffer buffer,
io.atomix.utils.concurrent.ReferenceManager<Buffer> referenceManager) |
| Modifier and Type | Method and Description |
|---|---|
Buffer |
acquire() |
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 |
duplicate()
Returns a duplicate of the buffer.
|
Buffer |
flush()
Flushes the bytes to the underlying persistence layer.
|
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.
|
boolean |
release() |
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,
int offset,
int 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,
int offset,
int length)
Writes an array of bytes to the buffer.
|
Buffer |
write(int offset,
byte[] bytes,
int srcOffset,
int length)
Writes an array of bytes to the buffer.
|
Buffer |
write(int offset,
Bytes bytes,
int srcOffset,
int 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(int 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(int 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(int 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(int 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(int 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(int offset,
int i)
Writes a 32-bit signed integer to the buffer at the given offset.
|
Buffer |
writeLong(int offset,
long l)
Writes a 64-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 |
writeMedium(int m)
Writes a 24-bit signed integer to the buffer.
|
Buffer |
writeMedium(int offset,
int m)
Writes a 24-bit signed integer to the buffer at the given offset.
|
Buffer |
writeShort(int 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 |
writeUnsignedByte(int b)
Writes an unsigned byte to the buffer at the current position.
|
Buffer |
writeUnsignedByte(int offset,
int b)
Writes an unsigned byte to the buffer at the given offset.
|
Buffer |
writeUnsignedInt(int offset,
long i)
Writes a 32-bit signed integer 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 |
writeUnsignedMedium(int m)
Writes a 24-bit unsigned integer to the buffer.
|
Buffer |
writeUnsignedMedium(int 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(int offset,
int s)
Writes a 16-bit signed integer 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(int offset)
Zeros out all bytes starting at the given offset in the array.
|
Buffer |
zero(int offset,
int length)
Zeros out bytes starting at the given offset up to the given length.
|
asReadOnlyBuffer, bytes, capacity, capacity, clear, flip, hasRemaining, limit, limit, mark, maxCapacity, offset, order, order, position, position, read, read, read, read, read, read, read, readBoolean, readBoolean, readByte, readByte, readChar, readChar, readDouble, readDouble, readFloat, readFloat, readInt, readInt, readLong, readLong, readMedium, readMedium, readShort, readShort, readString, readString, readString, readString, readUnsignedByte, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedMedium, readUnsignedMedium, readUnsignedShort, readUnsignedShort, readUTF8, readUTF8, references, remaining, reset, rewind, skip, slice, slice, slice, writeString, writeString, writeString, writeString, writeUTF8equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadByteswriteBytespublic boolean isDirect()
BufferisDirect in interface BufferisDirect in class AbstractBufferpublic boolean isFile()
BufferisFile in interface BufferisFile in class AbstractBufferpublic boolean isReadOnly()
BufferisReadOnly in interface BufferisReadOnly in class AbstractBufferpublic Buffer compact()
Buffercompact in interface Buffercompact in class AbstractBufferpublic Buffer duplicate()
Bufferpublic Buffer acquire()
acquire in interface io.atomix.utils.concurrent.ReferenceCounted<Buffer>acquire in class AbstractBufferpublic boolean release()
release in interface io.atomix.utils.concurrent.ReferenceCounted<Buffer>release in class AbstractBufferpublic Buffer zero(int offset, int length)
BytesOutputzero in interface BytesOutput<Buffer>zero in class AbstractBufferoffset - The offset at which to start zeroing out bytes.length - THe total number of bytes to zero out.public Buffer zero(int offset)
BytesOutputzero in interface BytesOutput<Buffer>zero in class AbstractBufferoffset - The offset at which to start zeroing out bytes.public Buffer zero()
BytesOutputzero in interface BytesOutput<Buffer>zero in class AbstractBufferpublic Buffer writeBoolean(int 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>writeBoolean in class AbstractBufferoffset - The offset at which to write the boolean.b - The boolean to write.Buffer.writeBoolean(boolean)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>write in class AbstractBufferbuffer - 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>write in class AbstractBufferbytes - The array of bytes to write.Buffer.write(Bytes, int, int),
Buffer.write(int, Bytes, int, int)public Buffer write(Bytes bytes, int offset, int 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>write in class AbstractBufferbytes - 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(int, Bytes, int, int)public Buffer write(int offset, Bytes bytes, int srcOffset, int 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>write in class AbstractBufferoffset - 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, int, int)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>write in class AbstractBufferbytes - The array of bytes to write.Buffer.write(byte[], int, int),
Buffer.write(int, byte[], int, int)public Buffer write(byte[] bytes, int offset, int 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>write in class AbstractBufferbytes - 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(int, byte[], int, int)public Buffer write(int offset, byte[] bytes, int srcOffset, int 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>write in class AbstractBufferoffset - 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[], int, int)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>writeByte in class AbstractBufferb - The byte to write.Buffer.writeByte(int, int)public Buffer writeByte(int 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>writeByte in class AbstractBufferoffset - 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>writeUnsignedByte in class AbstractBufferb - The byte to write.Buffer.writeUnsignedByte(int, int)public Buffer writeUnsignedByte(int 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>writeUnsignedByte in class AbstractBufferoffset - 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>writeChar in class AbstractBufferc - The character to write.Buffer.writeChar(int, char)public Buffer writeChar(int 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>writeChar in class AbstractBufferoffset - 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>writeShort in class AbstractBuffers - The short to write.Buffer.writeShort(int, short)public Buffer writeShort(int 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>writeShort in class AbstractBufferoffset - 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>writeUnsignedShort in class AbstractBuffers - The short to write.Buffer.writeUnsignedShort(int, int)public Buffer writeUnsignedShort(int 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>writeUnsignedShort in class AbstractBufferoffset - 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>writeMedium in class AbstractBufferm - The integer to write.public Buffer writeMedium(int offset, int m)
BytesOutputwriteMedium in interface BytesOutput<Buffer>writeMedium in class AbstractBufferoffset - The offset at which to write the short.m - The short to write.public Buffer writeUnsignedMedium(int m)
BufferOutputwriteUnsignedMedium in interface BufferOutput<Buffer>writeUnsignedMedium in class AbstractBufferm - The integer to write.public Buffer writeUnsignedMedium(int offset, int m)
BytesOutputwriteUnsignedMedium in interface BytesOutput<Buffer>writeUnsignedMedium in class AbstractBufferoffset - 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>writeInt in class AbstractBufferi - The integer to write.Buffer.writeInt(int, int)public Buffer writeInt(int 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>writeInt in class AbstractBufferoffset - 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>writeUnsignedInt in class AbstractBufferi - The integer to write.Buffer.writeUnsignedInt(int, long)public Buffer writeUnsignedInt(int 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>writeUnsignedInt in class AbstractBufferoffset - 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>writeLong in class AbstractBufferl - The long to write.Buffer.writeLong(int, long)public Buffer writeLong(int 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>writeLong in class AbstractBufferoffset - 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>writeFloat in class AbstractBufferf - The float to write.Buffer.writeFloat(int, float)public Buffer writeFloat(int 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>writeFloat in class AbstractBufferoffset - 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>writeDouble in class AbstractBufferd - The double to write.Buffer.writeDouble(int, double)public Buffer writeDouble(int 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>writeDouble in class AbstractBufferoffset - 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>writeBoolean in class AbstractBufferb - The boolean to write.Buffer.writeBoolean(int, boolean)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>writeUTF8 in class AbstractBuffers - The string to write.Buffer.writeUTF8(int, String)public Buffer flush()
BytesOutputflush in interface BufferOutput<Buffer>flush in interface BytesOutput<Buffer>flush in class AbstractBufferpublic 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 Bufferclose in interface BufferInput<Buffer>close in interface BufferOutput<Buffer>close in interface io.atomix.utils.concurrent.ReferenceCounted<Buffer>close in interface AutoCloseableclose in class AbstractBufferCopyright © 2013–2017. All rights reserved.