de.unkrig.commons.io.pipe
Class AbstractRingBuffer
java.lang.Object
de.unkrig.commons.io.pipe.AbstractPipe
de.unkrig.commons.io.pipe.AbstractRingBuffer
- All Implemented Interfaces:
- Pipe, java.io.Closeable
public abstract class AbstractRingBuffer
- extends AbstractPipe
Implementation of a pipe by a ring buffer.
|
Method Summary |
abstract void |
get(long pos,
byte[] buf,
int off,
int len)
Transfers len bytes from the backing store to buf[off].... |
boolean |
isEmpty()
|
boolean |
isFull()
|
abstract void |
put(byte[] buf,
int off,
int len,
long pos)
Transfers len bytes from buf[off]... to the backing store. |
int |
read(byte[] buf,
int off,
int len)
|
int |
write(byte[] buf,
int off,
int len)
|
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface de.unkrig.commons.io.pipe.Pipe |
close |
AbstractRingBuffer
public AbstractRingBuffer(long capacity)
get
public abstract void get(long pos,
byte[] buf,
int off,
int len)
throws java.io.IOException
- Transfers
len bytes from the backing store to buf[off]....
- Parameters:
pos - 0...capacityoff - 0...buf.lengthlen - 0...min(capacity - pos, buf.length - off
- Throws:
java.io.IOException- See Also:
AbstractRingBuffer(long)
put
public abstract void put(byte[] buf,
int off,
int len,
long pos)
throws java.io.IOException
- Transfers
len bytes from buf[off]... to the backing store.
- Parameters:
off - 0...buf.lengthlen - 0...min(capacity - pos, buf.length - offpos - 0...capacity
- Throws:
java.io.IOException- See Also:
AbstractRingBuffer(long)
read
public final int read(byte[] buf,
int off,
int len)
throws java.io.IOException
- Returns:
- The number of bytes read; 0 iff the pipe is empty
- Throws:
java.io.IOException
write
public final int write(byte[] buf,
int off,
int len)
throws java.io.IOException
- Returns:
- The number of bytes written; 0 iff the pipe is full
- Throws:
java.io.IOException
isEmpty
public final boolean isEmpty()
- Returns:
- Whether the next invocation of
Pipe.read(byte[], int, int) will return 0
isFull
public final boolean isFull()
- Returns:
- Whether the next invocation of
Pipe.write(byte[], int, int) will return 0