Package com.jogamp.common.nio
Class AbstractBuffer<B extends AbstractBuffer>
- java.lang.Object
-
- com.jogamp.common.nio.AbstractBuffer<B>
-
- All Implemented Interfaces:
NativeBuffer<B>
- Direct Known Subclasses:
PointerBuffer
public abstract class AbstractBuffer<B extends AbstractBuffer> extends Object implements NativeBuffer<B>
- Author:
- Sven Gothel, Michael Bien
-
-
Field Summary
Fields Modifier and Type Field Description protected Bufferbufferprotected intcapacityprotected intelementSizeprotected intposition
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractBuffer(Buffer buffer, int elementSize, int capacity)capacity and elementSize should be match the equation w/ target buffer type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectarray()intarrayOffset()intcapacity()intelementSize()BuffergetBuffer()booleanhasArray()booleanhasRemaining()booleanisDirect()intlimit()intposition()Bposition(int newPos)intremaining()Brewind()StringtoString()
-
-
-
Field Detail
-
buffer
protected final Buffer buffer
-
elementSize
protected final int elementSize
-
capacity
protected final int capacity
-
position
protected int position
-
-
Constructor Detail
-
AbstractBuffer
protected AbstractBuffer(Buffer buffer, int elementSize, int capacity)
capacity and elementSize should be match the equation w/ target buffer typecapacity = elementSizeInBytes(buffer) * buffer.capacity() ) / elementSize- Parameters:
buffer- shall be in target format.elementSize- the target element size in bytes.capacity- the target capacity in elements of sizeelementSize.
-
-
Method Detail
-
elementSize
public final int elementSize()
- Specified by:
elementSizein interfaceNativeBuffer<B extends AbstractBuffer>
-
limit
public final int limit()
- Specified by:
limitin interfaceNativeBuffer<B extends AbstractBuffer>
-
capacity
public final int capacity()
- Specified by:
capacityin interfaceNativeBuffer<B extends AbstractBuffer>
-
position
public final int position()
- Specified by:
positionin interfaceNativeBuffer<B extends AbstractBuffer>
-
position
public final B position(int newPos)
- Specified by:
positionin interfaceNativeBuffer<B extends AbstractBuffer>
-
remaining
public final int remaining()
- Specified by:
remainingin interfaceNativeBuffer<B extends AbstractBuffer>
-
hasRemaining
public final boolean hasRemaining()
- Specified by:
hasRemainingin interfaceNativeBuffer<B extends AbstractBuffer>
-
rewind
public final B rewind()
- Specified by:
rewindin interfaceNativeBuffer<B extends AbstractBuffer>
-
getBuffer
public final Buffer getBuffer()
- Specified by:
getBufferin interfaceNativeBuffer<B extends AbstractBuffer>
-
isDirect
public final boolean isDirect()
- Specified by:
isDirectin interfaceNativeBuffer<B extends AbstractBuffer>
-
hasArray
public final boolean hasArray()
- Specified by:
hasArrayin interfaceNativeBuffer<B extends AbstractBuffer>- Returns:
- true if this buffer has a primitive backup array, otherwise false
-
arrayOffset
public final int arrayOffset()
- Specified by:
arrayOffsetin interfaceNativeBuffer<B extends AbstractBuffer>- Returns:
- the array offset of the optional primitive backup array of the buffer if
NativeBuffer.hasArray()is true, otherwise 0.
-
array
public Object array() throws UnsupportedOperationException
- Specified by:
arrayin interfaceNativeBuffer<B extends AbstractBuffer>- Returns:
- the primitive backup array of the buffer if
NativeBuffer.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:
NativeBuffer.hasArray()
-
-