public abstract class AbstractBytes extends Object implements Bytes
This class provides common state and bounds checking functionality for all Bytes implementations.
| Constructor and Description |
|---|
AbstractBytes() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Bytes |
flush()
Flushes the bytes to the underlying persistence layer.
|
boolean |
isDirect()
Returns a boolean value indicating whether the bytes are direct.
|
boolean |
isFile()
Returns a boolean value indicating whether the bytes are backed by a file.
|
ByteOrder |
order()
Returns the byte order.
|
Bytes |
order(ByteOrder order)
Sets the byte order, returning a new swapped
Bytes instance. |
boolean |
readBoolean(int offset)
Reads a 1 byte boolean from the buffer at the given offset.
|
int |
readMedium(int offset)
Reads a 24-bit signed integer from the buffer at the given offset.
|
String |
readString(int offset)
Reads a string from the buffer at the given offset.
|
String |
readString(int offset,
Charset charset)
Reads a string from the buffer at the given offset.
|
int |
readUnsignedByte(int offset)
Reads an unsigned byte from the buffer at the given offset.
|
long |
readUnsignedInt(int offset)
Reads a 32-bit unsigned integer from the buffer at the given offset.
|
int |
readUnsignedMedium(int offset)
Reads a 24-bin unsigned integer from the buffer at the given offset.
|
int |
readUnsignedShort(int offset)
Reads a 16-bit unsigned integer from the buffer at the given offset.
|
String |
readUTF8(int offset)
Reads a UTF-8 string from the buffer at the given offset.
|
Bytes |
writeBoolean(int offset,
boolean b)
Writes a 1 byte boolean to the buffer at the given offset.
|
Bytes |
writeMedium(int offset,
int m)
Writes a 24-bit signed integer to the buffer at the given offset.
|
Bytes |
writeString(int offset,
String s)
Writes a string to the buffer at the given offset.
|
Bytes |
writeString(int offset,
String s,
Charset charset)
Writes a string to the buffer at the given offset.
|
Bytes |
writeUnsignedByte(int offset,
int b)
Writes an unsigned byte to the buffer at the given position.
|
Bytes |
writeUnsignedInt(int offset,
long i)
Writes a 32-bit unsigned integer to the buffer at the given offset.
|
Bytes |
writeUnsignedMedium(int offset,
int m)
Writes a 24-bit unsigned integer to the buffer at the given offset.
|
Bytes |
writeUnsignedShort(int offset,
int s)
Writes a 16-bit unsigned integer to the buffer at the given offset.
|
Bytes |
writeUTF8(int offset,
String s)
Writes a UTF-8 string to the buffer at the given offset.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitread, read, readByte, readChar, readDouble, readFloat, readInt, readLong, readShortwrite, write, writeByte, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeShort, zero, zero, zeropublic boolean isDirect()
Bytespublic boolean isFile()
Bytespublic ByteOrder order()
Bytes
For consistency with ByteBuffer, all bytes implementations are initially in ByteOrder.BIG_ENDIAN order.
public Bytes order(ByteOrder order)
BytesBytes instance.
By default, all bytes are read and written in ByteOrder.BIG_ENDIAN order. This provides complete
consistency with ByteBuffer. To flip bytes to ByteOrder.LITTLE_ENDIAN order, this
Bytes instance is decorated by a SwappedBytes instance which will reverse
read and written bytes using, e.g. Integer.reverseBytes(int).
public boolean readBoolean(int offset)
BytesInputreadBoolean in interface BytesInput<Bytes>offset - The offset at which to read the boolean.public int readUnsignedByte(int offset)
BytesInputreadUnsignedByte in interface BytesInput<Bytes>offset - The offset at which to read the byte.public int readUnsignedShort(int offset)
BytesInputreadUnsignedShort in interface BytesInput<Bytes>offset - The offset at which to read the short.public int readMedium(int offset)
BytesInputreadMedium in interface BytesInput<Bytes>offset - The offset at which to read the integer.public int readUnsignedMedium(int offset)
BytesInputreadUnsignedMedium in interface BytesInput<Bytes>offset - The offset at which to read the integer.public long readUnsignedInt(int offset)
BytesInputreadUnsignedInt in interface BytesInput<Bytes>offset - The offset at which to read the integer.public String readString(int offset)
BytesInputreadString in interface BytesInput<Bytes>offset - The offset at which to read the string.public String readString(int offset, Charset charset)
BytesInputreadString in interface BytesInput<Bytes>offset - The offset at which to read the string.charset - The character set with which to decode the string.public String readUTF8(int offset)
BytesInputreadUTF8 in interface BytesInput<Bytes>offset - The offset at which to read the string.public Bytes writeBoolean(int offset, boolean b)
BytesOutputwriteBoolean in interface BytesOutput<Bytes>offset - The offset at which to write the boolean.b - The boolean to write.public Bytes writeUnsignedByte(int offset, int b)
BytesOutputwriteUnsignedByte in interface BytesOutput<Bytes>offset - The offset at which to write the byte.b - The byte to write.public Bytes writeUnsignedShort(int offset, int s)
BytesOutputwriteUnsignedShort in interface BytesOutput<Bytes>offset - The offset at which to write the short.s - The short to write.public Bytes writeMedium(int offset, int m)
BytesOutputwriteMedium in interface BytesOutput<Bytes>offset - The offset at which to write the short.m - The short to write.public Bytes writeUnsignedMedium(int offset, int m)
BytesOutputwriteUnsignedMedium in interface BytesOutput<Bytes>offset - The offset at which to write the short.m - The short to write.public Bytes writeUnsignedInt(int offset, long i)
BytesOutputwriteUnsignedInt in interface BytesOutput<Bytes>offset - The offset at which to write the integer.i - The integer to write.public Bytes writeString(int offset, String s)
BytesOutputwriteString in interface BytesOutput<Bytes>offset - The offset at which to write the string.s - The string to write.public Bytes writeString(int offset, String s, Charset charset)
BytesOutputwriteString in interface BytesOutput<Bytes>offset - The offset at which to write the string.s - The string to write.charset - The character set with which to encode the string.public Bytes writeUTF8(int offset, String s)
BytesOutputwriteUTF8 in interface BytesOutput<Bytes>offset - The offset at which to write the string.s - The string to write.public Bytes flush()
BytesOutputflush in interface BytesOutput<Bytes>public void close()
close in interface Bytesclose in interface AutoCloseableCopyright © 2013–2018. All rights reserved.