public abstract class AbstractBuffer<B extends AbstractBuffer> extends Object implements NativeBuffer<B>
Modifier and Type | Field and Description |
---|---|
protected Buffer |
buffer |
protected int |
capacity |
protected int |
elementSize |
protected int |
position |
Modifier | Constructor and Description |
---|---|
protected |
AbstractBuffer(Buffer buffer,
int elementSize,
int capacity)
capacity and elementSize should be match the equation w/ target buffer type
|
Modifier and Type | Method and Description |
---|---|
Object |
array() |
int |
arrayOffset() |
int |
capacity() |
int |
elementSize() |
Buffer |
getBuffer() |
boolean |
hasArray() |
boolean |
hasRemaining() |
boolean |
isDirect() |
int |
limit() |
int |
position() |
B |
position(int newPos) |
int |
remaining() |
B |
rewind() |
String |
toString() |
protected final Buffer buffer
protected final int elementSize
protected final int capacity
protected int position
protected AbstractBuffer(Buffer buffer, int elementSize, int capacity)
capacity = elementSizeInBytes(buffer) * buffer.capacity() ) / elementSize
buffer
- shall be in target format.elementSize
- the target element size in bytes.capacity
- the target capacity in elements of size elementSize
.public final int elementSize()
elementSize
in interface NativeBuffer<B extends AbstractBuffer>
public final int limit()
limit
in interface NativeBuffer<B extends AbstractBuffer>
public final int capacity()
capacity
in interface NativeBuffer<B extends AbstractBuffer>
public final int position()
position
in interface NativeBuffer<B extends AbstractBuffer>
public final B position(int newPos)
position
in interface NativeBuffer<B extends AbstractBuffer>
public final int remaining()
remaining
in interface NativeBuffer<B extends AbstractBuffer>
public final boolean hasRemaining()
hasRemaining
in interface NativeBuffer<B extends AbstractBuffer>
public final B rewind()
rewind
in interface NativeBuffer<B extends AbstractBuffer>
public final Buffer getBuffer()
getBuffer
in interface NativeBuffer<B extends AbstractBuffer>
public final boolean isDirect()
isDirect
in interface NativeBuffer<B extends AbstractBuffer>
public final boolean hasArray()
hasArray
in interface NativeBuffer<B extends AbstractBuffer>
public final int arrayOffset()
arrayOffset
in interface NativeBuffer<B extends AbstractBuffer>
NativeBuffer.hasArray()
is true,
otherwise 0.public Object array() throws UnsupportedOperationException
array
in interface NativeBuffer<B extends AbstractBuffer>
NativeBuffer.hasArray()
is true,
otherwise it throws UnsupportedOperationException
.
The returned primitive array maybe of type int[]
or long[]
, etc ..UnsupportedOperationException
- if this object has no backup arrayNativeBuffer.hasArray()