ServletResponseWrapper (Java EE 5)

Java EE API


javax.servlet Class ServletResponseWrapper

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
All Implemented Interfaces:
ServletResponse
Direct Known Subclasses:
HttpServletResponseWrapper

public class ServletResponseWrapper
extends Object
implements ServletResponse

Implements: ServletResponse

提供 ServletResponse 接口的便捷实现,希望根据 Servlet 适配响应的开发人员可以子类化该接口。此类实现 Wrapper 或 Decorator 模式。默认情况下,方法通过包装的响应对象调用。
英文文档:

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.

Since:
v 2.3
Author:
Various
See Also:
ServletResponse

Constructor Summary
 
Method Summary
 void
 int
 String
 String
 Locale
 ServletOutputStream
 ServletResponse
 PrintWriter
 boolean
 void
 void
 void
 void
 void
 void
 void
 void
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public ServletResponseWrapper(ServletResponse response)
创建包装给定响应对象的 ServletResponse 适配器。
ThrowsIllegalArgumentException: 如果 response 为 null
英文文档:

ServletResponseWrapper

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

Throws:
IllegalArgumentException - if the response is null.

Method Detail

public ServletResponse getResponse()
返回包装的 ServletResponse 对象。
英文文档:

getResponse

public ServletResponse getResponse()
Return the wrapped ServletResponse object.


public void setResponse(ServletResponse response)
设置将被包装的响应。
ThrowsIllegalArgumentException: 如果 response 为 null
英文文档:

setResponse

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

Throws:
IllegalArgumentException - if the response is null.

public void setCharacterEncoding(String charset)
此方法的默认行为是对包装的响应对象调用 setCharacterEncoding(String charset)。
since2.4
英文文档:

setCharacterEncoding

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

Specified by:
setCharacterEncoding in interface ServletResponse
Parameters:
charset - a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
Since:
2.4
See Also:
#setLocale

public String getCharacterEncoding()
此方法的默认行为是返回对包装的响应对象调用 getCharacterEncoding() 的结果。
英文文档:

getCharacterEncoding

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

Specified by:
getCharacterEncoding in interface ServletResponse
Returns:
a String specifying the name of the character encoding, for example, UTF-8

public ServletOutputStream getOutputStream() throws java.io.IOException
此方法的默认行为是返回对包装的响应对象调用 getOutputStream() 的结果。
英文文档:

getOutputStream

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

Specified by:
getOutputStream in interface ServletResponse
Returns:
a ServletOutputStream for writing binary data
Throws:
IOException - if an input or output exception occurred
See Also:
ServletResponse.getWriter()

public java.io.PrintWriter getWriter() throws java.io.IOException
此方法的默认行为是返回对包装的响应对象调用 getWriter() 的结果。
英文文档:

getWriter

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

Specified by:
getWriter in interface ServletResponse
Returns:
a PrintWriter object that can return character data to the client
Throws:
IOException - if an input or output exception occurred
See Also:
ServletResponse.getOutputStream(), ServletResponse.setCharacterEncoding(java.lang.String)

public void setContentLength(int len)
此方法的默认行为是对包装的响应对象调用 setContentLength(int len)。
英文文档:

setContentLength

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

Specified by:
setContentLength in interface ServletResponse
Parameters:
len - an integer specifying the length of the content being returned to the client; sets the Content-Length header

public void setContentType(String type)
此方法的默认行为是对包装的响应对象调用 setContentType(String type)。
英文文档:

setContentType

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

Specified by:
setContentType in interface ServletResponse
Parameters:
type - a String specifying the MIME type of the content
See Also:
ServletResponse.setLocale(java.util.Locale), ServletResponse.setCharacterEncoding(java.lang.String), ServletResponse.getOutputStream(), ServletResponse.getWriter()

public String getContentType()
此方法的默认行为是返回对包装的响应对象调用 getContentType() 的结果。
since2.4
英文文档:

getContentType

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

Specified by:
getContentType in interface ServletResponse
Returns:
a String specifying the content type, for example, text/html; charset=UTF-8, or null
Since:
2.4

public void setBufferSize(int size)
此方法的默认行为是对包装的响应对象调用 setBufferSize(int size)。
英文文档:

setBufferSize

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

Specified by:
setBufferSize in interface ServletResponse
Parameters:
size - the preferred buffer size
See Also:
ServletResponse.getBufferSize(), ServletResponse.flushBuffer(), ServletResponse.isCommitted(), ServletResponse.reset()

public int getBufferSize()
此方法的默认行为是返回对包装的响应对象调用 getBufferSize() 的结果。
英文文档:

getBufferSize

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

Specified by:
getBufferSize in interface ServletResponse
Returns:
the actual buffer size used
See Also:
ServletResponse.setBufferSize(int), ServletResponse.flushBuffer(), ServletResponse.isCommitted(), ServletResponse.reset()

public void flushBuffer() throws java.io.IOException
此方法的默认行为是对包装的响应对象调用 flushBuffer()。
英文文档:

flushBuffer

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

Specified by:
flushBuffer in interface ServletResponse
Throws:
IOException
See Also:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.isCommitted(), ServletResponse.reset()

public boolean isCommitted()
此方法的默认行为是返回对包装的响应对象调用 isCommitted() 的结果。
英文文档:

isCommitted

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

Specified by:
isCommitted in interface ServletResponse
Returns:
a boolean indicating if the response has been committed
See Also:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.flushBuffer(), ServletResponse.reset()

public void reset()
此方法的默认行为是对包装的响应对象调用 reset()。
英文文档:

reset

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

Specified by:
reset in interface ServletResponse
See Also:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.flushBuffer(), ServletResponse.isCommitted()

public void resetBuffer()
此方法的默认行为是对包装的响应对象调用 resetBuffer()。
英文文档:

resetBuffer

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

Specified by:
resetBuffer in interface ServletResponse
See Also:
ServletResponse.setBufferSize(int), ServletResponse.getBufferSize(), ServletResponse.isCommitted(), ServletResponse.reset()

public void setLocale(java.util.Locale loc)
此方法的默认行为是对包装的响应对象调用 setLocale(Locale loc)。
英文文档:

setLocale

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

Specified by:
setLocale in interface ServletResponse
Parameters:
loc - the locale of the response
See Also:
ServletResponse.getLocale(), ServletResponse.setContentType(java.lang.String), ServletResponse.setCharacterEncoding(java.lang.String)

public java.util.Locale getLocale()
此方法的默认行为是返回对包装的响应对象调用 getLocale() 的结果。
英文文档:

getLocale

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

Specified by:
getLocale in interface ServletResponse
See Also:
ServletResponse.setLocale(java.util.Locale)


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!