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 void
close()
void
flush()
OutputStream
getTargetStream()
Return the underlying target stream (nevernull
).boolean
isReady()
This method can be used to determine if data can be written without blocking.void
setWriteListener(WriteListener writeListener)
Instructs theServletOutputStream
to invoke the providedWriteListener
when it is possible to writevoid
write(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:
write
in classOutputStream
- Throws:
IOException
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
isReady
public boolean isReady()
Description copied from class:javax.servlet.ServletOutputStream
This method can be used to determine if data can be written without blocking.- Specified by:
isReady
in classServletOutputStream
- Returns:
true
if a write to thisServletOutputStream
will succeed, otherwise returnsfalse
.
setWriteListener
public void setWriteListener(WriteListener writeListener)
Description copied from class:javax.servlet.ServletOutputStream
Instructs theServletOutputStream
to invoke the providedWriteListener
when it is possible to write- Specified by:
setWriteListener
in classServletOutputStream
- Parameters:
writeListener
- theWriteListener
that should be notified when it's possible to write