javax.servlet
类 ServletResponseWrapper

java.lang.Object
  继承者 javax.servlet.ServletResponseWrapper
所有已实现的接口:
ServletResponse
直接已知子类:
HttpServletResponseWrapper, ServletResponseHttpWrapper

public class ServletResponseWrapper
extends Object
implements ServletResponse

Provides a convenient implementation of the ServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.

从以下版本开始:
Servlet 2.3
作者:
Various
另请参见:
ServletResponse

构造方法摘要
ServletResponseWrapper(ServletResponse response)
          Creates a ServletResponse adaptor wrapping the given response object.
 
方法摘要
 void flushBuffer()
          The default behavior of this method is to call flushBuffer() on the wrapped response object.
 int getBufferSize()
          The default behavior of this method is to return getBufferSize() on the wrapped response object.
 String getCharacterEncoding()
          The default behavior of this method is to return getCharacterEncoding() on the wrapped response object.
 String getContentType()
          The default behavior of this method is to return getContentType() on the wrapped response object.
 Locale getLocale()
          The default behavior of this method is to return getLocale() on the wrapped response object.
 ServletOutputStream getOutputStream()
          The default behavior of this method is to return getOutputStream() on the wrapped response object.
 ServletResponse getResponse()
          Return the wrapped ServletResponse object.
 PrintWriter getWriter()
          The default behavior of this method is to return getWriter() on the wrapped response object.
 boolean isCommitted()
          The default behavior of this method is to return isCommitted() on the wrapped response object.
 boolean isWrapperFor(Class wrappedType)
          Checks (recursively) if this ServletResponseWrapper wraps a ServletResponse of the given class type.
 boolean isWrapperFor(ServletResponse wrapped)
          Checks (recursively) if this ServletResponseWrapper wraps the given ServletResponse instance.
 void reset()
          The default behavior of this method is to call reset() on the wrapped response object.
 void resetBuffer()
          The default behavior of this method is to call resetBuffer() on the wrapped response object.
 void setBufferSize(int size)
          The default behavior of this method is to call setBufferSize(int size) on the wrapped response object.
 void setCharacterEncoding(String charset)
          The default behavior of this method is to call setCharacterEncoding(String charset) on the wrapped response object.
 void setContentLength(int len)
          The default behavior of this method is to call setContentLength(int len) on the wrapped response object.
 void setContentType(String type)
          The default behavior of this method is to call setContentType(String type) on the wrapped response object.
 void setLocale(Locale loc)
          The default behavior of this method is to call setLocale(Locale loc) on the wrapped response object.
 void setResponse(ServletResponse response)
          Sets the response being wrapped.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

ServletResponseWrapper

public ServletResponseWrapper(ServletResponse response)
Creates a ServletResponse adaptor wrapping the given response object.

抛出:
IllegalArgumentException - if the response is null.
方法详细信息

getResponse

public ServletResponse getResponse()
Return the wrapped ServletResponse object.


setResponse

public void setResponse(ServletResponse response)
Sets the response being wrapped.

抛出:
IllegalArgumentException - if the response is null.

setCharacterEncoding

public void setCharacterEncoding(String charset)
The default behavior of this method is to call setCharacterEncoding(String charset) on the wrapped response object.

指定者:
接口 ServletResponse 中的 setCharacterEncoding
参数:
charset - a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
从以下版本开始:
Servlet 2.4
另请参见:
#setLocale

getCharacterEncoding

public String getCharacterEncoding()
The default behavior of this method is to return getCharacterEncoding() on the wrapped response object.

指定者:
接口 ServletResponse 中的 getCharacterEncoding
返回:
a String specifying the name of the character encoding, for example, UTF-8

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws IOException
The default behavior of this method is to return getOutputStream() on the wrapped response object.

指定者:
接口 ServletResponse 中的 getOutputStream
返回:
a ServletOutputStream for writing binary data
抛出:
IOException - if an input or output exception occurred
另请参见:
ServletResponse.getWriter()

getWriter

public PrintWriter getWriter()
                      throws IOException
The default behavior of this method is to return getWriter() on the wrapped response object.

指定者:
接口 ServletResponse 中的 getWriter
返回:
a PrintWriter object that can return character data to the client
抛出:
IOException - if an input or output exception occurred
另请参见:
ServletResponse.getOutputStream(), ServletResponse.setCharacterEncoding(java.lang.String)

setContentLength

public void setContentLength(int len)
The default behavior of this method is to call setContentLength(int len) on the wrapped response object.

指定者:
接口 ServletResponse 中的 setContentLength
参数:
len - an integer specifying the length of the content being returned to the client; sets the Content-Length header

setContentType

public void setContentType(String type)
The default behavior of this method is to call setContentType(String type) on the wrapped response object.

指定者:
接口 ServletResponse 中的 setContentType
参数:
type - a String specifying the MIME type of the content
另请参见:
ServletResponse.setLocale(java.util.Locale), ServletResponse.setCharacterEncoding(java.lang.String), ServletResponse.getOutputStream(), ServletResponse.getWriter()

getContentType

public String getContentType()
The default behavior of this method is to return getContentType() on the wrapped response object.

指定者:
接口 ServletResponse 中的 getContentType
返回:
a String specifying the content type, for example, text/html; charset=UTF-8, or null
从以下版本开始:
Servlet 2.4

setBufferSize

public void setBufferSize(int size)
The default behavior of this method is to call setBufferSize(int size) on the wrapped response object.

指定者:
接口 ServletResponse 中的 setBufferSize
参数:
size - the preferred buffer size
另请参见:
ServletResponse.getBufferSize(), ServletResponse.flushBuffer(), ServletResponse.isCommitted(), ServletResponse.reset()

getBufferSize

public int getBufferSize()
The default behavior of this method is to return getBufferSize() on the wrapped response object.

指定者:
接口 ServletResponse 中的 getBufferSize
返回:
the actual buffer size used
另请参见:
ServletResponse.setBufferSize(int), ServletResponse.flushBuffer(), ServletResponse.isCommitted(), ServletResponse.reset()

flushBuffer

public void flushBuffer()
                 throws IOException
The default behavior of this method is to call flushBuffer() on the wrapped response object.

指定者:
接口 ServletResponse 中的 flushBuffer
抛出:
IOException
另请参见:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.isCommitted(), ServletResponse.reset()

isCommitted

public boolean isCommitted()
The default behavior of this method is to return isCommitted() on the wrapped response object.

指定者:
接口 ServletResponse 中的 isCommitted
返回:
a boolean indicating if the response has been committed
另请参见:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.flushBuffer(), ServletResponse.reset()

reset

public void reset()
The default behavior of this method is to call reset() on the wrapped response object.

指定者:
接口 ServletResponse 中的 reset
另请参见:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.flushBuffer(), ServletResponse.isCommitted()

resetBuffer

public void resetBuffer()
The default behavior of this method is to call resetBuffer() on the wrapped response object.

指定者:
接口 ServletResponse 中的 resetBuffer
另请参见:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.isCommitted(), ServletResponse.reset()

setLocale

public void setLocale(Locale loc)
The default behavior of this method is to call setLocale(Locale loc) on the wrapped response object.

指定者:
接口 ServletResponse 中的 setLocale
参数:
loc - the locale of the response
另请参见:
ServletResponse.getLocale(), ServletResponse.setContentType(java.lang.String), ServletResponse.setCharacterEncoding(java.lang.String)

getLocale

public Locale getLocale()
The default behavior of this method is to return getLocale() on the wrapped response object.

指定者:
接口 ServletResponse 中的 getLocale
另请参见:
ServletResponse.setLocale(java.util.Locale)

isWrapperFor

public boolean isWrapperFor(ServletResponse wrapped)
Checks (recursively) if this ServletResponseWrapper wraps the given ServletResponse instance.

参数:
wrapped - the ServletResponse instance to search for
返回:
true if this ServletResponseWrapper wraps the given ServletResponse instance, false otherwise
从以下版本开始:
Servlet 3.0

isWrapperFor

public boolean isWrapperFor(Class wrappedType)
Checks (recursively) if this ServletResponseWrapper wraps a ServletResponse of the given class type.

参数:
wrappedType - the ServletResponse class type to search for
返回:
true if this ServletResponseWrapper wraps a ServletResponse of the given class type, false otherwise
抛出:
IllegalArgumentException - if the given class does not implement ServletResponse
从以下版本开始:
Servlet 3.0


Copyright © 2013. All Rights Reserved.