Package org.apache.http.impl.nio.reactor
Class SessionInputBufferImpl
java.lang.Object
org.apache.http.nio.util.ExpandableBuffer
org.apache.http.impl.nio.reactor.SessionInputBufferImpl
- All Implemented Interfaces:
BufferInfo,SessionInputBuffer,BufferInfo
Default implementation of
SessionInputBuffer based on
the ExpandableBuffer class.- Since:
- 4.0
-
Field Summary
Fields inherited from class org.apache.http.nio.util.ExpandableBuffer
INPUT_MODE, OUTPUT_MODE -
Constructor Summary
ConstructorsConstructorDescriptionSessionInputBufferImpl(int buffersize) SessionInputBufferImpl(int buffersize, int lineBuffersize) SessionInputBufferImpl(int buffersize, int lineBuffersize, Charset charset) SessionInputBufferImpl(int buffersize, int lineBuffersize, CharsetDecoder chardecoder, ByteBufferAllocator allocator) Creates SessionInputBufferImpl instance.SessionInputBufferImpl(int buffersize, int lineBuffersize, MessageConstraints constraints, Charset charset) SessionInputBufferImpl(int buffersize, int lineBuffersize, MessageConstraints constraints, CharsetDecoder chardecoder, ByteBufferAllocator allocator) Creates SessionInputBufferImpl instance.SessionInputBufferImpl(int buffersize, int lineBuffersize, ByteBufferAllocator allocator, HttpParams params) Deprecated.SessionInputBufferImpl(int buffersize, int linebuffersize, HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionintfill(ReadableByteChannel channel) Makes an attempt to fill the buffer with data from the givenReadableByteChannel.intread()Reads one byte from the buffer.intread(ByteBuffer dst) Reads a sequence of bytes from this buffer into the destination buffer.intread(ByteBuffer dst, int maxLen) Reads a sequence of bytes from this buffer into the destination buffer, up to the given maximum limit.intread(WritableByteChannel dst) Reads a sequence of bytes from this buffer into the destination channel.intread(WritableByteChannel dst, int maxLen) Reads a sequence of bytes from this buffer into the destination channel, up to the given maximum limit.readLine(boolean endOfStream) Attempts to transfer a complete line of characters up to a line delimiter from this buffer to a newly created string.booleanreadLine(CharArrayBuffer linebuffer, boolean endOfStream) Attempts to transfer a complete line of characters up to a line delimiter from this buffer to the destination buffer.Methods inherited from class org.apache.http.nio.util.ExpandableBuffer
available, capacity, hasData, length, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.http.nio.reactor.SessionInputBuffer
hasData, length
-
Constructor Details
-
SessionInputBufferImpl
public SessionInputBufferImpl(int buffersize, int lineBuffersize, MessageConstraints constraints, CharsetDecoder chardecoder, ByteBufferAllocator allocator) Creates SessionInputBufferImpl instance.- Parameters:
buffersize- input buffer sizelineBuffersize- buffer size for line operations. Has effect only ifchardecoderis notnull.constraints- Message constraints. IfnullMessageConstraints.DEFAULTwill be used.chardecoder- chardecoder to be used for decoding HTTP protocol elements. Ifnullsimple type cast will be used for byte to char conversion.allocator- memory allocator. IfnullHeapByteBufferAllocator.INSTANCEwill be used.- Since:
- 4.4
-
SessionInputBufferImpl
public SessionInputBufferImpl(int buffersize, int lineBuffersize, CharsetDecoder chardecoder, ByteBufferAllocator allocator) Creates SessionInputBufferImpl instance.- Parameters:
buffersize- input buffer sizelineBuffersize- buffer size for line operations. Has effect only ifchardecoderis notnull.chardecoder- chardecoder to be used for decoding HTTP protocol elements. Ifnullsimple type cast will be used for byte to char conversion.allocator- memory allocator. IfnullHeapByteBufferAllocator.INSTANCEwill be used.- Since:
- 4.3
-
SessionInputBufferImpl
@Deprecated public SessionInputBufferImpl(int buffersize, int lineBuffersize, ByteBufferAllocator allocator, HttpParams params) Deprecated. -
SessionInputBufferImpl
Deprecated. -
SessionInputBufferImpl
- Since:
- 4.3
-
SessionInputBufferImpl
public SessionInputBufferImpl(int buffersize, int lineBuffersize, MessageConstraints constraints, Charset charset) - Since:
- 4.3
-
SessionInputBufferImpl
public SessionInputBufferImpl(int buffersize, int lineBuffersize) - Since:
- 4.3
-
SessionInputBufferImpl
public SessionInputBufferImpl(int buffersize) - Since:
- 4.3
-
-
Method Details
-
fill
Description copied from interface:SessionInputBufferMakes an attempt to fill the buffer with data from the givenReadableByteChannel.- Specified by:
fillin interfaceSessionInputBuffer- Parameters:
channel- the source channel- Returns:
- The number of bytes read, possibly zero, or
-1if the channel has reached end-of-stream. - Throws:
IOException- in case of an I/O error.
-
read
public int read()Description copied from interface:SessionInputBufferReads one byte from the buffer. If the buffer is empty this method can throw a runtime exception. The exact type of runtime exception thrown by this method depends on implementation.- Specified by:
readin interfaceSessionInputBuffer- Returns:
- one byte
-
read
Description copied from interface:SessionInputBufferReads a sequence of bytes from this buffer into the destination buffer, up to the given maximum limit. The exact number of bytes transferred depends on availability of data in this buffer and capacity of the destination buffer, but cannot be more thanmaxLenvalue.- Specified by:
readin interfaceSessionInputBuffer- Parameters:
dst- the destination buffer.maxLen- the maximum number of bytes to be read.- Returns:
- The number of bytes read, possibly zero.
-
read
Description copied from interface:SessionInputBufferReads a sequence of bytes from this buffer into the destination buffer. The exact number of bytes transferred depends on availability of data in this buffer and capacity of the destination buffer.- Specified by:
readin interfaceSessionInputBuffer- Parameters:
dst- the destination buffer.- Returns:
- The number of bytes read, possibly zero.
-
read
Description copied from interface:SessionInputBufferReads a sequence of bytes from this buffer into the destination channel, up to the given maximum limit. The exact number of bytes transferred depends on availability of data in this buffer, but cannot be more thanmaxLenvalue.- Specified by:
readin interfaceSessionInputBuffer- Parameters:
dst- the destination channel.maxLen- the maximum number of bytes to be read.- Returns:
- The number of bytes read, possibly zero.
- Throws:
IOException- in case of an I/O error.
-
read
Description copied from interface:SessionInputBufferReads a sequence of bytes from this buffer into the destination channel. The exact number of bytes transferred depends on availability of data in this buffer.- Specified by:
readin interfaceSessionInputBuffer- Parameters:
dst- the destination channel.- Returns:
- The number of bytes read, possibly zero.
- Throws:
IOException- in case of an I/O error.
-
readLine
public boolean readLine(CharArrayBuffer linebuffer, boolean endOfStream) throws CharacterCodingException Description copied from interface:SessionInputBufferAttempts to transfer a complete line of characters up to a line delimiter from this buffer to the destination buffer. If a complete line is available in the buffer, the sequence of chars is transferred to the destination buffer the method returnstrue. The line delimiter itself is discarded. If a complete line is not available in the buffer, this method returnsfalsewithout transferring anything to the destination buffer. IfendOfStreamparameter is set totruethis method assumes the end of stream has been reached and the content currently stored in the buffer should be treated as a complete line.The choice of a char encoding and line delimiter sequence is up to the specific implementations of this interface.
- Specified by:
readLinein interfaceSessionInputBuffer- Parameters:
linebuffer- the destination buffer.endOfStream- end of stream flag- Returns:
trueif a sequence of chars representing a complete line has been transferred to the destination buffer,falseotherwise.- Throws:
CharacterCodingException- in case a character encoding or decoding error occurs.
-
readLine
Description copied from interface:SessionInputBufferAttempts to transfer a complete line of characters up to a line delimiter from this buffer to a newly created string. If a complete line is available in the buffer, the sequence of chars is transferred to a newly created string. The line delimiter itself is discarded. If a complete line is not available in the buffer, this method returnsnull. IfendOfStreamparameter is set totruethis method assumes the end of stream has been reached and the content currently stored in the buffer should be treated as a complete line.The choice of a char encoding and line delimiter sequence is up to the specific implementations of this interface.
- Specified by:
readLinein interfaceSessionInputBuffer- Parameters:
endOfStream- end of stream flag- Returns:
- a string representing a complete line, if available.
nullotherwise. - Throws:
CharacterCodingException- in case a character encoding or decoding error occurs.
-
SessionInputBufferImpl(int, int, CharsetDecoder, ByteBufferAllocator)