public class FifoBuffer extends Object implements Closeable
Modifier and Type | Class and Description |
---|---|
static class |
FifoBuffer.CloseCause
Explains the reason of the buffer close.
|
Constructor and Description |
---|
FifoBuffer(int limit) |
FifoBuffer(int pageSize,
int limit) |
FifoBuffer(Object lock,
int pageSize,
int limit) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Indicates that there will be no more write.
|
FifoBuffer.CloseCause |
getCloseCause()
Returns Exception with stacktrace of the command, which invoked the buffer close.
|
InputStream |
getInputStream()
Wraps the reader end of it to
InputStream |
OutputStream |
getOutputStream()
Wraps writer end of it to
OutputStream . |
boolean |
isClosed()
Returns true if the write end of the buffer is already closed, and that
no more new data will arrive.
|
int |
peek(int offset,
byte[] data) |
int |
peek(int offset,
byte[] data,
int start,
int len)
Peek the specified number of bytes (
len ) at the specified offset in this buffer (offset )
and places it into the specified position (start ) of the array (data ) |
int |
read(byte[] buf) |
int |
read(byte[] buf,
int start,
int len) |
int |
readable()
Number of bytes available in this buffer that are readable.
|
int |
readNonBlocking(byte[] buf) |
int |
readNonBlocking(byte[] buf,
int start,
int len) |
int |
receive(ReadableByteChannel ch)
Read bytes from a channel and stores it into this buffer.
|
int |
send(WritableByteChannel ch)
Read from this buffer write as much as possible to the channel until
the channel gets filled up.
|
void |
setLimit(int newLimit)
Set limit to the number of maximum bytes this buffer can hold.
|
int |
writable()
Number of bytes writable.
|
void |
write(byte[] buf) |
void |
write(byte[] buf,
int start,
int len) |
int |
writeNonBlock(ByteBuffer buf)
Non-blocking write.
|
public FifoBuffer(int pageSize, int limit)
public FifoBuffer(int limit)
public FifoBuffer(Object lock, int pageSize, int limit)
public void setLimit(int newLimit)
public int readable()
public int writable()
public boolean isClosed()
true
when the close operation is actually requested.@CheckForNull public FifoBuffer.CloseCause getCloseCause()
null
public int send(WritableByteChannel ch) throws IOException
IOException
public int writeNonBlock(ByteBuffer buf)
public int receive(ReadableByteChannel ch) throws IOException
IOException
- receive errorpublic void write(byte[] buf) throws InterruptedException, IOException
InterruptedException
IOException
public void write(byte[] buf, int start, int len) throws InterruptedException, IOException
InterruptedException
IOException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public int peek(int offset, byte[] data, int start, int len)
len
) at the specified offset in this buffer (offset
)
and places it into the specified position (start
) of the array (data
)public int peek(int offset, byte[] data)
public int read(byte[] buf) throws InterruptedException
InterruptedException
public int read(byte[] buf, int start, int len) throws InterruptedException
InterruptedException
InputStream.read(byte[],int,int)
public int readNonBlocking(byte[] buf)
public int readNonBlocking(byte[] buf, int start, int len)
InputStream.read(byte[],int,int)
public OutputStream getOutputStream()
OutputStream
.public InputStream getInputStream()
InputStream
Copyright © 2004–2022. All rights reserved.