Class BaseURLWrapper
- java.lang.Object
-
- jakarta.portlet.filter.RenderStateWrapper
-
- jakarta.portlet.filter.BaseURLWrapper
-
- All Implemented Interfaces:
BaseURL,RenderState
- Direct Known Subclasses:
PortletURLWrapper,ResourceURLWrapper
public class BaseURLWrapper extends RenderStateWrapper implements BaseURL
TheBaseURLWrapperprovides a convenient implementation of theBaseURLinterface that can be subclassed by developers. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped object.- Since:
- 3.0
-
-
Field Summary
-
Fields inherited from class jakarta.portlet.filter.RenderStateWrapper
wrapped
-
-
Constructor Summary
Constructors Constructor Description BaseURLWrapper(BaseURL wrapped)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddProperty(String key, String value)Adds a String property to an existing key on the URL.Appendableappend(Appendable out)Appends the portlet URL to the appendable object.Appendableappend(Appendable out, boolean escapeXML)Appends the portlet URL to the appendable object.Map<String,String[]>getParameterMap()Deprecated.BaseURLgetWrapped()Gets the wrapped object.voidsetParameter(String name, String value)Deprecated.voidsetParameter(String name, String... values)Deprecated.voidsetParameters(Map<String,String[]> parameters)Deprecated.voidsetProperty(String key, String value)Sets a String property on the URL.voidsetSecure(boolean secure)Indicates the security setting for this URL.voidsetWrapped(BaseURL wrapped)Sets the wrapped object.StringtoString()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.voidwrite(Writer out)Writes the portlet URL to the output stream using the provided writer.voidwrite(Writer out, boolean escapeXML)Writes the portlet URL to the output stream using the provided writer.-
Methods inherited from class jakarta.portlet.filter.RenderStateWrapper
getPortletMode, getRenderParameters, getWindowState, setWrapped
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jakarta.portlet.RenderState
getPortletMode, getRenderParameters, getWindowState
-
-
-
-
Constructor Detail
-
BaseURLWrapper
public BaseURLWrapper(BaseURL wrapped)
- Parameters:
wrapped- the wrapped object to set.- Throws:
IllegalArgumentException- if the BaseURL is null.
-
-
Method Detail
-
getWrapped
public BaseURL getWrapped()
Gets the wrapped object.- Overrides:
getWrappedin classRenderStateWrapper- Returns:
- the wrapped object.
-
setWrapped
public void setWrapped(BaseURL wrapped)
Sets the wrapped object.- Parameters:
wrapped- the wrapped object to set.- Throws:
IllegalArgumentException- if the BaseURL is null.
-
setParameter
@Deprecated public void setParameter(String name, String value)
Deprecated.Description copied from interface:BaseURLSets the given String parameter on this URL.This method replaces all parameter values with the given key, as allowed according to the rules for the URL.
-
RenderURL- Both public and private parameters can be set. -
ActionURL- Action parameters (private parameters) are set as described. Public render parameters remain unchanged. If an action parameter has the same name as a public render parameter, both the action parameter value and the public render parameter value will be available during processing of the action request. -
ResourceURL- Resource parameters are set. Public and private render parameters that were attached to the URL when it was created remain unchanged. If a resource parameter has the same name as a public or private render parameter, both the resource parameter value and the public or private render parameter value will be available during processing of the resource request.
The
PortletURLimplementation '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
nullindicates that this parameter should be removed. However, an empty string value ("") is allowed.A public render parameter cannot be removed by setting its value to
null.- Specified by:
setParameterin interfaceBaseURL- Parameters:
name- the parameter namevalue- the parameter value
-
-
setParameter
@Deprecated public void setParameter(String name, String... values)
Deprecated.Description copied from interface:BaseURLSets a multi-valued String parameter on this URL.This method replaces all parameter values with the given key according to the rules for the URL.
-
RenderURL- Both public and private parameters can be set. -
ActionURL- Action parameters (private parameters) are set as described. Public render parameters remain unchanged. If an action parameter has the same name as a public render parameter, both the action parameter value and the public render parameter value will be available during processing of the action request. -
ResourceURL- Resource parameters are set. Public and private render parameters that were attached to the URL when it was created remain unchanged. If a resource parameter has the same name as a public or private render parameter, both the resource parameter value and the public or private render parameter value will be available during processing of the resource request.
The
PortletURLimplementation '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 values parameter of
nullindicates that this parameter should be removed.If the values parameter is not null, no element of the values array may be null. However, an empty string value ("") is allowed.
- Specified by:
setParameterin interfaceBaseURL- Parameters:
name- the parameter namevalues- the parameter values
-
-
setParameters
@Deprecated public void setParameters(Map<String,String[]> parameters)
Deprecated.Description copied from interface:BaseURLSets a parameter map for this URL.All previously set parameters are cleared.
This method can be used to set both public and private render parameters according to the rules for the URL.
-
RenderURL- Both public and private parameters can be set. -
ActionURL- Action parameters are set. Public render parameters remain unchanged. If an action parameter has the same name as a public render parameter, both the action parameter value and the public render parameter value will be available during processing of the action request. -
ResourceURL- Resource parameters are set. Public and private render parameters that were attached to the URL when it was created remain unchanged. If a resource parameter has the same name as a public or private render parameter, both the resource parameter value and the public or private render parameter value will be available during processing of the resource request.
These parameters will be accessible through the portlet request initiated through the URL.
Any previously set private render parameter that is not contained in the new map is removed. However, public render parameters cannot be removed by excluding them from the map. Public render parameters that are not included in the map remain unchanged.
The
PortletURLimplementation '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:
setParametersin interfaceBaseURL- 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 and may not be null or the empty string (""). The values in the parameter map must be of type String array (String[]). Neither the values array nor any of its elements may be null; however, the empty string ("") is allowed as an array element.
-
-
setSecure
public void setSecure(boolean secure) throws PortletSecurityExceptionDescription copied from interface:BaseURLIndicates the security setting for this URL.Secure set to
trueindicates that the portlet requests a secure connection between the client and the portlet window for this URL. Secure set tofalseindicates 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:
setSecurein interfaceBaseURL- 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
-
getParameterMap
@Deprecated public Map<String,String[]> getParameterMap()
Deprecated.Description copied from interface:BaseURLReturns aMapof the parameters currently set on this portlet URL.The values in the returned
Mapare from type String array (String[]).The contents of the returned map are immutable in the sense that modifying the map does not directly affect the render parameters. In order to set the parameters using the modified map, the
BaseURL.setParameters(Map)method must be used.If no parameters exist this method returns an empty
Map.- Specified by:
getParameterMapin interfaceBaseURL- Returns:
Mapcontaining parameter names as keys and parameter values as map values, or an emptyMapif 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[]).
-
write
public void write(Writer out) throws IOException
Description copied from interface:BaseURLWrites 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:
writein interfaceBaseURL- Parameters:
out- the writer to write the portlet URL to- Throws:
IOException- if an I/O error occurred while writing the URL
-
write
public void write(Writer out, boolean escapeXML) throws IOException
Description copied from interface:BaseURLWrites 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. The manner in which escaping is performed is implementation specific. IfescapeXMLis set tofalse, escaping the URL is left to the implementation.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:
writein interfaceBaseURL- Parameters:
out- the writer to write the portlet URL toescapeXML- denotes if the URL should be XML escaped before written to the output stream or not- Throws:
IOException- if an I/O error occurred while writing the URL
-
append
public Appendable append(Appendable out) throws IOException
Description copied from interface:BaseURLAppends the portlet URL to the appendable object.Note that the appended URL may not be a valid URL, as it may be rewritten by the portal/portlet-container before returning the markup to the client.
The appended URL is always XML escaped. For appending non-escaped URLs use
BaseURL.append(java.lang.Appendable, boolean).- Specified by:
appendin interfaceBaseURL- Parameters:
out- the object to receive the URL- Returns:
- Appendable the Appendable object containing the URL
- Throws:
IOException- if an I/O error occurred while writing the URL
-
append
public Appendable append(Appendable out, boolean escapeXML) throws IOException
Description copied from interface:BaseURLAppends the portlet URL to the appendable object.If the parameter escapeXML is set to
true, the URL will be escaped to be valid XML characters. The manner in which escaping is performed is implementation specific. IfescapeXMLis set tofalse, escaping the URL is left to the implementation.Note that the appended URL 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:
appendin interfaceBaseURL- Parameters:
out- the object to receive the URLescapeXML- flag indicating whether or not the Appendable object should be escaped- Returns:
- Appendable the Appendable object containing the URL
- Throws:
IOException- if an I/O error occurred while writing the URL
-
addProperty
public void addProperty(String key, String value)
Description copied from interface:BaseURLAdds 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:
addPropertyin interfaceBaseURL- Parameters:
key- the key of the propertyvalue- the value of the property
-
setProperty
public void setProperty(String key, String value)
Description copied from interface:BaseURLSets 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:
setPropertyin interfaceBaseURL- Parameters:
key- the key of the propertyvalue- the value of the property
-
toString
public String toString()
Description copied from interface:BaseURLReturns 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)orBaseURL.write(java.io.Writer, boolean)method should be used as these are more efficient.
-
-