InputBuffer (Apache Tomcat 9.0.83 API Documentation)
Description: declaration: package: org.apache.catalina.connector, class: InputBuffer

Package org.apache.catalina.connector

# Class InputBuffer

java.lang.Object
java.io.Reader
org.apache.catalina.connector.InputBuffer

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `Readable`, `ByteChunk.ByteInputChannel`, `ApplicationBufferHandler`

public class InputBuffer extends 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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final int`
  `BYTE_STATE`
  `final int`
  `CHAR_STATE`
  `protected B2CConverter`
  `conv`
  Current byte to char converter.
  `static final int`
  `DEFAULT_BUFFER_SIZE`
  `final int`
  `INITIAL_STATE`
  `protected static final StringManager`
  `sm`
  The string manager for this package.

  ### Fields inherited from class java.io.Reader

  `lock`

  ### Fields inherited from interface org.apache.tomcat.util.net.ApplicationBufferHandler

  `EMPTY, EMPTY_BUFFER`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InputBuffer()`
  Default constructor.
  `InputBuffer(int size)`
  Alternate constructor which allows specifying the initial buffer size.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `available()`
  `void`
  `checkConverter()`
  `void`
  `close()`
  Close the input buffer.
  `void`
  `expand(int size)`
  `ByteBuffer`
  `getByteBuffer()`
  `boolean`
  `isFinished()`
  `boolean`
  `isReady()`
  `void`
  `mark(int readAheadLimit)`
  `boolean`
  `markSupported()`
  `int`
  `read()`
  `int`
  `read(byte[] b, int off, int len)`
  `int`
  `read(char[] cbuf)`
  `int`
  `read(char[] cbuf, int off, int len)`
  `int`
  `read(ByteBuffer to)`
  Transfers bytes from the buffer to the specified ByteBuffer.
  `int`
  `readByte()`
  `boolean`
  `ready()`
  `int`
  `realReadBytes()`
  Reads new bytes in the byte chunk.
  `int`
  `realReadChars()`
  `void`
  `recycle()`
  Recycle the output buffer.
  `void`
  `reset()`
  `void`
  `setByteBuffer(ByteBuffer buffer)`
  `void`
  `setReadListener(ReadListener listener)`
  `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 Details

  - ### sm

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

  - ### DEFAULT_BUFFER_SIZE

    public static final int DEFAULT_BUFFER_SIZE
    See Also:
      - Constant Field Values

  - ### INITIAL_STATE

    public final int INITIAL_STATE
    See Also:
      - Constant Field Values

  - ### CHAR_STATE

    public final int CHAR_STATE
    See Also:
      - Constant Field Values

  - ### BYTE_STATE

    public final int BYTE_STATE
    See Also:
      - Constant Field Values

  - ### conv

    protected B2CConverter conv
    Current byte to char converter.

- ## Constructor Details

  - ### 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 Details

  - ### 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 IOException
    Close the input buffer.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Specified by:
      `close` in class `Reader`
    Throws:
      `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 IOException
    Reads new bytes in the byte chunk.
    Specified by:
      `realReadBytes` in interface `ByteChunk.ByteInputChannel`
    Returns:
      The number of bytes read
    Throws:
      `IOException` - An underlying IOException occurred

  - ### readByte

    public int readByte() throws IOException
    Throws:
      `IOException`

  - ### read

    public int read(byte[] b, int off, int len) throws IOException
    Throws:
      `IOException`

  - ### read

    public int read(ByteBuffer to) throws 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:
      `IOException` - if an input or output exception has occurred

  - ### realReadChars

    public int realReadChars() throws IOException
    Throws:
      `IOException`

  - ### read

    public int read() throws IOException
    Overrides:
      `read` in class `Reader`
    Throws:
      `IOException`

  - ### read

    public int read(char[] cbuf) throws IOException
    Overrides:
      `read` in class `Reader`
    Throws:
      `IOException`

  - ### read

    public int read(char[] cbuf, int off, int len) throws IOException
    Specified by:
      `read` in class `Reader`
    Throws:
      `IOException`

  - ### skip

    public long skip(long n) throws IOException
    Overrides:
      `skip` in class `Reader`
    Throws:
      `IOException`

  - ### ready

    public boolean ready() throws IOException
    Overrides:
      `ready` in class `Reader`
    Throws:
      `IOException`

  - ### markSupported

    public boolean markSupported()
    Overrides:
      `markSupported` in class `Reader`

  - ### mark

    public void mark(int readAheadLimit) throws IOException
    Overrides:
      `mark` in class `Reader`
    Throws:
      `IOException`

  - ### reset

    public void reset() throws IOException
    Overrides:
      `reset` in class `Reader`
    Throws:
      `IOException`

  - ### checkConverter

    public void checkConverter() throws IOException
    Throws:
      `IOException`

  - ### setByteBuffer

    public void setByteBuffer(ByteBuffer buffer)
    Specified by:
      `setByteBuffer` in interface `ApplicationBufferHandler`

  - ### getByteBuffer

    public ByteBuffer getByteBuffer()
    Specified by:
      `getByteBuffer` in interface `ApplicationBufferHandler`

  - ### expand

    public void expand(int size)
    Specified by:
      `expand` in interface `ApplicationBufferHandler`