public class UnsafeHeapBytes extends AbstractBytes
| Modifier and Type | Method and Description |
|---|---|
static UnsafeHeapBytes |
allocate(int size)
Allocates a new heap byte array.
|
byte[] |
array()
Returns the underlying byte array.
|
UnsafeHeapBytes |
copy()
Copies the bytes to a new byte array.
|
boolean |
hasArray()
Returns whether the bytes has an array.
|
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.
|
boolean |
readBoolean(int offset)
Reads a 1 byte boolean from the buffer at the given offset.
|
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 |
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.
|
UnsafeHeapBytes |
reset(byte[] array)
Resets the heap byte array.
|
Bytes |
resize(int newSize)
Resizes the bytes.
|
int |
size()
Returns the count of the bytes.
|
static UnsafeHeapBytes |
wrap(byte[] bytes)
Wraps the given bytes in a
UnsafeHeapBytes object. |
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 |
writeBoolean(int offset,
boolean b)
Writes a 1 byte boolean to the buffer at the given offset.
|
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 |
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 |
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, order, order, readString, readString, readUTF8, writeString, writeString, writeUTF8public static UnsafeHeapBytes allocate(int size)
When the array is constructed, HeapMemoryAllocator will be used to allocate
count bytes on the Java heap.
size - The count of the buffer to allocate (in bytes).IllegalArgumentException - If count is greater than the maximum allowed count for
an array on the Java heap - Integer.MAX_VALUE - 5public static UnsafeHeapBytes wrap(byte[] bytes)
UnsafeHeapBytes object.
The returned Bytes object will be backed by a HeapMemory instance that
wraps the given byte array. The Bytes.size() will be equivalent to the provided
by array length.
bytes - The bytes to wrap.public UnsafeHeapBytes copy()
UnsafeHeapBytes instance backed by a copy of this instance's array.public boolean hasArray()
Bytespublic byte[] array()
Bytespublic UnsafeHeapBytes reset(byte[] array)
array - The internal byte array.public 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 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 int readUnsignedByte(int offset)
BytesInputreadUnsignedByte in interface BytesInput<Bytes>readUnsignedByte in class AbstractBytesoffset - 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 readUnsignedShort(int offset)
BytesInputreadUnsignedShort in interface BytesInput<Bytes>readUnsignedShort in class AbstractBytesoffset - 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 readUnsignedInt(int offset)
BytesInputreadUnsignedInt in interface BytesInput<Bytes>readUnsignedInt in class AbstractBytesoffset - 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 boolean readBoolean(int offset)
BytesInputreadBoolean in interface BytesInput<Bytes>readBoolean in class AbstractBytesoffset - The offset at which to read the boolean.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 writeUnsignedByte(int offset, int b)
BytesOutputwriteUnsignedByte in interface BytesOutput<Bytes>writeUnsignedByte in class AbstractBytesoffset - 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 writeUnsignedShort(int offset, int s)
BytesOutputwriteUnsignedShort in interface BytesOutput<Bytes>writeUnsignedShort in class AbstractBytesoffset - 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 writeUnsignedInt(int offset, long i)
BytesOutputwriteUnsignedInt in interface BytesOutput<Bytes>writeUnsignedInt in class AbstractBytesoffset - 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 Bytes writeBoolean(int offset, boolean b)
BytesOutputwriteBoolean in interface BytesOutput<Bytes>writeBoolean in class AbstractBytesoffset - The offset at which to write the boolean.b - The boolean to write.Copyright © 2013–2017. All rights reserved.