Class SessionOutputBufferImpl
java.lang.Object
org.apache.hc.core5.http.impl.nio.ExpandableBuffer
org.apache.hc.core5.http.impl.nio.SessionOutputBufferImpl
- All Implemented Interfaces:
SessionOutputBuffer
-
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 CharsetEncoder
private static final byte[]
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionSessionOutputBufferImpl
(int bufferSize) SessionOutputBufferImpl
(int bufferSize, int lineBufferSize) SessionOutputBufferImpl
(int bufferSize, int lineBufferSize, Charset charset) SessionOutputBufferImpl
(int bufferSize, int lineBufferSize, CharsetEncoder charEncoder) Creates SessionOutputBufferImpl instance. -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
Returns available capacity of this buffer.int
flush
(WritableByteChannel channel) Makes an attempt to flush the content of this buffer to the given destinationWritableByteChannel
.boolean
hasData()
Determines if the buffer contains data.int
length()
Returns the length of this buffer.private void
write
(byte[] b) void
write
(ByteBuffer src) Copies content of the source buffer into this buffer.void
write
(ReadableByteChannel src) Reads a sequence of bytes from the source channel into this buffer.private void
void
writeLine
(CharArrayBuffer lineBuffer) Copies content of the source buffer into this buffer as one line of text including a line delimiter.Methods inherited from class org.apache.hc.core5.http.impl.nio.ExpandableBuffer
buffer, clear, ensureAdjustedCapacity, ensureCapacity, expand, mode, setInputMode, setOutputMode, toString
-
Field Details
-
CRLF
private static final byte[] CRLF -
charEncoder
-
lineBufferSize
private final int lineBufferSize -
charbuffer
-
-
Constructor Details
-
SessionOutputBufferImpl
Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize
- input buffer sizelineBufferSize
- buffer size for line operations. Has effect only ifcharEncoder
is notnull
.charEncoder
- charEncoder to be used for encoding HTTP protocol elements. Ifnull
simple type cast will be used for char to byte conversion.- Since:
- 4.3
-
SessionOutputBufferImpl
- Since:
- 4.3
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize) - Since:
- 4.3
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(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 interfaceSessionOutputBuffer
- 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 interfaceSessionOutputBuffer
- 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.- Specified by:
capacity
in interfaceSessionOutputBuffer
- Overrides:
capacity
in classExpandableBuffer
- Returns:
- buffer length.
-
flush
Description copied from interface:SessionOutputBuffer
Makes an attempt to flush the content of this buffer to the given destinationWritableByteChannel
.- Specified by:
flush
in interfaceSessionOutputBuffer
- Parameters:
channel
- the destination channel.- Returns:
- The number of bytes written, possibly zero.
- Throws:
IOException
- in case of an I/O error.
-
write
Description copied from interface:SessionOutputBuffer
Copies content of the source buffer into this buffer. The capacity of the destination will be expanded in order to accommodate the entire content of the source buffer.- Specified by:
write
in interfaceSessionOutputBuffer
- Parameters:
src
- the source buffer.
-
write
Description copied from interface:SessionOutputBuffer
Reads a sequence of bytes from the source channel into this buffer.- Specified by:
write
in interfaceSessionOutputBuffer
- Parameters:
src
- the source channel.- Throws:
IOException
-
write
private void write(byte[] b) -
writeCRLF
private void writeCRLF() -
writeLine
Description copied from interface:SessionOutputBuffer
Copies content of the source buffer into this buffer as one line of text including a line delimiter. The capacity of the destination will be expanded in order to accommodate the entire content of the source buffer.The choice of a char encoding and line delimiter sequence is up to the specific implementations of this interface.
- Specified by:
writeLine
in interfaceSessionOutputBuffer
- Parameters:
lineBuffer
- the source buffer.- Throws:
CharacterCodingException
-