Class InputBuffer

    • Constructor Summary

      Constructors 
      Constructor Description
      InputBuffer()
      Default constructor.
      InputBuffer​(int size)
      Alternate constructor which allows specifying the initial buffer size.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Returns the number of bytes or characters available in the buffer.
      void checkConverter()
      Ensures a byte-to-char converter is available, initializing one if necessary.
      void close()  
      void expand​(int size)
      Expand the byte buffer to at least the given size.
      java.nio.ByteBuffer getByteBuffer()
      Obtain the ByteBuffer this channel is targeting.
      boolean isFinished()
      Checks if all data has been read from the input buffer.
      boolean isReady()
      Checks if the input buffer is ready for reading.
      void mark​(int readAheadLimit)  
      boolean markSupported()  
      int read()  
      int read​(byte[] b, int off, int len)
      Reads bytes into the specified array.
      int read​(char[] cbuf)  
      int read​(char[] cbuf, int off, int len)  
      int read​(java.nio.ByteBuffer to)
      Transfers bytes from the buffer to the specified ByteBuffer.
      int readByte()
      Reads a single byte from the buffer.
      boolean ready()  
      int realReadBytes()
      Read new bytes.
      int realReadChars()
      Reads characters from the byte buffer using the current converter.
      void recycle()
      Recycle the output buffer.
      void reset()  
      void setByteBuffer​(java.nio.ByteBuffer buffer)
      Set the byte buffer.
      void setReadListener​(ReadListener listener)
      Sets the read listener for async request processing.
      void setRequest​(Request coyoteRequest)
      Associated Coyote request.
      long skip​(long n)  
      • Methods inherited from class java.io.Reader

        nullReader, read, transferTo
      • Methods inherited from class java.lang.Object

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

      • sm

        protected static final StringManager sm
        The string manager for this package.
      • DEFAULT_BUFFER_SIZE

        public static final int DEFAULT_BUFFER_SIZE
        Default buffer size in bytes.
        See Also:
        Constant Field Values
      • INITIAL_STATE

        public final int INITIAL_STATE
        Initial state before any read operation.
        See Also:
        Constant Field Values
      • CHAR_STATE

        public final int CHAR_STATE
        State when reading character data.
        See Also:
        Constant Field Values
      • conv

        protected B2CConverter conv
        Current byte to char converter.
    • 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
        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
      • available

        public int available()
        Returns the number of bytes or characters available in the buffer.
        Returns:
        the number of bytes or characters available
      • setReadListener

        public void setReadListener​(ReadListener listener)
        Sets the read listener for async request processing.
        Parameters:
        listener - the read listener to set
      • isFinished

        public boolean isFinished()
        Checks if all data has been read from the input buffer.
        Returns:
        true if all data has been read
      • isReady

        public boolean isReady()
        Checks if the input buffer is ready for reading.
        Returns:
        true if the buffer is ready
      • readByte

        public int readByte()
                     throws java.io.IOException
        Reads a single byte from the buffer.
        Returns:
        the byte read, or -1 if end of stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Reads bytes into the specified array.
        Parameters:
        b - the buffer into which the data is read
        off - the start offset in the destination array
        len - the maximum number of bytes to read
        Returns:
        the number of bytes read, or -1 if end of stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • 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
        Reads characters from the byte buffer using the current converter.
        Returns:
        the number of characters read, or -1 if end of stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • 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
        Ensures a byte-to-char converter is available, initializing one if necessary.
        Throws:
        java.io.IOException - if an I/O error occurs
      • expand

        public void expand​(int size)
        Description copied from interface: ApplicationBufferHandler
        Expand the byte buffer to at least the given size. Some implementations may not implement this.
        Specified by:
        expand in interface ApplicationBufferHandler
        Parameters:
        size - the desired size