org.apache.pluto.internal.impl
Class BaseURLImpl

java.lang.Object
  extended by org.apache.pluto.internal.impl.BaseURLImpl
All Implemented Interfaces:
BaseURL
Direct Known Subclasses:
PortletURLImpl, ResourceURLImpl

public class BaseURLImpl
extends java.lang.Object
implements BaseURL

Implementation of JSR-286 BaseURL, which includes a refactoring of PortletURLImpl.

Since:
2.0

Field Summary
protected  PortletContainer container
           
protected  PortalContext context
           
protected  InternalPortletWindow internalPortletWindow
           
protected  boolean isAction
           
protected  boolean isResourceServing
           
protected  PortletMode mode
           
protected  java.util.Map parameters
           
protected  java.util.Map<java.lang.String,java.lang.String[]> publicRenderParameters
           
protected  boolean secure
           
protected  javax.servlet.http.HttpServletRequest servletRequest
           
protected  javax.servlet.http.HttpServletResponse servletResponse
           
protected  WindowState state
           
 
Constructor Summary
BaseURLImpl(PortletContainer container, InternalPortletWindow internalPortletWindow, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, boolean isAction, boolean isResourceServing)
           
 
Method Summary
 void addProperty(java.lang.String key, java.lang.String value)
          Adds a String property to an existing key on the URL.
 java.lang.String getParameter(java.lang.String name)
           
 java.util.Map getParameterMap()
          Returns a Map of the parameters currently set on this portlet URL via the setParameter or setParameters methods.
 java.lang.String[] getParameters(java.lang.String name)
           
 PortletMode getPortletMode()
           
 WindowState getWindowState()
           
protected  boolean isPortletModeAllowed(PortletMode mode)
           
protected  boolean isWindowStateAllowed(WindowState state)
           
 void setParameter(java.lang.String name, java.lang.String value)
          Sets the given String parameter to this URL.
 void setParameter(java.lang.String name, java.lang.String[] values)
          Sets the given String array parameter to this URL.
 void setParameters(java.util.Map<java.lang.String,java.lang.String[]> parameters)
          Sets a parameter map for this URL.
 void setProperty(java.lang.String key, java.lang.String value)
          Sets a String property on the URL.
 void setSecure(boolean secure)
          Indicated the security setting for this URL.
 java.lang.String toString()
          Returns the portlet URL string representation to be embedded in the markup.
Note that the returned String may not be a valid URL, as it may be rewritten by the portal/portlet-container before returning the markup to the client.
 void write(java.io.Writer out)
          Writes the portlet URL to the output stream using the provided writer.
 void write(java.io.Writer out, boolean escapeXML)
          Writes the portlet URL to the output stream using the provided writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parameters

protected java.util.Map parameters

publicRenderParameters

protected java.util.Map<java.lang.String,java.lang.String[]> publicRenderParameters

secure

protected boolean secure

container

protected PortletContainer container

mode

protected PortletMode mode

internalPortletWindow

protected InternalPortletWindow internalPortletWindow

servletRequest

protected javax.servlet.http.HttpServletRequest servletRequest

servletResponse

protected javax.servlet.http.HttpServletResponse servletResponse

state

protected WindowState state

isAction

protected boolean isAction

isResourceServing

protected boolean isResourceServing

context

protected PortalContext context
Constructor Detail

BaseURLImpl

public BaseURLImpl(PortletContainer container,
                   InternalPortletWindow internalPortletWindow,
                   javax.servlet.http.HttpServletRequest servletRequest,
                   javax.servlet.http.HttpServletResponse servletResponse,
                   boolean isAction,
                   boolean isResourceServing)
Method Detail

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Description copied from interface: BaseURL
Sets the given String parameter to this URL.

This method replaces all parameters with the given key.

The PortletURL implementation 'x-www-form-urlencoded' encodes all parameter names and values. Developers should not encode them.

A portlet container may prefix the attribute names internally in order to preserve a unique namespace for the portlet.

A parameter value of null indicates that this parameter should be removed.

Specified by:
setParameter in interface BaseURL
Parameters:
name - the parameter name
value - the parameter value

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String[] values)
Description copied from interface: BaseURL
Sets the given String array parameter to this URL.

This method replaces all parameters with the given key.

The PortletURL implementation 'x-www-form-urlencoded' encodes all parameter names and values. Developers should not encode them.

A portlet container may prefix the attribute names internally in order to preserve a unique namespace for the portlet.

Specified by:
setParameter in interface BaseURL
Parameters:
name - the parameter name
values - the parameter values

setParameters

public void setParameters(java.util.Map<java.lang.String,java.lang.String[]> parameters)
Description copied from interface: BaseURL
Sets a parameter map for this URL.

All previously set parameters are cleared.

The PortletURL implementation 'x-www-form-urlencoded' encodes all parameter names and values. Developers should not encode them.

A portlet container may prefix the attribute names internally, in order to preserve a unique namespace for the portlet.

Specified by:
setParameters in interface BaseURL
Parameters:
parameters - Map containing parameter names for the render phase as keys and parameter values as map values. The keys in the parameter map must be of type String. The values in the parameter map must be of type String array (String[]).

setSecure

public void setSecure(boolean secure)
               throws PortletSecurityException
Description copied from interface: BaseURL
Indicated the security setting for this URL.

Secure set to true indicates that the portlet requests a secure connection between the client and the portlet window for this URL. Secure set to false indicates that the portlet does not need a secure connection for this URL. If the security is not set for a URL, it should stay the same as the current request.

Specified by:
setSecure in interface BaseURL
Parameters:
secure - true, if portlet requests to have a secure connection between its portlet window and the client; false, if the portlet does not require a secure connection.
Throws:
PortletSecurityException - if the run-time environment does not support the indicated setting

toString

public java.lang.String toString()
Description copied from interface: BaseURL
Returns the portlet URL string representation to be embedded in the markup.
Note that the returned String may not be a valid URL, as it may be rewritten by the portal/portlet-container before returning the markup to the client.

The returned URL is not XML escaped.

For writing URLs to an output stream the BaseURL.write(java.io.Writer) or BaseURL.write(java.io.Writer, boolean) method should be used as these are more efficient.

Specified by:
toString in interface BaseURL
Overrides:
toString in class java.lang.Object
Returns:
the encoded URL as a string

getParameter

public java.lang.String getParameter(java.lang.String name)

getParameters

public java.lang.String[] getParameters(java.lang.String name)

getParameterMap

public java.util.Map getParameterMap()
Description copied from interface: BaseURL
Returns a Map of the parameters currently set on this portlet URL via the setParameter or setParameters methods.

The values in the returned Map are from type String array (String[]).

If no parameters exist this method returns an empty Map.

Specified by:
getParameterMap in interface BaseURL
Returns:
Map containing parameter names as keys and parameter values as map values, or an empty Map if no parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of type String array (String[]).

getPortletMode

public PortletMode getPortletMode()

getWindowState

public WindowState getWindowState()

isPortletModeAllowed

protected boolean isPortletModeAllowed(PortletMode mode)
                                throws PortletModeException
Throws:
PortletModeException

isWindowStateAllowed

protected boolean isWindowStateAllowed(WindowState state)

write

public void write(java.io.Writer out)
           throws java.io.IOException
Description copied from interface: BaseURL
Writes the portlet URL to the output stream using the provided writer.

Note that the URL written to the output stream may not be a valid URL, as it may be rewritten by the portal/portlet-container before returning the markup to the client.

The URL written to the output stream is always XML escaped. For writing non-escaped URLs use BaseURL.write(java.io.Writer, boolean).

Specified by:
write in interface BaseURL
Parameters:
out - the writer to write the portlet URL to
Throws:
java.io.IOException - if an I/O error occured while writing the URL

write

public void write(java.io.Writer out,
                  boolean escapeXML)
           throws java.io.IOException
Description copied from interface: BaseURL
Writes the portlet URL to the output stream using the provided writer. If the parameter escapeXML is set to true the URL will be escaped to be valid XML characters, i.e. <, >, &, ', " will get converted into their corresponding character entity codes (< to &<, > to &>, & to &&, ' to &', " to &"). If escapeXML is set to false no escaping will be done.

Note that the URL written to the output stream may not be a valid URL, as it may be rewritten by the portal/portlet-container before returning the markup to the client.

Specified by:
write in interface BaseURL
Parameters:
out - the writer to write the portlet URL to
escapeXML - denotes if the URL should be XML escaped before written to the output stream or not
Throws:
java.io.IOException - if an I/O error occurred while writing the URL

addProperty

public void addProperty(java.lang.String key,
                        java.lang.String value)
Description copied from interface: BaseURL
Adds a String property to an existing key on the URL.

This method allows URL properties to have multiple values.

Properties can be used by portlets to provide vendor specific information to the URL.

Specified by:
addProperty in interface BaseURL
Parameters:
key - the key of the property
value - the value of the property

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Description copied from interface: BaseURL
Sets a String property on the URL.

Properties can be used by portlets to provide vendor specific information to the URL.

This method resets all properties previously added with the same key.

Specified by:
setProperty in interface BaseURL
Parameters:
key - the key of the property
value - the value of the property


Copyright © 2003-2010 Apache Software Foundation. All Rights Reserved.