Package org.springframework.mock.web
Class DelegatingServletInputStream
- java.lang.Object
- java.io.InputStream
- javax.servlet.ServletInputStream
- org.springframework.mock.web.DelegatingServletInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class DelegatingServletInputStream extends ServletInputStream
Delegating implementation ofServletInputStream
.Used by
MockHttpServletRequest
; typically not directly used for testing application controllers.- Since:
- 1.0.2
- Author:
- Juergen Hoeller
- See Also:
MockHttpServletRequest
Constructor Summary
Constructors Constructor Description DelegatingServletInputStream(InputStream sourceStream)
Create a DelegatingServletInputStream for the given source stream.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
InputStream
getSourceStream()
Return the underlying source stream (nevernull
).boolean
isFinished()
Returns true when all the data from the stream has been read else it returns false.boolean
isReady()
Returns true if data can be read without blocking else returns false.int
read()
void
setReadListener(ReadListener readListener)
Instructs theServletInputStream
to invoke the providedReadListener
when it is possible to readMethods inherited from class javax.servlet.ServletInputStream
readLine
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
Constructor Detail
DelegatingServletInputStream
public DelegatingServletInputStream(InputStream sourceStream)
Create a DelegatingServletInputStream for the given source stream.- Parameters:
sourceStream
- the source stream (nevernull
)
Method Detail
getSourceStream
public final InputStream getSourceStream()
Return the underlying source stream (nevernull
).
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
isFinished
public boolean isFinished()
Description copied from class:javax.servlet.ServletInputStream
Returns true when all the data from the stream has been read else it returns false.- Specified by:
isFinished
in classServletInputStream
- Returns:
true
when all data for this particular request has been read, otherwise returnsfalse
.
isReady
public boolean isReady()
Description copied from class:javax.servlet.ServletInputStream
Returns true if data can be read without blocking else returns false.- Specified by:
isReady
in classServletInputStream
- Returns:
true
if data can be obtained without blocking, otherwise returnsfalse
.
setReadListener
public void setReadListener(ReadListener readListener)
Description copied from class:javax.servlet.ServletInputStream
Instructs theServletInputStream
to invoke the providedReadListener
when it is possible to read- Specified by:
setReadListener
in classServletInputStream
- Parameters:
readListener
- theReadListener
that should be notified when it's possible to read.