Package org.springframework.mock.web
Class DelegatingServletOutputStream
- java.lang.Object
- java.io.OutputStream
- javax.servlet.ServletOutputStream
- org.springframework.mock.web.DelegatingServletOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class DelegatingServletOutputStream extends ServletOutputStream
Delegating implementation ofServletOutputStream.Used by
MockHttpServletResponse; typically not directly used for testing application controllers.- Since:
- 1.0.2
- Author:
- Juergen Hoeller
- See Also:
MockHttpServletResponse
Constructor Summary
Constructors Constructor Description DelegatingServletOutputStream(OutputStream targetStream)Create a DelegatingServletOutputStream for the given target stream.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()OutputStreamgetTargetStream()Return the underlying target stream (nevernull).booleanisReady()This method can be used to determine if data can be written without blocking.voidsetWriteListener(WriteListener writeListener)Instructs theServletOutputStreamto invoke the providedWriteListenerwhen it is possible to writevoidwrite(int b)Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
Constructor Detail
DelegatingServletOutputStream
public DelegatingServletOutputStream(OutputStream targetStream)
Create a DelegatingServletOutputStream for the given target stream.- Parameters:
targetStream- the target stream (nevernull)
Method Detail
getTargetStream
public final OutputStream getTargetStream()
Return the underlying target stream (nevernull).
write
public void write(int b) throws IOException
- Specified by:
writein classOutputStream- Throws:
IOException
flush
public void flush() throws IOException
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
close
public void close() throws IOException
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
isReady
public boolean isReady()
Description copied from class:javax.servlet.ServletOutputStreamThis method can be used to determine if data can be written without blocking.- Specified by:
isReadyin classServletOutputStream- Returns:
trueif a write to thisServletOutputStreamwill succeed, otherwise returnsfalse.
setWriteListener
public void setWriteListener(WriteListener writeListener)
Description copied from class:javax.servlet.ServletOutputStreamInstructs theServletOutputStreamto invoke the providedWriteListenerwhen it is possible to write- Specified by:
setWriteListenerin classServletOutputStream- Parameters:
writeListener- theWriteListenerthat should be notified when it's possible to write