com.alexkasko.unsafe.offheapstruct
private static class OffHeapStructComparator.OffHeapStructByteArrayAccessor extends Object implements OffHeapStructAccessor
Modifier and Type | Field and Description |
---|---|
private ByteArrayTool |
bt |
private byte[] |
struct |
Modifier | Constructor and Description |
---|---|
private |
OffHeapStructComparator.OffHeapStructByteArrayAccessor(ByteArrayTool bt)
Constructor
|
private |
OffHeapStructComparator.OffHeapStructByteArrayAccessor(ByteArrayTool bt,
byte[] struct)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
get(byte[] buffer)
Copies struct into specified buffer
|
void |
get(int srcPos,
byte[] dest,
int destPos,
int length)
Copies part of struct into specified buffer
|
byte |
getByte(int offset)
Gets byte from struct with specified offset
|
int |
getInt(int offset)
Gets four bytes as int from struct with specified offset
|
long |
getLong(int offset)
Gets long from struct with specified offset
|
short |
getShort(int offset)
Gets two bytes as short from struct with specified offset
|
private byte[] |
getStruct()
Returns previously setted struct
|
short |
getUnsignedByte(int offset)
Gets one byte (stored as one signed byte) from struct on specified index
with specified offset, converts it to unsigned and returns it as short
|
long |
getUnsignedInt(int offset)
Gets unsigned int (stored as 4 bytes) and returns it as long
from struct with specified offset
|
int |
getUnsignedShort(int offset)
Gets unsigned short (stored as two bytes) from struct on specified index
with specified offset and returns it as int
|
void |
set(byte[] buffer)
Copies specified buffer data into internal buffer
|
private void |
setStruct(byte[] struct)
Sets struct to access it
|
int |
structLength()
Returns length of the single struct in bytes
|
String |
toString() |
private final ByteArrayTool bt
private byte[] struct
private OffHeapStructComparator.OffHeapStructByteArrayAccessor(ByteArrayTool bt)
bt
- byte array tool to operate over held byte arrayprivate OffHeapStructComparator.OffHeapStructByteArrayAccessor(ByteArrayTool bt, byte[] struct)
bt
- byte array tool to operate over held byte arraystruct
- byte array to holdpublic int structLength()
structLength
in interface OffHeapStructAccessor
public void get(byte[] buffer)
get
in interface OffHeapStructAccessor
buffer
- buffer to copy struct intopublic void get(int srcPos, byte[] dest, int destPos, int length)
get
in interface OffHeapStructAccessor
public void set(byte[] buffer)
buffer
- data to copypublic byte getByte(int offset)
getByte
in interface OffHeapStructAccessor
offset
- byte array indexpublic short getUnsignedByte(int offset)
getUnsignedByte
in interface OffHeapStructAccessor
offset
- byte array indexpublic short getShort(int offset)
getShort
in interface OffHeapStructAccessor
offset
- byte array offsetpublic int getUnsignedShort(int offset)
getUnsignedShort
in interface OffHeapStructAccessor
offset
- byte array offsetpublic int getInt(int offset)
getInt
in interface OffHeapStructAccessor
offset
- byte array offsetpublic long getUnsignedInt(int offset)
getUnsignedInt
in interface OffHeapStructAccessor
offset
- byte array offsetpublic long getLong(int offset)
getLong
in interface OffHeapStructAccessor
offset
- byte array offsetprivate byte[] getStruct()
private void setStruct(byte[] struct)
struct
- structCopyright © 2014. All Rights Reserved.