org.apache.cocoon.environment.portlet
Class PortletResponse

java.lang.Object
  extended by org.apache.cocoon.environment.portlet.PortletResponse
All Implemented Interfaces:
Response
Direct Known Subclasses:
ActionResponse, RenderResponse

public abstract class PortletResponse
extends Object
implements Response

Implements the Response interface for the JSR-168 (Portlet) environment.

Version:
CVS $Id: PortletResponse.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Alex Rudnev, Vadim Gritsenko

Constructor Summary
protected PortletResponse(javax.portlet.PortletResponse response, javax.portlet.PortletPreferences preferences)
          Creates a PortletResponse based on a real PortletResponse object
 
Method Summary
 void addCookie(Cookie cookie)
          Adds the specified cookie to the response.
 void addDateHeader(String name, long date)
          Adds a response header with the given name and date-value.
 void addHeader(String name, String value)
          Adds a response header with the given name and value.
 void addIntHeader(String name, int value)
          Adds a response header with the given name and int value.
 void addProperty(String key, String value)
           
 boolean containsHeader(String name)
          Returns a boolean indicating whether the named response header has already been set.
 Cookie createCookie(String name, String value)
          Constructs a cookie with a specified name and value.
 String encodeURL(String url)
          Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
 String getCharacterEncoding()
          Returns the name of the charset used for the MIME body sent in this response.
 Locale getLocale()
          Returns the locale assigned to the response.
 javax.portlet.PortletResponse getPortletResponse()
          Provides access to the underlying response object
 void setDateHeader(String name, long date)
          Sets a response header with the given name and date-value.
 void setHeader(String name, String value)
          Sets a response header with the given name and value.
 void setIntHeader(String name, int value)
          Sets a response header with the given name and int value.
 void setLocale(Locale locale)
          Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
 void setProperty(String key, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortletResponse

protected PortletResponse(javax.portlet.PortletResponse response,
                          javax.portlet.PortletPreferences preferences)
Creates a PortletResponse based on a real PortletResponse object

Method Detail

containsHeader

public boolean containsHeader(String name)
Description copied from interface: Response
Returns a boolean indicating whether the named response header has already been set.

Specified by:
containsHeader in interface Response
Parameters:
name - the header name
Returns:
true if the named response header has already been set; false otherwise

setHeader

public void setHeader(String name,
                      String value)
Description copied from interface: Response
Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setHeader in interface Response
Parameters:
name - the name of the header
value - the header value
See Also:
Response.containsHeader(String), Response.addHeader(String, String)

setIntHeader

public void setIntHeader(String name,
                         int value)
Description copied from interface: Response
Sets a response header with the given name and int value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setIntHeader in interface Response
Parameters:
name - the name of the header to set
value - the assigned int value
See Also:
Response.containsHeader(String), Response.addIntHeader(String, int)

setDateHeader

public void setDateHeader(String name,
                          long date)
Description copied from interface: Response
Sets a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setDateHeader in interface Response
Parameters:
name - the name of the header to set
date - the assigned date value
See Also:
Response.containsHeader(String), Response.addDateHeader(String, long)

addHeader

public void addHeader(String name,
                      String value)
Description copied from interface: Response
Adds a response header with the given name and value. This method allows response headers to have multiple values.

Specified by:
addHeader in interface Response
Parameters:
name - the name of the header
value - the additional header value
See Also:
Response.setHeader(String, String)

addIntHeader

public void addIntHeader(String name,
                         int value)
Description copied from interface: Response
Adds a response header with the given name and int value. This method allows response headers to have multiple values.

Specified by:
addIntHeader in interface Response
Parameters:
name - the name of the header to set
value - the additional int value
See Also:
Response.setIntHeader(String, int)

addDateHeader

public void addDateHeader(String name,
                          long date)
Description copied from interface: Response
Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. This method allows response headers to have multiple values.

Specified by:
addDateHeader in interface Response
Parameters:
name - the name of the header to set
date - the additional date value
See Also:
Response.setDateHeader(String, long)

getCharacterEncoding

public String getCharacterEncoding()
Description copied from interface: Response
Returns the name of the charset used for the MIME body sent in this response.

If no charset has been assigned, it is implicitly set to ISO-8859-1 (Latin-1).

See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.

Specified by:
getCharacterEncoding in interface Response
Returns:
a String specifying the name of the charset, for example, ISO-8859-1

createCookie

public Cookie createCookie(String name,
                           String value)
Description copied from interface: Response
Constructs a cookie with a specified name and value.

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation.

The value can be anything the server chooses to send. Its value is probably of interest only to the server. The cookie's value can be changed after creation with the setValue method.

By default, cookies are created according to the Netscape cookie specification. The version can be changed with the setVersion method.

Specified by:
createCookie in interface Response
Parameters:
name - a String specifying the name of the cookie
value - a String specifying the value of the cookie

addCookie

public void addCookie(Cookie cookie)
Description copied from interface: Response
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

Specified by:
addCookie in interface Response
Parameters:
cookie - the Cookie to return to the client

setLocale

public void setLocale(Locale locale)
Description copied from interface: Response
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. By default, the response locale is the default locale for the server.

Specified by:
setLocale in interface Response
Parameters:
locale - the locale of the response
See Also:
Response.getLocale()

getLocale

public Locale getLocale()
Description copied from interface: Response
Returns the locale assigned to the response.

Specified by:
getLocale in interface Response
See Also:
Response.setLocale(Locale)

encodeURL

public String encodeURL(String url)
Description copied from interface: Response
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.

For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

Specified by:
encodeURL in interface Response
Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

getPortletResponse

public javax.portlet.PortletResponse getPortletResponse()
Provides access to the underlying response object

Returns:
portlet API response object

addProperty

public void addProperty(String key,
                        String value)

setProperty

public void setProperty(String key,
                        String value)


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.