Class CircularBuffer
java.lang.Object
org.apache.commons.compress.archivers.zip.CircularBuffer
Circular byte buffer.
- Since:
- 1.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
The bufferprivate int
Index of the next data to be read from the bufferprivate final int
Size of the bufferprivate int
Index of the next data written in the buffer -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
size
private final int sizeSize of the buffer -
buffer
private final byte[] bufferThe buffer -
readIndex
private int readIndexIndex of the next data to be read from the buffer -
writeIndex
private int writeIndexIndex of the next data written in the buffer
-
-
Constructor Details
-
CircularBuffer
CircularBuffer(int size)
-
-
Method Details
-
available
public boolean available()Tests whether a new byte can be read from the buffer.- Returns:
- Whether a new byte can be read from the buffer.
-
copy
public void copy(int distance, int length) Copies a previous interval in the buffer to the current position.- Parameters:
distance
- the distance from the current write positionlength
- the number of bytes to copy
-
get
public int get()Reads a byte from the buffer.- Returns:
- a byte from the buffer.
-
put
public void put(int value) Puts a byte to the buffer.- Parameters:
value
- the value to put.
-