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
Modifier and TypeFieldDescriptionfinal int
final int
protected B2CConverter
Current byte to char converter.static final int
final int
protected static final StringManager
The string manager for this package.Fields inherited from interface org.apache.tomcat.util.net.ApplicationBufferHandler
EMPTY, EMPTY_BUFFER
-
Constructor Summary
ConstructorDescriptionInputBuffer
(int size, Request coyoteRequest) Alternate constructor which allows specifying the initial buffer size.InputBuffer
(Request coyoteRequest) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
void
void
close()
void
expand
(int size) Expand the byte buffer to at least the given size.boolean
boolean
isReady()
void
mark
(int readAheadLimit) boolean
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
Read new bytes.int
void
recycle()
Recycle the output buffer.void
reset()
void
setByteBuffer
(ByteBuffer buffer) Set the byte buffer.void
setReadListener
(ReadListener listener) long
skip
(long n) Methods inherited from class java.io.Reader
nullReader, read, transferTo
-
Field Details
-
sm
The string manager for this package. -
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
INITIAL_STATE
public final int INITIAL_STATE- See Also:
-
CHAR_STATE
public final int CHAR_STATE- See Also:
-
BYTE_STATE
public final int BYTE_STATE- See Also:
-
conv
Current byte to char converter.
-
-
Constructor Details
-
InputBuffer
Default constructor. Allocate the buffer with the default buffer size.- Parameters:
coyoteRequest
- The associated Coyote request
-
InputBuffer
Alternate constructor which allows specifying the initial buffer size.- Parameters:
size
- Buffer size to usecoyoteRequest
- The associated Coyote request
-
-
Method Details
-
recycle
public void recycle()Recycle the output buffer. -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
available
public int available() -
setReadListener
-
isFinished
public boolean isFinished() -
isReady
public boolean isReady() -
realReadBytes
Description copied from interface:ByteChunk.ByteInputChannel
Read new bytes.- Specified by:
realReadBytes
in interfaceByteChunk.ByteInputChannel
- Returns:
- The number of bytes read
- Throws:
IOException
- If an I/O error occurs during reading
-
readByte
- Throws:
IOException
-
read
- Throws:
IOException
-
read
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
- Throws:
IOException
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Specified by:
read
in classReader
- Throws:
IOException
-
skip
- Overrides:
skip
in classReader
- Throws:
IOException
-
ready
- Overrides:
ready
in classReader
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classReader
-
mark
- Overrides:
mark
in classReader
- Throws:
IOException
-
reset
- Overrides:
reset
in classReader
- Throws:
IOException
-
checkConverter
- Throws:
IOException
-
setByteBuffer
Description copied from interface:ApplicationBufferHandler
Set the byte buffer.- Specified by:
setByteBuffer
in interfaceApplicationBufferHandler
- Parameters:
buffer
- the byte buffer
-
getByteBuffer
- Specified by:
getByteBuffer
in interfaceApplicationBufferHandler
- Returns:
- the byte buffer
-
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 interfaceApplicationBufferHandler
- Parameters:
size
- the desired size
-