Class SessionInputBufferImpl
java.lang.Object
org.apache.hc.core5.http.impl.nio.ExpandableBuffer
org.apache.hc.core5.http.impl.nio.SessionInputBufferImpl
- All Implemented Interfaces:
SessionInputBuffer
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hc.core5.http.impl.nio.ExpandableBuffer
ExpandableBuffer.Mode
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CharBuffer
private final CharsetDecoder
private final int
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionSessionInputBufferImpl
(int bufferSize) SessionInputBufferImpl
(int bufferSize, int lineBuffersize) SessionInputBufferImpl
(int bufferSize, int lineBuffersize, int maxLineLen) SessionInputBufferImpl
(int bufferSize, int lineBuffersize, int maxLineLen, Charset charset) SessionInputBufferImpl
(int bufferSize, int lineBuffersize, int maxLineLen, CharsetDecoder charDecoder) Creates SessionInputBufferImpl instance. -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
Returns available capacity of this buffer.int
fill
(ReadableByteChannel channel) Makes an attempt to fill the buffer with data from the givenReadableByteChannel
.boolean
hasData()
Determines if the buffer contains data.int
length()
Returns the length of this buffer.void
put
(ByteBuffer src) int
read()
Reads one byte from the buffer.int
read
(ByteBuffer dst) Reads a sequence of bytes from this buffer into the destination buffer.int
read
(ByteBuffer dst, int maxLen) Reads a sequence of bytes from this buffer into the destination buffer, up to the given maximum limit.int
read
(WritableByteChannel dst) Reads a sequence of bytes from this buffer into the destination channel.int
read
(WritableByteChannel dst, int maxLen) Reads a sequence of bytes from this buffer into the destination channel, up to the given maximum limit.boolean
readLine
(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.hc.core5.http.impl.nio.ExpandableBuffer
buffer, clear, ensureAdjustedCapacity, ensureCapacity, expand, mode, setInputMode, setOutputMode, toString
-
Field Details
-
charDecoder
-
lineBuffersize
private final int lineBuffersize -
maxLineLen
private final int maxLineLen -
charbuffer
-
-
Constructor Details
-
SessionInputBufferImpl
public SessionInputBufferImpl(int bufferSize, int lineBuffersize, int maxLineLen, CharsetDecoder charDecoder) Creates SessionInputBufferImpl instance.- Parameters:
bufferSize
- input buffer sizelineBuffersize
- buffer size for line operations. Has effect only ifcharDecoder
is notnull
.maxLineLen
- maximum line length.charDecoder
- charDecoder to be used for decoding HTTP protocol elements. Ifnull
simple type cast will be used for byte to char conversion.- Since:
- 4.4
-
SessionInputBufferImpl
- Since:
- 4.3
-
SessionInputBufferImpl
public SessionInputBufferImpl(int bufferSize, int lineBuffersize, int maxLineLen) - Since:
- 4.3
-
SessionInputBufferImpl
public SessionInputBufferImpl(int bufferSize, int lineBuffersize) - Since:
- 4.3
-
SessionInputBufferImpl
public SessionInputBufferImpl(int bufferSize) - Since:
- 4.3
-
-
Method Details
-
length
public int length()Description copied from class:ExpandableBuffer
Returns the length of this buffer.Sets the mode to output.
- Specified by:
length
in interfaceSessionInputBuffer
- Overrides:
length
in classExpandableBuffer
- Returns:
- buffer length.
-
hasData
public boolean hasData()Description copied from class:ExpandableBuffer
Determines if the buffer contains data.Sets the mode to output.
- Specified by:
hasData
in interfaceSessionInputBuffer
- Overrides:
hasData
in classExpandableBuffer
- Returns:
true
if there is data in the buffer,false
otherwise.
-
capacity
public int capacity()Description copied from class:ExpandableBuffer
Returns available capacity of this buffer.- Overrides:
capacity
in classExpandableBuffer
- Returns:
- buffer length.
-
put
-
fill
Description copied from interface:SessionInputBuffer
Makes an attempt to fill the buffer with data from the givenReadableByteChannel
.- Specified by:
fill
in interfaceSessionInputBuffer
- Parameters:
channel
- the source channel- Returns:
- The number of bytes read, possibly zero, or
-1
if the channel has reached end-of-stream. - Throws:
IOException
- in case of an I/O error.
-
read
public int read()Description copied from interface:SessionInputBuffer
Reads 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:
read
in interfaceSessionInputBuffer
- Returns:
- one byte
-
read
Description copied from interface:SessionInputBuffer
Reads 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 thanmaxLen
value.- Specified by:
read
in 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:SessionInputBuffer
Reads 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:
read
in interfaceSessionInputBuffer
- Parameters:
dst
- the destination buffer.- Returns:
- The number of bytes read, possibly zero.
-
read
Description copied from interface:SessionInputBuffer
Reads 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 thanmaxLen
value.- Specified by:
read
in 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:SessionInputBuffer
Reads 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:
read
in interfaceSessionInputBuffer
- Parameters:
dst
- the destination channel.- Returns:
- The number of bytes read, possibly zero.
- Throws:
IOException
- in case of an I/O error.
-
readLine
Description copied from interface:SessionInputBuffer
Attempts 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 returnsfalse
without transferring anything to the destination buffer. IfendOfStream
parameter is set totrue
this 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:
readLine
in interfaceSessionInputBuffer
- Parameters:
lineBuffer
- the destination buffer.endOfStream
- end of stream flag- Returns:
true
if a sequence of chars representing a complete line has been transferred to the destination buffer,false
otherwise.- Throws:
IOException
-