public abstract class ByteBufferBytes extends AbstractBytes
| Modifier and Type | Method and Description |
|---|---|
byte[] |
array()
Returns the underlying byte array.
|
ByteBuffer |
byteBuffer()
Returns the underlying
ByteBuffer. |
ByteOrder |
order()
Returns the byte order.
|
Bytes |
order(ByteOrder order)
Sets the byte order, returning a new swapped
Bytes instance. |
Bytes |
read(int position,
byte[] bytes,
int offset,
int length)
Reads bytes into the given byte array starting at the given offset up to the given length.
|
Bytes |
read(int position,
Bytes bytes,
int offset,
int length)
Reads bytes into the given byte array starting at the given offset up to the given length.
|
int |
readByte(int offset)
Reads a byte from the buffer at the given offset.
|
char |
readChar(int offset)
Reads a 16-bit character from the buffer at the given offset.
|
double |
readDouble(int offset)
Reads a double-precision 64-bit floating point number from the buffer at the given offset.
|
float |
readFloat(int offset)
Reads a single-precision 32-bit floating point number from the buffer at the given offset.
|
int |
readInt(int offset)
Reads a 32-bit signed integer from the buffer at the given offset.
|
long |
readLong(int offset)
Reads a 64-bit signed integer from the buffer at the given offset.
|
short |
readShort(int offset)
Reads a 16-bit signed integer from the buffer at the given offset.
|
Bytes |
reset(ByteBuffer buffer) |
Bytes |
resize(int newSize)
Resizes the bytes.
|
int |
size()
Returns the count of the bytes.
|
Bytes |
write(int position,
byte[] bytes,
int offset,
int length)
Writes an array of bytes to the buffer.
|
Bytes |
write(int position,
Bytes bytes,
int offset,
int length)
Writes an array of bytes to the buffer.
|
Bytes |
writeByte(int offset,
int b)
Writes a byte to the buffer at the given offset.
|
Bytes |
writeChar(int offset,
char c)
Writes a 16-bit character to the buffer at the given offset.
|
Bytes |
writeDouble(int offset,
double d)
Writes a double-precision 64-bit floating point number to the buffer at the given offset.
|
Bytes |
writeFloat(int offset,
float f)
Writes a single-precision 32-bit floating point number to the buffer at the given offset.
|
Bytes |
writeInt(int offset,
int i)
Writes a 32-bit signed integer to the buffer at the given offset.
|
Bytes |
writeLong(int offset,
long l)
Writes a 64-bit signed integer to the buffer at the given offset.
|
Bytes |
writeShort(int offset,
short s)
Writes a 16-bit signed integer to the buffer at the given offset.
|
Bytes |
zero()
Zeros out all bytes in the array.
|
Bytes |
zero(int offset)
Zeros out all bytes starting at the given offset in the array.
|
Bytes |
zero(int offset,
int length)
Zeros out bytes starting at the given offset up to the given length.
|
close, flush, isDirect, isFile, readBoolean, readMedium, readString, readString, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, readUTF8, writeBoolean, writeMedium, writeString, writeString, writeUnsignedByte, writeUnsignedInt, writeUnsignedMedium, writeUnsignedShort, writeUTF8public Bytes reset(ByteBuffer buffer)
public Bytes resize(int newSize)
Bytes
When the bytes are resized, underlying memory addresses in copies of this instance may no longer be valid. Additionally,
if the newSize is smaller than the current count then some data may be lost during the resize. Use
with caution.
newSize - The count to which to resize this instance.public byte[] array()
Bytespublic ByteBuffer byteBuffer()
ByteBuffer.public Bytes zero()
BytesOutputpublic int size()
Bytespublic ByteOrder order()
Bytes
For consistency with ByteBuffer, all bytes implementations are initially in ByteOrder.BIG_ENDIAN order.
order in interface Bytesorder in class AbstractBytespublic 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).
order in interface Bytesorder in class AbstractBytesorder - The byte order.public Bytes zero(int offset)
BytesOutputoffset - The offset at which to start zeroing out bytes.public Bytes zero(int offset, int length)
BytesOutputoffset - The offset at which to start zeroing out bytes.length - THe total number of bytes to zero out.public Bytes read(int position, byte[] bytes, int offset, int length)
BytesInputposition - The offset from which to start reading bytes.bytes - The byte array into which to read bytes.offset - The offset at which to write bytes into the given bufferlength - The total number of bytes to read.public Bytes read(int position, Bytes bytes, int offset, int length)
BytesInputposition - The offset from which to start reading bytes.bytes - The byte array into which to read bytes.offset - The offset at which to write bytes into the given buffer.length - The total number of bytes to read.public Bytes write(int position, byte[] bytes, int offset, int length)
BytesOutputposition - The offset at which to start writing the bytes.bytes - The array of bytes to write.offset - The offset at which to start reading bytes from the given source.length - The number of bytes from the provided byte array to write to the buffer.public Bytes write(int position, Bytes bytes, int offset, int length)
BytesOutputposition - The offset at which to start writing the bytes.bytes - The array of bytes to write.offset - The offset at which to start reading bytes from the given source.length - The number of bytes from the provided byte array to write to the buffer.public int readByte(int offset)
BytesInputoffset - The offset at which to read the byte.public char readChar(int offset)
BytesInputoffset - The offset at which to read the character.public short readShort(int offset)
BytesInputoffset - The offset at which to read the short.public int readInt(int offset)
BytesInputoffset - The offset at which to read the integer.public long readLong(int offset)
BytesInputoffset - The offset at which to read the long.public float readFloat(int offset)
BytesInputoffset - The offset at which to read the float.public double readDouble(int offset)
BytesInputoffset - The offset at which to read the double.public Bytes writeByte(int offset, int b)
BytesOutputoffset - The offset at which to write the byte.b - The byte to write.public Bytes writeChar(int offset, char c)
BytesOutputoffset - The offset at which to write the character.c - The character to write.public Bytes writeShort(int offset, short s)
BytesOutputoffset - The offset at which to write the short.s - The short to write.public Bytes writeInt(int offset, int i)
BytesOutputoffset - The offset at which to write the integer.i - The integer to write.public Bytes writeLong(int offset, long l)
BytesOutputoffset - The offset at which to write the long.l - The long to write.public Bytes writeFloat(int offset, float f)
BytesOutputoffset - The offset at which to write the float.f - The float to write.public Bytes writeDouble(int offset, double d)
BytesOutputoffset - The offset at which to write the double.d - The double to write.Copyright © 2013–2018. All rights reserved.