public class SimpleMemorySegment extends Object
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
memory
The array in which the data is stored.
|
protected ByteBuffer |
wrapper
Wrapper for I/O requests.
|
| Constructor and Description |
|---|
SimpleMemorySegment(byte[] memory)
Creates a new memory segment of given size with the provided views.
|
| Modifier and Type | Method and Description |
|---|---|
void |
get(DataOutput out,
int offset,
int length) |
byte |
get(int index) |
void |
get(int index,
byte[] dst) |
void |
get(int index,
byte[] dst,
int offset,
int length) |
byte[] |
getBackingArray()
Gets the byte array that backs the memory segment and this random access view.
|
boolean |
getBoolean(int index) |
char |
getChar(int index) |
double |
getDouble(int index) |
float |
getFloat(int index) |
int |
getInt(int index) |
int |
getIntBigEndian(int index) |
int |
getIntLittleEndian(int index) |
long |
getLong(int index) |
long |
getLongBigEndian(int index) |
long |
getLongLittleEndian(int index) |
short |
getShort(int index) |
boolean |
isFreed()
Checks whether this memory segment has already been freed.
|
void |
put(DataInput in,
int offset,
int length) |
void |
put(int index,
byte b) |
void |
put(int index,
byte[] src) |
void |
put(int index,
byte[] src,
int offset,
int length) |
void |
putBoolean(int index,
boolean value) |
void |
putChar(int index,
char value) |
void |
putDouble(int index,
double value) |
void |
putFloat(int index,
float value) |
void |
putInt(int index,
int value) |
void |
putIntBigEndian(int index,
int value) |
void |
putIntLittleEndian(int index,
int value) |
void |
putLong(int index,
long value) |
void |
putLongBigEndian(int index,
long value) |
void |
putLongLittleEndian(int index,
long value) |
void |
putShort(int index,
short value) |
int |
size()
Gets the size of the memory segment, in bytes.
|
int |
translateOffset(int offset)
Translates the given offset for this view into the offset for the backing array.
|
ByteBuffer |
wrap(int offset,
int length)
Wraps the chunk of the underlying memory located between offset and
length in a NIO ByteBuffer.
|
protected byte[] memory
protected ByteBuffer wrapper
public SimpleMemorySegment(byte[] memory)
public final boolean isFreed()
public final int size()
public final byte[] getBackingArray()
translateOffset(int) method.public final int translateOffset(int offset)
offset - The offset to be translated.public ByteBuffer wrap(int offset, int length)
offset - The offset in the memory segment.length - The number of bytes to be wrapped as a buffer.IndexOutOfBoundsException - Thrown, if offset is negative or larger than the memory segment size,
or if the offset plus the length is larger than the segment size.public final byte get(int index)
public final void put(int index,
byte b)
public final void get(int index,
byte[] dst)
public final void put(int index,
byte[] src)
public final void get(int index,
byte[] dst,
int offset,
int length)
public final void put(int index,
byte[] src,
int offset,
int length)
public final void get(DataOutput out, int offset, int length) throws IOException
IOExceptionpublic final void put(DataInput in, int offset, int length) throws IOException
IOExceptionpublic final boolean getBoolean(int index)
public final void putBoolean(int index,
boolean value)
public final char getChar(int index)
public final void putChar(int index,
char value)
public final short getShort(int index)
public final void putShort(int index,
short value)
public final int getInt(int index)
public final int getIntLittleEndian(int index)
public final int getIntBigEndian(int index)
public final void putInt(int index,
int value)
public final void putIntLittleEndian(int index,
int value)
public final void putIntBigEndian(int index,
int value)
public final long getLong(int index)
public final long getLongLittleEndian(int index)
public final long getLongBigEndian(int index)
public final void putLong(int index,
long value)
public final void putLongLittleEndian(int index,
long value)
public final void putLongBigEndian(int index,
long value)
public final float getFloat(int index)
public final void putFloat(int index,
float value)
public final double getDouble(int index)
public final void putDouble(int index,
double value)
Copyright © 2014 The Apache Software Foundation. All rights reserved.