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 for newInstance(Buffer, boolean) and BufferAccess.newInstance(ByteBuffer, boolean)
B - Buffer subclass
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

    Fields
    Modifier and Type
    Field
    Description
    (package private) final B
     
    (package private) static final boolean
    Default valid setting if not specified
    private final boolean
    If valid or not as per VolatileAccess.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    AbstractBufferAccess(B buffer, boolean isValid)
     
    AbstractBufferAccess(Function<Integer,B> allocate, int numEntities)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) A
    allocate(int numEntities)
    Allocate a new BufferAccess using the current buffer's directness and validity.
    (package private) A
    allocate(int numEntities, boolean isDirect, boolean isValid)
    Allocate a new BufferAccess specifying the directness and validity.
    (package private) ByteBuffer
    allocateByteBuffer(int numEntities, boolean isDirect)
    Allocate a new ByteBuffer with initial capacity and directness.
    createArray(int numEntities)
    Respects the directness of the buffer.
    Returns a new instance of BufferAccess with duplicated Buffer for thread safety.
    (package private) abstract B
    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--
    int
    Returns the Buffer's limit or zero if buffer is null.
    Returns the raw buffer (not duplicated)
    boolean
    Return the Buffer's directness or false is the buffer is null.
    boolean
    Determine if data can be read only and not written
    boolean
     
    abstract A
    newInstance(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, wait

    Methods inherited from interface BufferAccess

    getNumBytesPerEntity, newInstance
  • Field Details

    • DEFAULT_IS_VALID

      static final boolean DEFAULT_IS_VALID
      Default valid setting if not specified
      See Also:
    • isValid

      private final boolean isValid
      If valid or not as per VolatileAccess.
    • buffer

      final B extends Buffer buffer
  • Constructor Details

    • AbstractBufferAccess

      public AbstractBufferAccess(B buffer, boolean isValid)
    • AbstractBufferAccess

      public AbstractBufferAccess(B buffer)
    • AbstractBufferAccess

      public AbstractBufferAccess(Function<Integer,B> allocate, int numEntities)
  • Method Details

    • createView

      public A createView(Object o)
      Returns a new instance of BufferAccess with duplicated Buffer for thread safety.
      Specified by:
      createView in interface DataAccess
      Parameters:
      o - Usually an accessor like Cursor. See NativeImg.update(Object)
      Returns:
      A view of the original access and of the same concrete type.
      See Also:
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface VolatileAccess
    • 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:
      createArray in interface ArrayDataAccess<A extends AbstractBufferAccess<A,B>>
    • getCurrentStorageArray

      public B getCurrentStorageArray()
      Returns the raw buffer (not duplicated)
      Specified by:
      getCurrentStorageArray in interface ArrayDataAccess<A extends AbstractBufferAccess<A,B>>
    • getArrayLength

      public int getArrayLength()
      Returns the Buffer's limit or zero if buffer is null.
      Specified by:
      getArrayLength in interface ArrayDataAccess<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:
      isDirect in interface BufferAccess<A extends AbstractBufferAccess<A,B>>
      Returns:
      true if the Buffer is direct.
      See Also:
    • isReadOnly

      public boolean isReadOnly()
      Description copied from interface: BufferAccess
      Determine if data can be read only and not written
      Specified by:
      isReadOnly in interface BufferAccess<A extends AbstractBufferAccess<A,B>>
      Returns:
      See Also:
    • allocateByteBuffer

      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:
    • duplicateBuffer

      abstract B duplicateBuffer(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--
      Returns: