public class RingBuffer extends Object
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buffer |
protected int |
bufferSize |
protected static int |
DEFAULT_BUFFER_SIZE |
protected boolean |
eof |
protected int |
getHere |
protected int |
putHere |
protected Object |
signal |
| Constructor and Description |
|---|
RingBuffer()
Constructor.
|
RingBuffer(int size)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
empty()
Empty the ring buffer.
|
int |
get(byte[] data,
int offset,
int len)
Read data from the ring buffer.
|
int |
getAvailable()
Return the bytes available for reading.
|
boolean |
isEOF()
Return EOF status.
|
static void |
main(String[] args)
Test main routine.
|
void |
put(byte[] data,
int offset,
int len)
Put data into the ring buffer.
|
int |
putAvailable()
return the space avaiable for writing.
|
void |
resize(int newSize)
Resize the ring buffer.
|
void |
setEOF(boolean eof)
Set the EOF status.
|
int |
size()
Return the size of the ring buffer.
|
protected static final int DEFAULT_BUFFER_SIZE
protected volatile int bufferSize
protected byte[] buffer
protected volatile int putHere
protected volatile int getHere
protected volatile boolean eof
protected Object signal
public RingBuffer(int size)
size - The size of the ring bufferpublic RingBuffer()
public int size()
public void resize(int newSize)
newSize - The new size of the ring bufferpublic int putAvailable()
public void empty()
public void put(byte[] data,
int offset,
int len)
data - The data to writeoffset - The start position in the data arraylen - The bytes from the data array to writepublic int getAvailable()
public int get(byte[] data,
int offset,
int len)
data - Where to put the dataoffset - The offset into the data array to start putting datalen - The maximum data to readpublic boolean isEOF()
public void setEOF(boolean eof)
eof - The eof to set.public static void main(String[] args)
args - Not usedCopyright © 2004–2017. All rights reserved.