Package com.jogamp.common.nio
Interface NativeBuffer<B extends NativeBuffer>
-
- All Known Implementing Classes:
AbstractBuffer
,ElementBuffer
,PointerBuffer
public interface NativeBuffer<B extends NativeBuffer>
Hardware independent container for various kinds of buffers.Implementations follow
Buffer
semantics, e.g.0 <= position <= limit <= capacity
- Author:
- Sven Gothel, Michael Bien
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
array()
int
arrayOffset()
int
capacity()
Returns this buffer's element capacity.B
clear()
Sets the limit to the capacity and the position to zero.int
elementSize()
Returns byte size of one elementB
flip()
Sets the limit to the current position and the position to zero.Buffer
getBuffer()
Returns the underlying buffer object.long
getDirectBufferAddress()
Returns the native address of the underlying buffer ifisDirect()
, otherwise0
.boolean
hasArray()
boolean
hasRemaining()
Returnsremaining()
> 0boolean
isDirect()
Return true if the underlying buffer is NIO direct, otherwise false.int
limit()
Returns this buffer's element limit.B
limit(int newLim)
Sets this buffer's element limit.int
position()
Returns this buffer's element position.B
position(int newPos)
Sets this buffer's element position.B
put(B src)
Relative bulk get method.int
remaining()
Returns this buffer's remaining element, i.e.B
rewind()
Sets the position to zero.void
storeDirectAddress(ByteBuffer directDest)
Store thegetDirectBufferAddress()
into the givenByteBuffer
using relative put.void
storeDirectAddress(ByteBuffer directDest, int destOffset)
Store thegetDirectBufferAddress()
into the givenByteBuffer
using absolute put.
-
-
-
Method Detail
-
elementSize
int elementSize()
Returns byte size of one element
-
limit
int limit()
Returns this buffer's element limit.
-
limit
B limit(int newLim)
Sets this buffer's element limit.
-
capacity
int capacity()
Returns this buffer's element capacity.
-
position
int position()
Returns this buffer's element position.
-
position
B position(int newPos)
Sets this buffer's element position.
-
remaining
int remaining()
Returns this buffer's remaining element, i.e. limit - position.
-
hasRemaining
boolean hasRemaining()
Returnsremaining()
> 0
-
clear
B clear()
Sets the limit to the capacity and the position to zero.
-
flip
B flip()
Sets the limit to the current position and the position to zero.
-
rewind
B rewind()
Sets the position to zero.
-
hasArray
boolean hasArray()
- Returns:
- true if this buffer has a primitive backup array, otherwise false
-
arrayOffset
int arrayOffset()
- Returns:
- the array offset of the optional primitive backup array of the buffer if
hasArray()
is true, otherwise 0.
-
array
Object array() throws UnsupportedOperationException
- Returns:
- the primitive backup array of the buffer if
hasArray()
is true, otherwise it throwsUnsupportedOperationException
. The returned primitive array maybe of typeint[]
orlong[]
, etc .. - Throws:
UnsupportedOperationException
- if this object has no backup array- See Also:
hasArray()
-
getBuffer
Buffer getBuffer()
Returns the underlying buffer object.
-
isDirect
boolean isDirect()
Return true if the underlying buffer is NIO direct, otherwise false.
-
getDirectBufferAddress
long getDirectBufferAddress()
Returns the native address of the underlying buffer ifisDirect()
, otherwise0
.
-
storeDirectAddress
void storeDirectAddress(ByteBuffer directDest)
Store thegetDirectBufferAddress()
into the givenByteBuffer
using relative put.The native pointer value is stored either as a 32bit (int) or 64bit (long) wide value, depending of the CPU pointer width.
-
storeDirectAddress
void storeDirectAddress(ByteBuffer directDest, int destOffset)
Store thegetDirectBufferAddress()
into the givenByteBuffer
using absolute put.The native pointer value is stored either as a 32bit (int) or 64bit (long) wide value, depending of the CPU pointer width.
-
-