Class CircularBuffer

java.lang.Object
org.apache.commons.compress.archivers.zip.CircularBuffer

class CircularBuffer extends Object
Circular byte buffer.
Since:
1.7
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
    The buffer
    private int
    Index of the next data to be read from the buffer
    private final int
    Size of the buffer
    private int
    Index of the next data written in the buffer
  • Constructor Summary

    Constructors
    Constructor
    Description
    CircularBuffer(int size)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tells if a new byte can be read from the buffer.
    void
    copy(int distance, int length)
    Copy a previous interval in the buffer to the current position.
    int
    get()
    Reads a byte from the buffer.
    void
    put(int value)
    Writes a byte to the buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • size

      private final int size
      Size of the buffer
    • buffer

      private final byte[] buffer
      The buffer
    • readIndex

      private int readIndex
      Index of the next data to be read from the buffer
    • writeIndex

      private int writeIndex
      Index of the next data written in the buffer
  • Constructor Details

    • CircularBuffer

      CircularBuffer(int size)
  • Method Details

    • available

      public boolean available()
      Tells if a new byte can be read from the buffer.
    • put

      public void put(int value)
      Writes a byte to the buffer.
    • get

      public int get()
      Reads a byte from the buffer.
    • copy

      public void copy(int distance, int length)
      Copy a previous interval in the buffer to the current position.
      Parameters:
      distance - the distance from the current write position
      length - the number of bytes to copy