Class SessionOutputBufferImpl

    • 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  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int capacity()
      Returns available capacity of this buffer.
      int flush​(java.nio.channels.WritableByteChannel channel)
      Makes an attempt to flush the content of this buffer to the given destination WritableByteChannel.
      boolean hasData()
      Determines if the buffer contains data.
      int length()
      Returns the length of this buffer.
      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​(CharArrayBuffer lineBuffer)
      Copies content of the source buffer into this buffer as one line of text including a line delimiter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • CRLF

        private static final byte[] CRLF
      • charEncoder

        private final java.nio.charset.CharsetEncoder charEncoder
      • lineBufferSize

        private final int lineBufferSize
      • charbuffer

        private java.nio.CharBuffer charbuffer
    • Constructor Detail

      • SessionOutputBufferImpl

        public SessionOutputBufferImpl​(int bufferSize,
                                       int lineBufferSize,
                                       java.nio.charset.CharsetEncoder charEncoder)
        Creates SessionOutputBufferImpl instance.
        Parameters:
        bufferSize - input buffer size
        lineBufferSize - buffer size for line operations. Has effect only if charEncoder is not null.
        charEncoder - charEncoder to be used for encoding HTTP protocol elements. If null simple 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

      • 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 destination WritableByteChannel.
        Specified by:
        flush in interface SessionOutputBuffer
        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 interface SessionOutputBuffer
        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 interface SessionOutputBuffer
        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 interface SessionOutputBuffer
        Parameters:
        lineBuffer - the source buffer.
        Throws:
        java.nio.charset.CharacterCodingException