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
public class SessionOutputBufferImpl extends ExpandableBuffer implements SessionOutputBuffer
Default implementation ofSessionOutputBuffer
based on theExpandableBuffer
class.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.CharBuffer
charBuffer
private java.nio.charset.CharsetEncoder
charEncoder
private static byte[]
CRLF
private int
lineBufferSize
-
Fields inherited from class org.apache.http.nio.util.ExpandableBuffer
buffer, INPUT_MODE, OUTPUT_MODE
-
-
Constructor Summary
Constructors Constructor Description SessionOutputBufferImpl(int bufferSize)
Creates SessionOutputBufferImpl instance.SessionOutputBufferImpl(int bufferSize, int lineBufferSize)
Creates SessionOutputBufferImpl instance.SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.Charset charset)
Creates SessionOutputBufferImpl instance.SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
flush(java.nio.channels.WritableByteChannel channel)
Makes an attempt to flush the content of this buffer to the given destinationWritableByteChannel
.void
reset(HttpParams params)
private void
write(byte[] b)
void
write(java.nio.ByteBuffer src)
Copies content of the source buffer into this buffer.void
write(java.nio.channels.ReadableByteChannel src)
Reads a sequence of bytes from the source channel into this buffer.private void
writeCRLF()
void
writeLine(java.lang.String s)
Copies content of the given string into this buffer as one line of text including a line delimiter.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.http.nio.util.ExpandableBuffer
available, capacity, clear, ensureCapacity, expand, getMode, hasData, length, setInputMode, setOutputMode, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.http.nio.reactor.SessionOutputBuffer
hasData, length
-
-
-
-
Constructor Detail
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.CharsetEncoder charEncoder, ByteBufferAllocator allocator)
Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize
- input buffer size.lineBufferSize
- 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.allocator
- memory allocator. Ifnull
HeapByteBufferAllocator.INSTANCE
will be used.- Since:
- 4.3
-
SessionOutputBufferImpl
@Deprecated public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, ByteBufferAllocator allocator, HttpParams params)
Deprecated.
-
SessionOutputBufferImpl
@Deprecated public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, HttpParams params)
Deprecated.
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize)
Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize
- input buffer size.- Since:
- 4.3
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.Charset charset)
Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize
- input buffer size.lineBufferSize
- buffer size for line operations. Has effect only ifcharset
is notnull
.charset
- Charset to be used for encoding HTTP protocol elements. Ifnull
simple 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 Detail
-
reset
public void reset(HttpParams params)
-
flush
public int flush(java.nio.channels.WritableByteChannel channel) throws java.io.IOException
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:
java.io.IOException
- in case of an I/O error.
-
write
public void write(java.nio.ByteBuffer src)
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
public void write(java.nio.channels.ReadableByteChannel src) throws java.io.IOException
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:
java.io.IOException
-
write
private void write(byte[] b)
-
writeCRLF
private void writeCRLF()
-
writeLine
public void writeLine(CharArrayBuffer lineBuffer) throws java.nio.charset.CharacterCodingException
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:
java.nio.charset.CharacterCodingException
-
writeLine
public void writeLine(java.lang.String s) throws java.io.IOException
Description copied from interface:SessionOutputBuffer
Copies 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:
writeLine
in interfaceSessionOutputBuffer
- Parameters:
s
- the string.- Throws:
java.io.IOException
-
-