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 SummaryFieldsModifier and TypeFieldDescriptionfinal intfinal intprotected B2CConverterCurrent byte to char converter.static final intfinal intprotected static final StringManagerThe string manager for this package.Fields inherited from interface org.apache.tomcat.util.net.ApplicationBufferHandlerEMPTY, EMPTY_BUFFER
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor.InputBuffer(int size) Alternate constructor which allows specifying the initial buffer size.
- 
Method SummaryModifier and TypeMethodDescriptionintvoidvoidclose()Close the input buffer.voidexpand(int size) booleanbooleanisReady()voidmark(int readAheadLimit) booleanintread()intread(byte[] b, int off, int len) intread(char[] cbuf) intread(char[] cbuf, int off, int len) intread(ByteBuffer to) Transfers bytes from the buffer to the specified ByteBuffer.intreadByte()booleanready()intReads new bytes in the byte chunk.intvoidrecycle()Recycle the output buffer.voidreset()voidsetByteBuffer(ByteBuffer buffer) voidsetReadListener(ReadListener listener) voidsetRequest(Request coyoteRequest) Associated Coyote request.longskip(long n) Methods inherited from class java.io.ReadernullReader, read, transferTo
- 
Field Details- 
smThe string manager for this package.
- 
DEFAULT_BUFFER_SIZEpublic static final int DEFAULT_BUFFER_SIZE- See Also:
 
- 
INITIAL_STATEpublic final int INITIAL_STATE- See Also:
 
- 
CHAR_STATEpublic final int CHAR_STATE- See Also:
 
- 
BYTE_STATEpublic final int BYTE_STATE- See Also:
 
- 
convCurrent byte to char converter.
 
- 
- 
Constructor Details- 
InputBufferpublic InputBuffer()Default constructor. Allocate the buffer with the default buffer size.
- 
InputBufferpublic InputBuffer(int size) Alternate constructor which allows specifying the initial buffer size.- Parameters:
- size- Buffer size to use
 
 
- 
- 
Method Details- 
setRequestAssociated Coyote request.- Parameters:
- coyoteRequest- Associated Coyote request
 
- 
recyclepublic void recycle()Recycle the output buffer.
- 
closeClose the input buffer.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- Reader
- Throws:
- IOException- An underlying IOException occurred
 
- 
availablepublic int available()
- 
setReadListener
- 
isFinishedpublic boolean isFinished()
- 
isReadypublic boolean isReady()
- 
realReadBytesReads new bytes in the byte chunk.- Specified by:
- realReadBytesin interface- ByteChunk.ByteInputChannel
- Returns:
- The number of bytes read
- Throws:
- IOException- An underlying IOException occurred
 
- 
readByte- Throws:
- IOException
 
- 
read- Throws:
- IOException
 
- 
readTransfers 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:
- readin class- Reader
- Throws:
- IOException
 
- 
read- Overrides:
- readin class- Reader
- Throws:
- IOException
 
- 
read- Specified by:
- readin class- Reader
- Throws:
- IOException
 
- 
skip- Overrides:
- skipin class- Reader
- Throws:
- IOException
 
- 
ready- Overrides:
- readyin class- Reader
- Throws:
- IOException
 
- 
markSupportedpublic boolean markSupported()- Overrides:
- markSupportedin class- Reader
 
- 
mark- Overrides:
- markin class- Reader
- Throws:
- IOException
 
- 
reset- Overrides:
- resetin class- Reader
- Throws:
- IOException
 
- 
checkConverter- Throws:
- IOException
 
- 
setByteBuffer- Specified by:
- setByteBufferin interface- ApplicationBufferHandler
 
- 
getByteBuffer- Specified by:
- getByteBufferin interface- ApplicationBufferHandler
 
- 
expandpublic void expand(int size) - Specified by:
- expandin interface- ApplicationBufferHandler
 
 
-