public abstract class NativeBytes extends AbstractBytes
Bytes are read from and written to the JVM's underlying static Unsafe instance. Bytes are read in
ByteOrder.nativeOrder() order and if necessary bytes are reversed to ByteOrder.BIG_ENDIAN
order.
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
isDirect()
Returns a boolean value indicating whether the bytes are direct.
|
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.
|
int |
readMedium(int offset)
Reads a 24-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.
|
int |
readUnsignedMedium(int offset)
Reads a 24-bin unsigned integer from the buffer at the given offset.
|
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 |
writeMedium(int offset,
int m)
Writes a 24-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 |
writeUnsignedMedium(int offset,
int m)
Writes a 24-bit unsigned 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.
|
flush, isFile, order, order, readBoolean, readString, readString, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF8, writeBoolean, writeString, writeString, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUTF8public int size()
Bytespublic 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 boolean isDirect()
BytesisDirect in interface BytesisDirect in class AbstractBytespublic Bytes zero()
BytesOutputpublic 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, 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 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 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 readMedium(int offset)
BytesInputreadMedium in interface BytesInput<Bytes>readMedium in class AbstractBytesoffset - The offset at which to read the integer.public int readUnsignedMedium(int offset)
BytesInputreadUnsignedMedium in interface BytesInput<Bytes>readUnsignedMedium in class AbstractBytesoffset - The offset at which to read the integer.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 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 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 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 writeMedium(int offset, int m)
BytesOutputwriteMedium in interface BytesOutput<Bytes>writeMedium in class AbstractBytesoffset - 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>writeUnsignedMedium in class AbstractBytesoffset - The offset at which to write the short.m - 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.public void close()
close in interface Bytesclose in interface AutoCloseableclose in class AbstractBytesCopyright © 2013–2018. All rights reserved.