@ThreadSafe public class SharedInputBuffer extends ExpandableBuffer implements ContentInputBuffer
ContentInputBuffer interface that can be
shared by multiple threads, usually the I/O dispatch of an I/O reactor and
a worker thread.
The I/O dispatch thread is expect to transfer data from ContentDecoder to the buffer
by calling consumeContent(ContentDecoder).
The worker thread is expected to read the data from the buffer by calling
read() or read(byte[], int, int) methods.
In case of an abnormal situation or when no longer needed the buffer must be shut down
using shutdown() method.
buffer, INPUT_MODE, OUTPUT_MODE| 构造器和说明 |
|---|
SharedInputBuffer(int buffersize) |
SharedInputBuffer(int buffersize,
ByteBufferAllocator allocator) |
SharedInputBuffer(int buffersize,
IOControl ioctrl,
ByteBufferAllocator allocator)
已过时。
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
available()
Returns available capacity of this buffer.
|
int |
capacity()
Returns the total capacity of this buffer.
|
void |
close() |
int |
consumeContent(ContentDecoder decoder)
已过时。
|
int |
consumeContent(ContentDecoder decoder,
IOControl ioctrl) |
boolean |
hasData()
Determines if the buffer contains data.
|
protected boolean |
isEndOfStream() |
protected boolean |
isShutdown() |
int |
length()
Returns the length of this buffer.
|
int |
read()
Reads one byte from this buffer.
|
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from this buffer into
an array of bytes. |
void |
reset()
Resets the buffer by clearing its state and stored content.
|
void |
shutdown() |
protected void |
waitForData() |
clear, ensureCapacity, expand, getMode, setInputMode, setOutputMode, toString@Deprecated
public SharedInputBuffer(int buffersize,
IOControl ioctrl,
ByteBufferAllocator allocator)
SharedInputBuffer(int, ByteBufferAllocator)public SharedInputBuffer(int buffersize,
ByteBufferAllocator allocator)
public SharedInputBuffer(int buffersize)
public void reset()
ContentInputBufferreset 在接口中 ContentInputBuffer@Deprecated public int consumeContent(ContentDecoder decoder) throws java.io.IOException
consumeContent(ContentDecoder, IOControl)ContentInputBufferContentDecoder and stores it in
this buffer.consumeContent 在接口中 ContentInputBufferdecoder - the content decoder.java.io.IOException - in case of an I/O error.public int consumeContent(ContentDecoder decoder, IOControl ioctrl) throws java.io.IOException
java.io.IOExceptionpublic boolean hasData()
ExpandableBufferhasData 在类中 ExpandableBuffertrue if there is data in the buffer,
false otherwise.public int available()
ExpandableBufferavailable 在接口中 BufferInfoavailable 在类中 ExpandableBufferpublic int capacity()
ExpandableBuffercapacity 在接口中 BufferInfocapacity 在类中 ExpandableBufferpublic int length()
ExpandableBufferlength 在接口中 BufferInfolength 在类中 ExpandableBufferprotected void waitForData()
throws java.io.IOException
java.io.IOExceptionpublic void close()
public void shutdown()
protected boolean isShutdown()
protected boolean isEndOfStream()
public int read()
throws java.io.IOException
ContentInputBuffer-1 if the end of content stream has been reached.read 在接口中 ContentInputBufferjava.io.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
ContentInputBufferlen bytes of data from this buffer into
an array of bytes. The exact number of bytes read depends how many bytes
are stored in the buffer.
If off is negative, or len is negative, or
off+len is greater than the length of the array
b, this method can throw a runtime exception. The exact category
of runtime exception thrown by this method depends on implementation.
This method returns -1 if the end of content stream has been
reached.
read 在接口中 ContentInputBufferb - the buffer into which the data is read.off - the start offset in array b
at which the data is written.len - the maximum number of bytes to read.-1 if there is no more data because the end of
the stream has been reached.java.io.IOException - if an I/O error occurs.public int read(byte[] b)
throws java.io.IOException
java.io.IOException