Class InputBuffer

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Readable, org.glassfish.grizzly.http.util.ByteChunk.ByteInputChannel, org.glassfish.grizzly.http.util.CharChunk.CharInputChannel, org.glassfish.grizzly.http.util.CharChunk.CharOutputChannel

    public class InputBuffer
    extends Reader
    implements org.glassfish.grizzly.http.util.ByteChunk.ByteInputChannel, org.glassfish.grizzly.http.util.CharChunk.CharInputChannel, org.glassfish.grizzly.http.util.CharChunk.CharOutputChannel
    The buffer used by Tomcat request. This is a derivative of the Tomcat 3.3 OutputBuffer, adapted to handle input instead of output. This allows complete recycling of the facade objects (the ServletInputStream and the BufferedReader).
    Author:
    Remy Maucherat
    • Constructor Detail

      • InputBuffer

        public InputBuffer()
        Default constructor. Allocate the buffer with the default buffer size.
      • InputBuffer

        public InputBuffer​(int size)
        Alternate constructor which does nothing
        Parameters:
        size - Buffer size to use
    • Method Detail

      • setRequest

        public void setRequest​(org.glassfish.grizzly.http.server.Request grizzlyRequest)
        Associated Grizzly request.
        Parameters:
        grizzlyRequest - Associated Grizzly request
      • setRequest

        public void setRequest​(Request request)
      • getRequest

        public org.glassfish.grizzly.http.server.Request getRequest()
        Get associated Grizzly request.
        Returns:
        the associated Grizzly request
      • recycle

        public void recycle()
        Recycle the output buffer.
      • realReadBytes

        public int realReadBytes​(byte[] cbuf,
                                 int off,
                                 int len)
                          throws IOException
        Reads new bytes in the byte chunk.
        Specified by:
        realReadBytes in interface org.glassfish.grizzly.http.util.ByteChunk.ByteInputChannel
        Parameters:
        cbuf - Byte buffer to be written to the response
        off - Offset
        len - Length
        Throws:
        IOException - An underlying IOException occurred
      • isFinished

        public boolean isFinished()
      • isReady

        public boolean isReady()
      • setReadListener

        public void setReadListener​(jakarta.servlet.ReadListener readListener)
      • realWriteChars

        public void realWriteChars​(char[] c,
                                   int off,
                                   int len)
                            throws IOException
        Since the converter will use append, it is possible to get chars to be removed from the buffer for "writing". Since the chars have already been read before, they are ignored. If a mark was set, then the mark is lost.
        Specified by:
        realWriteChars in interface org.glassfish.grizzly.http.util.CharChunk.CharOutputChannel
        Throws:
        IOException
      • setEncoding

        public void setEncoding​(String encoding)
      • realReadChars

        public int realReadChars​(char[] cbuf,
                                 int off,
                                 int len)
                          throws IOException
        Specified by:
        realReadChars in interface org.glassfish.grizzly.http.util.CharChunk.CharInputChannel
        Throws:
        IOException