Package org.apache.catalina.connector
Class InputBuffer
- java.lang.Object
-
- java.io.Reader
-
- org.apache.catalina.connector.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).
-
-
Field Summary
Fields Modifier and Type Field Description intBYTE_STATEintCHAR_STATEprotected B2CConverterconvCurrent byte to char converter.static intDEFAULT_BUFFER_SIZEintINITIAL_STATEprotected static StringManagersmThe string manager for this package.-
Fields inherited from interface org.apache.tomcat.util.net.ApplicationBufferHandler
EMPTY
-
-
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 intavailable()voidcheckConverter()voidclose()voidexpand(int size)Expand the byte buffer to at least the given size.java.nio.ByteBuffergetByteBuffer()booleanisFinished()booleanisReady()voidmark(int readAheadLimit)booleanmarkSupported()intread()intread(byte[] b, int off, int len)intread(char[] cbuf)intread(char[] cbuf, int off, int len)intread(java.nio.ByteBuffer to)Transfers bytes from the buffer to the specified ByteBuffer.intreadByte()booleanready()intrealReadBytes()Read new bytes.intrealReadChars()voidrecycle()Recycle the output buffer.voidreset()voidsetByteBuffer(java.nio.ByteBuffer buffer)Set the byte buffer.voidsetReadListener(ReadListener listener)voidsetRequest(Request coyoteRequest)Associated Coyote request.longskip(long n)
-
-
-
Field Detail
-
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.
-
-
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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader- Throws:
java.io.IOException
-
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.IOExceptionDescription copied from interface:ByteChunk.ByteInputChannelRead new bytes.- Specified by:
realReadBytesin interfaceByteChunk.ByteInputChannel- Returns:
- The number of bytes read
- Throws:
java.io.IOException- If an I/O error occurs during reading
-
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.IOExceptionTransfers 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:
readin classjava.io.Reader- Throws:
java.io.IOException
-
read
public int read(char[] cbuf) throws java.io.IOException- Overrides:
readin classjava.io.Reader- Throws:
java.io.IOException
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException- Specified by:
readin classjava.io.Reader- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.Reader- Throws:
java.io.IOException
-
ready
public boolean ready() throws java.io.IOException- Overrides:
readyin classjava.io.Reader- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.Reader
-
mark
public void mark(int readAheadLimit) throws java.io.IOException- Overrides:
markin classjava.io.Reader- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.Reader- Throws:
java.io.IOException
-
checkConverter
public void checkConverter() throws java.io.IOException- Throws:
java.io.IOException
-
setByteBuffer
public void setByteBuffer(java.nio.ByteBuffer buffer)
Description copied from interface:ApplicationBufferHandlerSet the byte buffer.- Specified by:
setByteBufferin interfaceApplicationBufferHandler- Parameters:
buffer- the byte buffer
-
getByteBuffer
public java.nio.ByteBuffer getByteBuffer()
- Specified by:
getByteBufferin interfaceApplicationBufferHandler- Returns:
- the byte buffer
-
expand
public void expand(int size)
Description copied from interface:ApplicationBufferHandlerExpand the byte buffer to at least the given size. Some implementations may not implement this.- Specified by:
expandin interfaceApplicationBufferHandler- Parameters:
size- the desired size
-
-