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:
ElementBuffer,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 intlimitstatic intPOINTER_SIZEPlatform dependent pointer size in bytes, i.e.protected 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()Returns this buffer's element capacity.Bclear()Sets the limit to the capacity and the position to zero.intelementSize()Returns byte size of one elementBflip()Sets the limit to the current position and the position to zero.BuffergetBuffer()Returns the underlying buffer object.longgetDirectBufferAddress()Returns the native address of the underlying buffer ifNativeBuffer.isDirect(), otherwise0.booleanhasArray()booleanhasRemaining()ReturnsNativeBuffer.remaining()> 0booleanisDirect()Return true if the underlying buffer is NIO direct, otherwise false.intlimit()Returns this buffer's element limit.Blimit(int newLim)Sets this buffer's element limit.intposition()Returns this buffer's element position.Bposition(int newPos)Sets this buffer's element position.intremaining()Returns this buffer's remaining element, i.e.Brewind()Sets the position to zero.voidstoreDirectAddress(ByteBuffer directDest)Store theNativeBuffer.getDirectBufferAddress()into the givenByteBufferusing relative put.voidstoreDirectAddress(ByteBuffer directDest, int destBytePos)Store theNativeBuffer.getDirectBufferAddress()into the givenByteBufferusing absolute put.StringtoString()protected StringtoSubString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.jogamp.common.nio.NativeBuffer
put
-
-
-
-
Field Detail
-
POINTER_SIZE
public static final int POINTER_SIZE
Platform dependent pointer size in bytes, i.e. 32bit or 64bit wide, depending of the CPU pointer width.
-
buffer
protected final Buffer buffer
-
elementSize
protected final int elementSize
-
capacity
protected final int capacity
-
limit
protected int limit
-
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()
Description copied from interface:NativeBufferReturns byte size of one element- Specified by:
elementSizein interfaceNativeBuffer<B extends AbstractBuffer>
-
limit
public final int limit()
Description copied from interface:NativeBufferReturns this buffer's element limit.- Specified by:
limitin interfaceNativeBuffer<B extends AbstractBuffer>
-
limit
public final B limit(int newLim)
Description copied from interface:NativeBufferSets this buffer's element limit.- Specified by:
limitin interfaceNativeBuffer<B extends AbstractBuffer>
-
capacity
public final int capacity()
Description copied from interface:NativeBufferReturns this buffer's element capacity.- Specified by:
capacityin interfaceNativeBuffer<B extends AbstractBuffer>
-
position
public final int position()
Description copied from interface:NativeBufferReturns this buffer's element position.- Specified by:
positionin interfaceNativeBuffer<B extends AbstractBuffer>
-
position
public final B position(int newPos)
Description copied from interface:NativeBufferSets this buffer's element position.- Specified by:
positionin interfaceNativeBuffer<B extends AbstractBuffer>
-
remaining
public final int remaining()
Description copied from interface:NativeBufferReturns this buffer's remaining element, i.e. limit - position.- Specified by:
remainingin interfaceNativeBuffer<B extends AbstractBuffer>
-
hasRemaining
public final boolean hasRemaining()
Description copied from interface:NativeBufferReturnsNativeBuffer.remaining()> 0- Specified by:
hasRemainingin interfaceNativeBuffer<B extends AbstractBuffer>
-
clear
public final B clear()
Description copied from interface:NativeBufferSets the limit to the capacity and the position to zero.- Specified by:
clearin interfaceNativeBuffer<B extends AbstractBuffer>
-
flip
public final B flip()
Description copied from interface:NativeBufferSets the limit to the current position and the position to zero.- Specified by:
flipin interfaceNativeBuffer<B extends AbstractBuffer>
-
rewind
public final B rewind()
Description copied from interface:NativeBufferSets the position to zero.- Specified by:
rewindin interfaceNativeBuffer<B extends AbstractBuffer>
-
getBuffer
public final Buffer getBuffer()
Description copied from interface:NativeBufferReturns the underlying buffer object.- Specified by:
getBufferin interfaceNativeBuffer<B extends AbstractBuffer>
-
isDirect
public final boolean isDirect()
Description copied from interface:NativeBufferReturn true if the underlying buffer is NIO direct, otherwise false.- Specified by:
isDirectin interfaceNativeBuffer<B extends AbstractBuffer>
-
getDirectBufferAddress
public long getDirectBufferAddress()
Description copied from interface:NativeBufferReturns the native address of the underlying buffer ifNativeBuffer.isDirect(), otherwise0.- Specified by:
getDirectBufferAddressin interfaceNativeBuffer<B extends AbstractBuffer>
-
storeDirectAddress
public void storeDirectAddress(ByteBuffer directDest)
Description copied from interface:NativeBufferStore theNativeBuffer.getDirectBufferAddress()into the givenByteBufferusing relative put.The native pointer value is stored either as a 32bit (int) or 64bit (long) wide value, depending of the CPU pointer width.
- Specified by:
storeDirectAddressin interfaceNativeBuffer<B extends AbstractBuffer>
-
storeDirectAddress
public void storeDirectAddress(ByteBuffer directDest, int destBytePos)
Description copied from interface:NativeBufferStore theNativeBuffer.getDirectBufferAddress()into the givenByteBufferusing absolute put.The native pointer value is stored either as a 32bit (int) or 64bit (long) wide value, depending of the CPU pointer width.
- Specified by:
storeDirectAddressin 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()
-
toSubString
protected String toSubString()
-
-