cn.dreampie.common.http
类 AbstractResponse<R>

java.lang.Object
  继承者 cn.dreampie.common.http.AbstractResponse<R>
所有已实现的接口:
Response
直接已知子类:
HttpResponse

public abstract class AbstractResponse<R>
extends Object
implements Response

Date: 1/3/14 Time: 20:46


构造方法摘要
protected AbstractResponse(Class<R> responseClass, R response)
           
 
方法摘要
 Response addCookie(String cookie, String value)
           
 Response addHeader(String headerName, String header)
           
 void close()
           
protected abstract  void doAddHeader(String headerName, String header)
           
protected abstract  OutputStream doGetOutputStream()
           
protected abstract  void doSetHeader(String headerName, String header)
           
protected abstract  void doSetStatus(HttpStatus httpStatus)
           
 Charset getCharset()
          Returns the charset set on this response if any.
 String getHeader(String headerName)
          Returns the value of a header previously set with setHeader().
 OutputStream getOutputStream()
           
 HttpStatus getStatus()
           
 PrintWriter getWriter()
          A writer you can write to to send response as text.
 boolean isClosed()
           
 Response setContentType(String s)
          Sets the content type of this response.
 Response setHeader(String headerName, String header)
           
 Response setStatus(HttpStatus httpStatus)
           
 String toString()
           
<T> T
unwrap(Class<T> clazz)
          Unwraps the underlying native implementation of given class.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
从接口 cn.dreampie.common.Response 继承的方法
addCookie, clearCookie
 

构造方法详细信息

AbstractResponse

protected AbstractResponse(Class<R> responseClass,
                           R response)
方法详细信息

getStatus

public HttpStatus getStatus()
指定者:
接口 Response 中的 getStatus

setStatus

public Response setStatus(HttpStatus httpStatus)
指定者:
接口 Response 中的 setStatus

setContentType

public Response setContentType(String s)
从接口 Response 复制的描述
Sets the content type of this response.

It is highly recommended to call this before writing the response content, especially if you want to use getWriter().

The response charset may be set when calling this, either to the provided charset in the content type, or by default to UTF-8 if it is a 'text' content type.

指定者:
接口 Response 中的 setContentType
参数:
s - the content type
返回:
the current response

getCharset

public Charset getCharset()
从接口 Response 复制的描述
Returns the charset set on this response if any.

The charset is set when calling setContentType, either to the provided charset in the content type, or by default to UTF-8 if it is a 'text' content type.

指定者:
接口 Response 中的 getCharset
返回:
the charset

getWriter

public PrintWriter getWriter()
                      throws IOException
从接口 Response 复制的描述
A writer you can write to to send response as text.

The charset used is the one returned by getCharset(), or UTF-8 if not set.

It is strongly recommended to call setContentType to set the charset before calling this method.

指定者:
接口 Response 中的 getWriter
返回:
a PrintWriter which can be used to write the response.
抛出:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
指定者:
接口 Response 中的 getOutputStream
抛出:
IOException

close

public void close()
           throws IOException
抛出:
IOException

isClosed

public boolean isClosed()
指定者:
接口 Response 中的 isClosed

addCookie

public Response addCookie(String cookie,
                          String value)
指定者:
接口 Response 中的 addCookie

setHeader

public final Response setHeader(String headerName,
                                String header)
指定者:
接口 Response 中的 setHeader

addHeader

public final Response addHeader(String headerName,
                                String header)

doSetHeader

protected abstract void doSetHeader(String headerName,
                                    String header)

doAddHeader

protected abstract void doAddHeader(String headerName,
                                    String header)

getHeader

public String getHeader(String headerName)
从接口 Response 复制的描述
Returns the value of a header previously set with setHeader().

指定者:
接口 Response 中的 getHeader
参数:
headerName - the name of the header to get.
返回:
the header value.

toString

public String toString()
覆盖:
Object 中的 toString

unwrap

public <T> T unwrap(Class<T> clazz)
从接口 Response 复制的描述
Unwraps the underlying native implementation of given class.

Examnple: This is a HttpServletRequest in a servlet container.

指定者:
接口 Response 中的 unwrap
类型参数:
T - unwrapped class
参数:
clazz - the class of the underlying implementation
返回:
the unwrapped implementation.

doGetOutputStream

protected abstract OutputStream doGetOutputStream()
                                           throws IOException
抛出:
IOException

doSetStatus

protected abstract void doSetStatus(HttpStatus httpStatus)


Copyright © 2015. All rights reserved.