Package 

Class ByteFifoBuffer

  • All Implemented Interfaces:

    
    public class ByteFifoBuffer
    
                        

    First in - first out byte buffer

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int buffered
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteFifoBuffer(int len) Creates buffer of specified size
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      int getBuffered()
      int length()
      int read(Array<byte> out_buffer, int count) Reads count bytes into out_buffer.
      int read(Array<byte> out_buffer, int buff_offset, int count) Read with buffer offset
      int getWriteRemaining()
      int write(Array<byte> buffer, int count) Writes count of bytes from the buffer
      int write(Array<byte> data, int offset, int count) Writes data into the buffer.
      void consumeWriteBuffer(int count) Advances current buffer's write position by count bytes
      boolean setCapacity(int new_size) Sets new buffer's capacity
      void consumeReadData(int count) Aligns current read position by count
      int readOffset(Array<byte> dst_buff, int dst_buff_offset, int count, int offset) Reads count bytes from buffer without storing new read position
      int writeOffset(Array<byte> data, int count, int nOffset) Writes count bytes from data to the buffer without affecting buffer's write position
      void resetReadPosition()
      void resetWritePosition()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteFifoBuffer

        ByteFifoBuffer(int len)
        Creates buffer of specified size
        Parameters:
        len - buffer's size
    • Method Detail

      • read

         int read(Array<byte> out_buffer, int count)

        Reads count bytes into out_buffer. Current read position is incremented by count of bytes that has been successfully read.

        Parameters:
        out_buffer - read count bytes into this buffer
        count - number of bytes to read into the out_buffer
      • read

         int read(Array<byte> out_buffer, int buff_offset, int count)

        Read with buffer offset

        Parameters:
        out_buffer - read count bytes into this buffer
        buff_offset - offset where to start writing into out_buffer
        count - bytes to read
      • write

         int write(Array<byte> buffer, int count)

        Writes count of bytes from the buffer

        Parameters:
        buffer - data to write into the buffer
        count - number of bytes to read from the buffer
      • write

         int write(Array<byte> data, int offset, int count)

        Writes data into the buffer.

        Parameters:
        data - source data
        offset - source buffer's offset
        count - number of bytes to read from the buffer
      • consumeWriteBuffer

         void consumeWriteBuffer(int count)

        Advances current buffer's write position by count bytes

        Parameters:
        count - number of bytes to move forward
      • setCapacity

         boolean setCapacity(int new_size)

        Sets new buffer's capacity

        Parameters:
        new_size - number of bytes
      • consumeReadData

         void consumeReadData(int count)

        Aligns current read position by count

        Parameters:
        count - number of bytes to move the read position
      • readOffset

         int readOffset(Array<byte> dst_buff, int dst_buff_offset, int count, int offset)

        Reads count bytes from buffer without storing new read position

        Parameters:
        dst_buff - buffer to write the read data to
        dst_buff_offset - offset of destination buffer
        count - bytes to read
        offset - from current read position
      • writeOffset

         int writeOffset(Array<byte> data, int count, int nOffset)

        Writes count bytes from data to the buffer without affecting buffer's write position

        Parameters:
        data - the data to write to the buffer
        count - number of bytes to read from data
        nOffset - from buffer's write position