Class AbstractBufferAccess<A extends AbstractBufferAccess<A,B>, B extends Buffer>
java.lang.Object
net.imglib2.img.basictypeaccess.nio.AbstractBufferAccess<A,B>
- Type Parameters:
A- Subclass used as return type fornewInstance(Buffer, boolean)andBufferAccess.newInstance(ByteBuffer, boolean)B-Buffersubclass
- All Implemented Interfaces:
Serializable, ArrayDataAccess<A>, DataAccess, BufferAccess<A>, VolatileAccess
- Direct Known Subclasses:
ByteBufferAccess, CharBufferAccess, DoubleBufferAccess, FloatBufferAccess, IntBufferAccess, LongBufferAccess, ShortBufferAccess
public abstract class AbstractBufferAccess<A extends AbstractBufferAccess<A,B>, B extends Buffer>
extends Object
implements BufferAccess<A>
Base abstract class for
DataAccess implementations that wrap
Buffer.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final B(package private) static final booleanDefault valid setting if not specifiedprivate final booleanIf valid or not as perVolatileAccess. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBufferAccess(B buffer) AbstractBufferAccess(B buffer, boolean isValid) AbstractBufferAccess(Function<Integer, B> allocate, int numEntities) -
Method Summary
Modifier and TypeMethodDescription(package private) Aallocate(int numEntities) Allocate a new BufferAccess using the current buffer's directness and validity.(package private) Aallocate(int numEntities, boolean isDirect, boolean isValid) Allocate a new BufferAccess specifying the directness and validity.(package private) ByteBufferallocateByteBuffer(int numEntities, boolean isDirect) Allocate a new ByteBuffer with initial capacity and directness.createArray(int numEntities) Respects the directness of the buffer.createView(Object o) Returns a new instance of BufferAccess with duplicated Buffer for thread safety.(package private) abstract BduplicateBuffer(B buffer) Call Buffer.duplicate() Buffer.duplicate() only exists in the interface since Java 9 https://docs.oracle.com/javase/9/docs/api/java/nio/Buffer.html#duplicate--intReturns the Buffer's limit or zero if buffer is null.Returns the raw buffer (not duplicated)booleanisDirect()Return the Buffer's directness or false is the buffer is null.booleanDetermine if data can be read only and not writtenbooleanisValid()abstract AnewInstance(B buffer, boolean isValid) Create a new instance of this class given a Buffer of the same type.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BufferAccess
getNumBytesPerEntity, newInstance
-
Field Details
-
DEFAULT_IS_VALID
static final boolean DEFAULT_IS_VALIDDefault valid setting if not specified- See Also:
-
isValid
private final boolean isValidIf valid or not as perVolatileAccess. -
buffer
-
-
Constructor Details
-
AbstractBufferAccess
-
AbstractBufferAccess
-
AbstractBufferAccess
-
-
Method Details
-
createView
Returns a new instance of BufferAccess with duplicated Buffer for thread safety.- Specified by:
createViewin interfaceDataAccess- Parameters:
o- Usually an accessor likeCursor. SeeNativeImg.update(Object)- Returns:
- A view of the original access and of the same concrete type.
- See Also:
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceVolatileAccess
-
createArray
Respects the directness of the buffer. If this buffer is direct, then the new backing buffer is also direct.- Specified by:
createArrayin interfaceArrayDataAccess<A extends AbstractBufferAccess<A,B>>
-
getCurrentStorageArray
Returns the raw buffer (not duplicated)- Specified by:
getCurrentStorageArrayin interfaceArrayDataAccess<A extends AbstractBufferAccess<A,B>>
-
getArrayLength
public int getArrayLength()Returns the Buffer's limit or zero if buffer is null.- Specified by:
getArrayLengthin interfaceArrayDataAccess<A extends AbstractBufferAccess<A,B>> - See Also:
-
isDirect
public boolean isDirect()Return the Buffer's directness or false is the buffer is null.- Specified by:
isDirectin interfaceBufferAccess<A extends AbstractBufferAccess<A,B>> - Returns:
- true if the Buffer is direct.
- See Also:
-
isReadOnly
public boolean isReadOnly()Description copied from interface:BufferAccessDetermine if data can be read only and not written- Specified by:
isReadOnlyin interfaceBufferAccess<A extends AbstractBufferAccess<A,B>> - Returns:
- See Also:
-
allocateByteBuffer
Allocate a new ByteBuffer with initial capacity and directness.- Parameters:
numEntities-isDirect-- Returns:
-
allocate
Allocate a new BufferAccess specifying the directness and validity.- Parameters:
numEntities-isDirect-isValid-- Returns:
-
allocate
Allocate a new BufferAccess using the current buffer's directness and validity.- Parameters:
numEntities-- Returns:
-
newInstance
-
duplicateBuffer
-