Package org.apache.http.impl.nio.reactor
Class SessionOutputBufferImpl
java.lang.Object
org.apache.http.nio.util.ExpandableBuffer
org.apache.http.impl.nio.reactor.SessionOutputBufferImpl
- All Implemented Interfaces:
BufferInfo,SessionOutputBuffer,BufferInfo
Default implementation of
SessionOutputBuffer based on
the ExpandableBuffer class.- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CharBufferprivate final CharsetEncoderprivate static final byte[]private final intFields inherited from class org.apache.http.nio.util.ExpandableBuffer
buffer, INPUT_MODE, OUTPUT_MODE -
Constructor Summary
ConstructorsConstructorDescriptionSessionOutputBufferImpl(int bufferSize) Creates SessionOutputBufferImpl instance.SessionOutputBufferImpl(int bufferSize, int lineBufferSize) Creates SessionOutputBufferImpl instance.SessionOutputBufferImpl(int bufferSize, int lineBufferSize, Charset charset) Creates SessionOutputBufferImpl instance.SessionOutputBufferImpl(int bufferSize, int lineBufferSize, CharsetEncoder charEncoder, ByteBufferAllocator allocator) Creates SessionOutputBufferImpl instance.SessionOutputBufferImpl(int bufferSize, int lineBufferSize, ByteBufferAllocator allocator, HttpParams params) Deprecated.SessionOutputBufferImpl(int bufferSize, int lineBufferSize, HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears buffer.intflush(WritableByteChannel channel) Makes an attempt to flush the content of this buffer to the given destinationWritableByteChannel.voidreset(HttpParams params) private voidwrite(byte[] b) voidwrite(ByteBuffer src) Copies content of the source buffer into this buffer.voidwrite(ReadableByteChannel src) Reads a sequence of bytes from the source channel into this buffer.private voidvoidCopies content of the given string into this buffer as one line of text including a line delimiter.voidwriteLine(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.http.nio.util.ExpandableBuffer
available, capacity, ensureCapacity, expand, getMode, hasData, length, setInputMode, setOutputMode, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.http.nio.reactor.SessionOutputBuffer
hasData, length
-
Field Details
-
CRLF
private static final byte[] CRLF -
charEncoder
-
lineBufferSize
private final int lineBufferSize -
charBuffer
-
-
Constructor Details
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, CharsetEncoder charEncoder, ByteBufferAllocator allocator) Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize- input buffer size.lineBufferSize- buffer size for line operations. Has effect only ifcharEncoderis notnull.charEncoder- CharEncoder to be used for encoding HTTP protocol elements. Ifnullsimple type cast will be used for char to byte conversion.allocator- memory allocator. IfnullHeapByteBufferAllocator.INSTANCEwill be used.- Since:
- 4.3
-
SessionOutputBufferImpl
@Deprecated public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, ByteBufferAllocator allocator, HttpParams params) Deprecated. -
SessionOutputBufferImpl
Deprecated. -
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize) Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize- input buffer size.- Since:
- 4.3
-
SessionOutputBufferImpl
Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize- input buffer size.lineBufferSize- buffer size for line operations. Has effect only ifcharsetis notnull.charset- Charset to be used for encoding HTTP protocol elements. Ifnullsimple type cast will be used for char to byte conversion.- Since:
- 4.3
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize) Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize- input buffer size.lineBufferSize- buffer size for line operations.- Since:
- 4.3
-
-
Method Details
-
reset
-
flush
Description copied from interface:SessionOutputBufferMakes an attempt to flush the content of this buffer to the given destinationWritableByteChannel.- Specified by:
flushin 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:SessionOutputBufferCopies 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:
writein interfaceSessionOutputBuffer- Parameters:
src- the source buffer.
-
write
Description copied from interface:SessionOutputBufferReads a sequence of bytes from the source channel into this buffer.- Specified by:
writein interfaceSessionOutputBuffer- Parameters:
src- the source channel.- Throws:
IOException
-
write
private void write(byte[] b) -
writeCRLF
private void writeCRLF() -
writeLine
Description copied from interface:SessionOutputBufferCopies 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:
writeLinein interfaceSessionOutputBuffer- Parameters:
lineBuffer- the source buffer.- Throws:
CharacterCodingException
-
writeLine
Description copied from interface:SessionOutputBufferCopies content of the given string 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 string.The choice of a char encoding and line delimiter sequence is up to the specific implementations of this interface.
- Specified by:
writeLinein interfaceSessionOutputBuffer- Parameters:
s- the string.- Throws:
IOException
-
clear
public void clear()Description copied from class:ExpandableBufferClears buffer.- Overrides:
clearin classExpandableBuffer
-
SessionOutputBufferImpl(int, int, CharsetEncoder, ByteBufferAllocator)