Class BaseByteBuffer

  • All Implemented Interfaces:
    java.lang.Comparable<ByteBuffer>

    public abstract class BaseByteBuffer
    extends ByteBuffer
    A base implementation of ByteBuffer. This implementation assumes that ByteBuffer.buf() always returns a correct NIO ByteBuffer instance. Most implementations could extend this class and implement their own buffer management mechanism.
    See Also:
    ByteBufferAllocator
    • Constructor Detail

      • BaseByteBuffer

        protected BaseByteBuffer()
    • Method Detail

      • isDirect

        public boolean isDirect()
        Specified by:
        isDirect in class ByteBuffer
        See Also:
        ByteBuffer.isDirect()
      • isReadOnly

        public boolean isReadOnly()
        Specified by:
        isReadOnly in class ByteBuffer
        See Also:
        Buffer.isReadOnly()
      • capacity

        public int capacity()
        Specified by:
        capacity in class ByteBuffer
        See Also:
        Buffer.capacity()
      • capacity0

        protected abstract void capacity0​(int newCapacity)
        Implement this method to increase the capacity of this buffer. newCapacity is always greater than the current capacity.
      • isAutoExpand

        public boolean isAutoExpand()
        Description copied from class: ByteBuffer
        Returns true if and only if autoExpand is turned on.
        Specified by:
        isAutoExpand in class ByteBuffer
      • expand

        public ByteBuffer expand​(int pos,
                                 int expectedRemaining)
        Description copied from class: ByteBuffer
        Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified pos. This method works even if you didn't set autoExpand to true.
        Specified by:
        expand in class ByteBuffer
      • position

        public int position()
        Specified by:
        position in class ByteBuffer
        See Also:
        Buffer.position()
      • limit

        public int limit()
        Specified by:
        limit in class ByteBuffer
        See Also:
        Buffer.limit()
      • markValue

        public int markValue()
        Description copied from class: ByteBuffer
        Returns the position of the current mark. This method returns -1 if no mark is set.
        Specified by:
        markValue in class ByteBuffer
      • get

        public byte get()
        Specified by:
        get in class ByteBuffer
        See Also:
        ByteBuffer.get()
      • get

        public byte get​(int index)
        Specified by:
        get in class ByteBuffer
        See Also:
        ByteBuffer.get(int)
      • put

        public ByteBuffer put​(int index,
                              byte b)
        Specified by:
        put in class ByteBuffer
        See Also:
        ByteBuffer.put(int, byte)
      • get

        public ByteBuffer get​(byte[] dst,
                              int offset,
                              int length)
        Specified by:
        get in class ByteBuffer
        See Also:
        ByteBuffer.get(byte[], int, int)
      • put

        public ByteBuffer put​(java.nio.ByteBuffer src)
        Description copied from class: ByteBuffer
        Writes the content of the specified src into this buffer.
        Specified by:
        put in class ByteBuffer
      • put

        public ByteBuffer put​(byte[] src,
                              int offset,
                              int length)
        Specified by:
        put in class ByteBuffer
        See Also:
        ByteBuffer.put(byte[], int, int)
      • order

        public java.nio.ByteOrder order()
        Specified by:
        order in class ByteBuffer
        See Also:
        ByteBuffer.order()
      • order

        public ByteBuffer order​(java.nio.ByteOrder bo)
        Specified by:
        order in class ByteBuffer
        See Also:
        ByteBuffer.order(ByteOrder)
      • getChar

        public char getChar()
        Specified by:
        getChar in class ByteBuffer
        See Also:
        ByteBuffer.getChar()
      • getChar

        public char getChar​(int index)
        Specified by:
        getChar in class ByteBuffer
        See Also:
        ByteBuffer.getChar(int)
      • putChar

        public ByteBuffer putChar​(int index,
                                  char value)
        Specified by:
        putChar in class ByteBuffer
        See Also:
        ByteBuffer.putChar(int, char)
      • asCharBuffer

        public java.nio.CharBuffer asCharBuffer()
        Specified by:
        asCharBuffer in class ByteBuffer
        See Also:
        ByteBuffer.asCharBuffer()
      • getShort

        public short getShort()
        Specified by:
        getShort in class ByteBuffer
        See Also:
        ByteBuffer.getShort()
      • getShort

        public short getShort​(int index)
        Specified by:
        getShort in class ByteBuffer
        See Also:
        ByteBuffer.getShort()
      • putShort

        public ByteBuffer putShort​(int index,
                                   short value)
        Specified by:
        putShort in class ByteBuffer
        See Also:
        ByteBuffer.putShort(int, short)
      • asShortBuffer

        public java.nio.ShortBuffer asShortBuffer()
        Specified by:
        asShortBuffer in class ByteBuffer
        See Also:
        ByteBuffer.asShortBuffer()
      • getInt

        public int getInt()
        Specified by:
        getInt in class ByteBuffer
        See Also:
        ByteBuffer.getInt()
      • getInt

        public int getInt​(int index)
        Specified by:
        getInt in class ByteBuffer
        See Also:
        ByteBuffer.getInt(int)
      • putInt

        public ByteBuffer putInt​(int index,
                                 int value)
        Specified by:
        putInt in class ByteBuffer
        See Also:
        ByteBuffer.putInt(int, int)
      • asIntBuffer

        public java.nio.IntBuffer asIntBuffer()
        Specified by:
        asIntBuffer in class ByteBuffer
        See Also:
        ByteBuffer.asIntBuffer()
      • getLong

        public long getLong()
        Specified by:
        getLong in class ByteBuffer
        See Also:
        ByteBuffer.getLong()
      • putLong

        public ByteBuffer putLong​(long value)
        Specified by:
        putLong in class ByteBuffer
        See Also:
        ByteBuffer.putLong(int, long)
      • getLong

        public long getLong​(int index)
        Specified by:
        getLong in class ByteBuffer
        See Also:
        ByteBuffer.getLong(int)
      • putLong

        public ByteBuffer putLong​(int index,
                                  long value)
        Specified by:
        putLong in class ByteBuffer
        See Also:
        ByteBuffer.putLong(int, long)
      • asLongBuffer

        public java.nio.LongBuffer asLongBuffer()
        Specified by:
        asLongBuffer in class ByteBuffer
        See Also:
        ByteBuffer.asLongBuffer()
      • getFloat

        public float getFloat()
        Specified by:
        getFloat in class ByteBuffer
        See Also:
        ByteBuffer.getFloat()
      • getFloat

        public float getFloat​(int index)
        Specified by:
        getFloat in class ByteBuffer
        See Also:
        ByteBuffer.getFloat(int)
      • putFloat

        public ByteBuffer putFloat​(int index,
                                   float value)
        Specified by:
        putFloat in class ByteBuffer
        See Also:
        ByteBuffer.putFloat(int, float)
      • asFloatBuffer

        public java.nio.FloatBuffer asFloatBuffer()
        Specified by:
        asFloatBuffer in class ByteBuffer
        See Also:
        ByteBuffer.asFloatBuffer()
      • getDouble

        public double getDouble()
        Specified by:
        getDouble in class ByteBuffer
        See Also:
        ByteBuffer.getDouble()
      • getDouble

        public double getDouble​(int index)
        Specified by:
        getDouble in class ByteBuffer
        See Also:
        ByteBuffer.getDouble(int)
      • putDouble

        public ByteBuffer putDouble​(int index,
                                    double value)
        Specified by:
        putDouble in class ByteBuffer
        See Also:
        ByteBuffer.putDouble(int, double)
      • asDoubleBuffer

        public java.nio.DoubleBuffer asDoubleBuffer()
        Specified by:
        asDoubleBuffer in class ByteBuffer
        See Also:
        ByteBuffer.asDoubleBuffer()