Class AbstractBufferAccess<A extends AbstractBufferAccess<A,B>,B extends java.nio.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:
java.io.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 java.nio.Buffer> extends java.lang.Object implements BufferAccess<A>
Base abstract class forDataAccessimplementations that wrapBuffer.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Bbuffer(package private) static booleanDEFAULT_IS_VALIDDefault valid setting if not specifiedprivate booleanisValidIf valid or not as perVolatileAccess.
-
Constructor Summary
Constructors Constructor Description AbstractBufferAccess(B buffer)AbstractBufferAccess(B buffer, boolean isValid)AbstractBufferAccess(java.util.function.Function<java.lang.Integer,B> allocate, int numEntities)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (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) java.nio.ByteBufferallocateByteBuffer(int numEntities, boolean isDirect)Allocate a new ByteBuffer with initial capacity and directness.AcreateArray(int numEntities)Respects the directness of the buffer.AcreateView(java.lang.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--intgetArrayLength()Returns the Buffer's limit or zero if buffer is null.BgetCurrentStorageArray()Returns the raw buffer (not duplicated)booleanisDirect()Return the Buffer's directness or false is the buffer is null.booleanisReadOnly()Determine 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.imglib2.img.basictypeaccess.nio.BufferAccess
getNumBytesPerEntity, newInstance
-
-
-
-
Field Detail
-
DEFAULT_IS_VALID
static final boolean DEFAULT_IS_VALID
Default valid setting if not specified- See Also:
- Constant Field Values
-
isValid
private final boolean isValid
If valid or not as perVolatileAccess.
-
buffer
final B extends java.nio.Buffer buffer
-
-
Method Detail
-
createView
public A createView(java.lang.Object o)
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:
NativeImg.update(Object),NativeType.updateContainer(Object)
-
isValid
public boolean isValid()
- Specified by:
isValidin interfaceVolatileAccess
-
createArray
public A createArray(int numEntities)
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
public 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:
Buffer.limit()
-
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:
Buffer.isDirect()
-
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:
Buffer.isReadOnly()
-
allocateByteBuffer
java.nio.ByteBuffer allocateByteBuffer(int numEntities, boolean isDirect)Allocate a new ByteBuffer with initial capacity and directness.- Parameters:
numEntities-isDirect-- Returns:
-
allocate
A allocate(int numEntities, boolean isDirect, boolean isValid)
Allocate a new BufferAccess specifying the directness and validity.- Parameters:
numEntities-isDirect-isValid-- Returns:
-
allocate
A allocate(int numEntities)
Allocate a new BufferAccess using the current buffer's directness and validity.- Parameters:
numEntities-- Returns:
-
newInstance
public abstract A newInstance(B buffer, boolean isValid)
Create a new instance of this class given a Buffer of the same type.- Parameters:
buffer-isValid-- Returns:
-
-