Class AbstractBufferAccess<A extends AbstractBufferAccess<A,​B>,​B extends java.nio.Buffer>

    • Field Summary

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

      All Methods Instance Methods Abstract Methods Concrete Methods 
      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) java.nio.ByteBuffer allocateByteBuffer​(int numEntities, boolean isDirect)
      Allocate a new ByteBuffer with initial capacity and directness.
      A createArray​(int numEntities)
      Respects the directness of the buffer.
      A createView​(java.lang.Object o)
      Returns a new instance of BufferAccess with duplicated Buffer for thread safety.
      (package private) 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--
      int getArrayLength()
      Returns the Buffer's limit or zero if buffer is null.
      B getCurrentStorageArray()
      Returns the raw buffer (not duplicated)
      boolean isDirect()
      Return the Buffer's directness or false is the buffer is null.
      boolean isReadOnly()
      Determine if data can be read only and not written
      boolean isValid()  
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 per VolatileAccess.
      • buffer

        final B extends java.nio.Buffer buffer
    • Constructor Detail

      • AbstractBufferAccess

        public AbstractBufferAccess​(B buffer,
                                    boolean isValid)
      • AbstractBufferAccess

        public AbstractBufferAccess​(B buffer)
      • AbstractBufferAccess

        public AbstractBufferAccess​(java.util.function.Function<java.lang.Integer,​B> allocate,
                                    int numEntities)
    • Method Detail

      • 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>>
      • 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:
        Buffer.isDirect()
      • 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:
      • 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: