org.xwiki.portlet.model
Class ResponseData

java.lang.Object
  extended by org.xwiki.portlet.model.ResponseData

public class ResponseData
extends Object

Stores the response data.

Version:
$Id: 1729385c9b877167f0cecf4ee55ca441c1c16ddc $

Constructor Summary
ResponseData()
           
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds a cookie.
 void addHeader(String name, String value)
          Adds a new value to an HTTP response header.
 boolean containsHeader(String name)
           
 String getCharacterEncoding()
           
 int getContentLength()
           
 String getContentType()
           
 List<javax.servlet.http.Cookie> getCookies()
           
 int getErrorCode()
           
 String getErrorMessage()
           
 Map<String,List<String>> getHeaders()
           
 Locale getLocale()
           
 String getMimeType()
           
 javax.servlet.ServletOutputStream getOutputStream()
           
 Reader getReader()
           
 String getRedirect()
           
 int getStatusCode()
           
 String getStatusMessage()
           
 PrintWriter getWriter()
           
 void sendError(int code, String message)
          Specifies that the request could not be fulfilled.
 void sendRedirect(String location)
          Specifies that the request must be redirected.
 void setCharacterEncoding(String charset)
          Sets the character encoding.
 void setContentLength(int len)
          Sets the content length.
 void setContentType(String type)
          Sets the content type.
 void setHeader(String name, String value)
          Overwrite all the values associated with an HTTP response header.
 void setLocale(Locale loc)
          Sets the locale.
 void setStatus(int code, String message)
          Sets the response status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseData

public ResponseData()
Method Detail

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Adds a cookie.

Parameters:
cookie - the cookie to be added

getCookies

public List<javax.servlet.http.Cookie> getCookies()
Returns:
the list of cookies

addHeader

public void addHeader(String name,
                      String value)
Adds a new value to an HTTP response header.

Parameters:
name - the header name
value - the value to add

getHeaders

public Map<String,List<String>> getHeaders()
Returns:
the map of HTTP response headers

containsHeader

public boolean containsHeader(String name)
Parameters:
name - the header name
Returns:
true if the specified header was set, false otherwise

getCharacterEncoding

public String getCharacterEncoding()
Returns:
the character encoding

getContentType

public String getContentType()
Returns:
the content type

getMimeType

public String getMimeType()
Returns:
the mime type of this response data

getContentLength

public int getContentLength()
Returns:
the content length

getLocale

public Locale getLocale()
Returns:
the locale

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws IOException
Returns:
the output stream
Throws:
IOException - if the output stream is not accessible

getWriter

public PrintWriter getWriter()
                      throws IOException
Returns:
the writer
Throws:
IOException - if the writer is not accessible

setCharacterEncoding

public void setCharacterEncoding(String charset)
Sets the character encoding.

Parameters:
charset - the new character encoding

setContentLength

public void setContentLength(int len)
Sets the content length.

Parameters:
len - the content length

setContentType

public void setContentType(String type)
Sets the content type.

Parameters:
type - the new content type

setHeader

public void setHeader(String name,
                      String value)
Overwrite all the values associated with an HTTP response header.

Parameters:
name - the header name
value - the new value

setLocale

public void setLocale(Locale loc)
Sets the locale.

Parameters:
loc - the new locale

sendRedirect

public void sendRedirect(String location)
Specifies that the request must be redirected.

Parameters:
location - the location where to redirect the request

getRedirect

public String getRedirect()
Returns:
the redirect location

sendError

public void sendError(int code,
                      String message)
Specifies that the request could not be fulfilled.

Parameters:
code - the error code
message - the error message

getErrorCode

public int getErrorCode()
Returns:
the error code

getErrorMessage

public String getErrorMessage()
Returns:
the error message;

setStatus

public void setStatus(int code,
                      String message)
Sets the response status.

Parameters:
code - the status code
message - the status message

getStatusCode

public int getStatusCode()
Returns:
the status code

getStatusMessage

public String getStatusMessage()
Returns:
the status message

getReader

public Reader getReader()
                 throws UnsupportedEncodingException
Returns:
a reader that can be used to access the content written using either the writer returned by getWriter() or the output stream returned by getOutputStream()
Throws:
UnsupportedEncodingException - if the encoding returned by getCharacterEncoding() is unsupported


Copyright © 2004-2013 XWiki. All Rights Reserved.