Class BufferByteArray

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected IoBuffer bb
      The backing IoBuffer.
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferByteArray​(IoBuffer bb)
      Creates a new instance of BufferByteArray and uses the supplied IoBuffer to back this class
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ByteArray.Cursor cursor()
      ByteArray.Cursor cursor​(int index)
      int first()
      byte get​(int index)
      void get​(int index, IoBuffer other)
      Gets enough bytes to fill the IoBuffer from the given index.
      char getChar​(int index)
      double getDouble​(int index)
      float getFloat​(int index)
      int getInt​(int index)
      java.lang.Iterable<IoBuffer> getIoBuffers()
      long getLong​(int index)
      short getShort​(int index)
      IoBuffer getSingleIoBuffer()
      int hashCode()
      int last()
      java.nio.ByteOrder order()
      void order​(java.nio.ByteOrder order)
      Set the byte order of the array.
      void put​(int index, byte b)
      Puts a byte at the given index.
      void put​(int index, IoBuffer other)
      Puts bytes from the IoBuffer at the given index.
      void putChar​(int index, char c)
      Puts a char at the given index.
      void putDouble​(int index, double d)
      Puts a double at the given index.
      void putFloat​(int index, float f)
      Puts a float at the given index.
      void putInt​(int index, int i)
      Puts an int at the given index.
      void putLong​(int index, long l)
      Puts a long at the given index.
      void putShort​(int index, short s)
      Puts a short at the given index.
      ByteArray slice​(int index, int length)
      Creates an array with a view of part of this array.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.mina.util.byteaccess.ByteArray

        free
    • Field Detail

      • bb

        protected IoBuffer bb
        The backing IoBuffer.
    • Constructor Detail

      • BufferByteArray

        public BufferByteArray​(IoBuffer bb)
        Creates a new instance of BufferByteArray and uses the supplied IoBuffer to back this class
        Parameters:
        bb - The backing buffer
    • Method Detail

      • getIoBuffers

        public java.lang.Iterable<IoBuffer> getIoBuffers()
        Returns:
        the sequence of IoBuffers that back this array. Compared to getSingleIoBuffer(), this method should be relatively efficient for all implementations.
      • getSingleIoBuffer

        public IoBuffer getSingleIoBuffer()
        Returns:
        a single IoBuffer that backs this array. Some implementations may initially have data split across multiple buffers, so calling this method may require a new buffer to be allocated and populated.
      • slice

        public ByteArray slice​(int index,
                               int length)
        Creates an array with a view of part of this array. Calling free() on the returned slice has no effect.
        Parameters:
        index - The starting position
        length - The number of bytes to copy
        Returns:
        The ByteArray that is a view on the original array
      • cursor

        public ByteArray.Cursor cursor()
        Returns:
        a cursor starting at index 0 (which may not be the start of the array).
      • cursor

        public ByteArray.Cursor cursor​(int index)
        Parameters:
        index - The starting point
        Returns:
        a cursor starting at the given index.
      • first

        public int first()
        Returns:
        the index of the first byte that can be accessed.
      • last

        public int last()
        Returns:
        the index after the last byte that can be accessed.
      • order

        public java.nio.ByteOrder order()
        Returns:
        the order of the bytes.
      • order

        public void order​(java.nio.ByteOrder order)
        Set the byte order of the array.
        Parameters:
        order - The ByteOrder to use
      • get

        public byte get​(int index)
        Parameters:
        index - The starting position
        Returns:
        a byte from the given index.
      • put

        public void put​(int index,
                        byte b)
        Puts a byte at the given index.
        Parameters:
        index - The position
        b - The byte to put
      • get

        public void get​(int index,
                        IoBuffer other)
        Gets enough bytes to fill the IoBuffer from the given index.
        Parameters:
        index - The starting position
        other - The IoBuffer that will be filled with the bytes
      • put

        public void put​(int index,
                        IoBuffer other)
        Puts bytes from the IoBuffer at the given index.
        Parameters:
        index - The position
        other - The bytes to put
      • getShort

        public short getShort​(int index)
        Parameters:
        index - The starting position
        Returns:
        a short from the given index.
      • putShort

        public void putShort​(int index,
                             short s)
        Puts a short at the given index.
        Parameters:
        index - The position
        s - The short to put
      • getInt

        public int getInt​(int index)
        Parameters:
        index - The starting position
        Returns:
        an int from the given index.
      • putInt

        public void putInt​(int index,
                           int i)
        Puts an int at the given index.
        Parameters:
        index - The position
        i - The int to put
      • getLong

        public long getLong​(int index)
        Parameters:
        index - The starting position
        Returns:
        a long from the given index.
      • putLong

        public void putLong​(int index,
                            long l)
        Puts a long at the given index.
        Parameters:
        index - The position
        l - The long to put
      • getFloat

        public float getFloat​(int index)
        Parameters:
        index - The starting position
        Returns:
        a float from the given index.
      • putFloat

        public void putFloat​(int index,
                             float f)
        Puts a float at the given index.
        Parameters:
        index - The position
        f - The float to put
      • getDouble

        public double getDouble​(int index)
        Parameters:
        index - The starting position
        Returns:
        a double from the given index.
      • putDouble

        public void putDouble​(int index,
                              double d)
        Puts a double at the given index.
        Parameters:
        index - The position
        d - The doubvle to put
      • getChar

        public char getChar​(int index)
        Parameters:
        index - The starting position
        Returns:
        a char from the given index.
      • putChar

        public void putChar​(int index,
                            char c)
        Puts a char at the given index.
        Parameters:
        index - The position
        c - The char to put