Package org.apache.catalina.connector
Class InputBuffer
- java.lang.Object
-
- java.io.Reader
-
- org.apache.catalina.connector.InputBuffer
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
,org.glassfish.grizzly.http.util.ByteChunk.ByteInputChannel
,org.glassfish.grizzly.http.util.CharChunk.CharInputChannel
,org.glassfish.grizzly.http.util.CharChunk.CharOutputChannel
public class InputBuffer extends Reader implements org.glassfish.grizzly.http.util.ByteChunk.ByteInputChannel, org.glassfish.grizzly.http.util.CharChunk.CharInputChannel, org.glassfish.grizzly.http.util.CharChunk.CharOutputChannel
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 static int
DEFAULT_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description InputBuffer()
Default constructor.InputBuffer(int size)
Alternate constructor which does nothing
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
checkConverter()
void
close()
Close the input buffer.org.glassfish.grizzly.http.server.Request
getRequest()
Get associated Grizzly request.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
readByte()
boolean
ready()
int
realReadBytes(byte[] cbuf, int off, int len)
Reads new bytes in the byte chunk.int
realReadChars(char[] cbuf, int off, int len)
void
realWriteChars(char[] c, int off, int len)
Since the converter will use append, it is possible to get chars to be removed from the buffer for "writing".void
recycle()
Recycle the output buffer.void
reset()
void
setEncoding(String encoding)
void
setReadListener(jakarta.servlet.ReadListener readListener)
void
setRequest(Request request)
void
setRequest(org.glassfish.grizzly.http.server.Request grizzlyRequest)
Associated Grizzly request.long
skip(long n)
-
Methods inherited from class java.io.Reader
nullReader, read, transferTo
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setRequest
public void setRequest(org.glassfish.grizzly.http.server.Request grizzlyRequest)
Associated Grizzly request.- Parameters:
grizzlyRequest
- Associated Grizzly request
-
setRequest
public void setRequest(Request request)
-
getRequest
public org.glassfish.grizzly.http.server.Request getRequest()
Get associated Grizzly request.- Returns:
- the associated Grizzly request
-
recycle
public void recycle()
Recycle the output buffer.
-
close
public void close() throws IOException
Close the input buffer.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
- An underlying IOException occurred
-
available
public int available() throws IOException
- Throws:
IOException
-
realReadBytes
public int realReadBytes(byte[] cbuf, int off, int len) throws IOException
Reads new bytes in the byte chunk.- Specified by:
realReadBytes
in interfaceorg.glassfish.grizzly.http.util.ByteChunk.ByteInputChannel
- Parameters:
cbuf
- Byte buffer to be written to the responseoff
- Offsetlen
- Length- 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
-
isFinished
public boolean isFinished()
-
isReady
public boolean isReady()
-
setReadListener
public void setReadListener(jakarta.servlet.ReadListener readListener)
-
realWriteChars
public void realWriteChars(char[] c, int off, int len) throws IOException
Since the converter will use append, it is possible to get chars to be removed from the buffer for "writing". Since the chars have already been read before, they are ignored. If a mark was set, then the mark is lost.- Specified by:
realWriteChars
in interfaceorg.glassfish.grizzly.http.util.CharChunk.CharOutputChannel
- Throws:
IOException
-
setEncoding
public void setEncoding(String encoding)
-
realReadChars
public int realReadChars(char[] cbuf, int off, int len) throws IOException
- Specified by:
realReadChars
in interfaceorg.glassfish.grizzly.http.util.CharChunk.CharInputChannel
- Throws:
IOException
-
read
public int read() throws IOException
- Overrides:
read
in classReader
- Throws:
IOException
-
read
public int read(char[] cbuf) throws IOException
- Overrides:
read
in classReader
- Throws:
IOException
-
read
public int read(char[] cbuf, int off, int len) throws IOException
- Specified by:
read
in classReader
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classReader
- Throws:
IOException
-
ready
public boolean ready() throws IOException
- Overrides:
ready
in classReader
- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classReader
-
mark
public void mark(int readAheadLimit) throws IOException
- Overrides:
mark
in classReader
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classReader
- Throws:
IOException
-
checkConverter
public void checkConverter() throws IOException
- Throws:
IOException
-
-