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
class SessionOutputBufferImpl extends ExpandableBuffer implements SessionOutputBuffer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.hc.core5.http.impl.nio.ExpandableBuffer
ExpandableBuffer.Mode
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.CharBuffercharbufferprivate java.nio.charset.CharsetEncodercharEncoderprivate static byte[]CRLFprivate intlineBufferSize
-
Constructor Summary
Constructors Constructor Description SessionOutputBufferImpl(int bufferSize)SessionOutputBufferImpl(int bufferSize, int lineBufferSize)SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.Charset charset)SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.CharsetEncoder charEncoder)Creates SessionOutputBufferImpl instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()Returns available capacity of this buffer.intflush(java.nio.channels.WritableByteChannel channel)Makes an attempt to flush the content of this buffer to the given destinationWritableByteChannel.booleanhasData()Determines if the buffer contains data.intlength()Returns the length of this buffer.private voidwrite(byte[] b)voidwrite(java.nio.ByteBuffer src)Copies content of the source buffer into this buffer.voidwrite(java.nio.channels.ReadableByteChannel src)Reads a sequence of bytes from the source channel into this buffer.private voidwriteCRLF()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.hc.core5.http.impl.nio.ExpandableBuffer
buffer, clear, ensureAdjustedCapacity, ensureCapacity, expand, mode, setInputMode, setOutputMode, toString
-
-
-
-
Constructor Detail
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.CharsetEncoder charEncoder)Creates SessionOutputBufferImpl instance.- Parameters:
bufferSize- input buffer sizelineBufferSize- 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.- Since:
- 4.3
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, java.nio.charset.Charset charset)- Since:
- 4.3
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize, int lineBufferSize)- Since:
- 4.3
-
SessionOutputBufferImpl
public SessionOutputBufferImpl(int bufferSize)
- Since:
- 4.3
-
-
Method Detail
-
length
public int length()
Description copied from class:ExpandableBufferReturns the length of this buffer.Sets the mode to output.
- Specified by:
lengthin interfaceSessionOutputBuffer- Overrides:
lengthin classExpandableBuffer- Returns:
- buffer length.
-
hasData
public boolean hasData()
Description copied from class:ExpandableBufferDetermines if the buffer contains data.Sets the mode to output.
- Specified by:
hasDatain interfaceSessionOutputBuffer- Overrides:
hasDatain classExpandableBuffer- Returns:
trueif there is data in the buffer,falseotherwise.
-
capacity
public int capacity()
Description copied from class:ExpandableBufferReturns available capacity of this buffer.- Specified by:
capacityin interfaceSessionOutputBuffer- Overrides:
capacityin classExpandableBuffer- Returns:
- buffer length.
-
flush
public int flush(java.nio.channels.WritableByteChannel channel) throws java.io.IOExceptionDescription 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:
java.io.IOException- in case of an I/O error.
-
write
public void write(java.nio.ByteBuffer src)
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
public void write(java.nio.channels.ReadableByteChannel src) throws java.io.IOExceptionDescription 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:
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: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:
java.nio.charset.CharacterCodingException
-
-