Class InputBuffer

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable, ByteChunk.ByteInputChannel, ApplicationBufferHandler

    public class InputBuffer
    extends java.io.Reader
    implements ByteChunk.ByteInputChannel, ApplicationBufferHandler
    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 allows specifying the initial buffer size.
        Parameters:
        size - Buffer size to use
    • Method Detail

      • setRequest

        public void setRequest​(Request coyoteRequest)
        Associated Coyote request.
        Parameters:
        coyoteRequest - Associated Coyote request
      • recycle

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

        public void close()
                   throws java.io.IOException
        Close the input buffer.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Reader
        Throws:
        java.io.IOException - An underlying IOException occurred
      • available

        public int available()
      • setReadListener

        public void setReadListener​(ReadListener listener)
      • isFinished

        public boolean isFinished()
      • isReady

        public boolean isReady()
      • realReadBytes

        public int realReadBytes()
                          throws java.io.IOException
        Reads new bytes in the byte chunk.
        Specified by:
        realReadBytes in interface ByteChunk.ByteInputChannel
        Returns:
        The number of bytes read
        Throws:
        java.io.IOException - An underlying IOException occurred
      • readByte

        public int readByte()
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public int read​(java.nio.ByteBuffer to)
                 throws java.io.IOException
        Transfers bytes from the buffer to the specified ByteBuffer. After the operation the position of the ByteBuffer will be returned to the one before the operation, the limit will be the position incremented by the number of the transferred bytes.
        Parameters:
        to - the ByteBuffer into which bytes are to be written.
        Returns:
        an integer specifying the actual number of bytes read, or -1 if the end of the stream is reached
        Throws:
        java.io.IOException - if an input or output exception has occurred
      • realReadChars

        public int realReadChars()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Overrides:
        read in class java.io.Reader
        Throws:
        java.io.IOException
      • read

        public int read​(char[] cbuf)
                 throws java.io.IOException
        Overrides:
        read in class java.io.Reader
        Throws:
        java.io.IOException
      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Specified by:
        read in class java.io.Reader
        Throws:
        java.io.IOException
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.Reader
        Throws:
        java.io.IOException
      • ready

        public boolean ready()
                      throws java.io.IOException
        Overrides:
        ready in class java.io.Reader
        Throws:
        java.io.IOException
      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.Reader
      • mark

        public void mark​(int readAheadLimit)
                  throws java.io.IOException
        Overrides:
        mark in class java.io.Reader
        Throws:
        java.io.IOException
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.Reader
        Throws:
        java.io.IOException
      • checkConverter

        public void checkConverter()
                            throws java.io.IOException
        Throws:
        java.io.IOException