Interface BaseURL
-
- All Known Subinterfaces:
PortletURL,ResourceURL
public interface BaseURLTheBaseURLdefines the basic capabilities of a portlet URL pointing back to the portlet.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddProperty(java.lang.String key, java.lang.String value)Adds a String property to an existing key on the URL.java.util.Map<java.lang.String,java.lang.String[]>getParameterMap()Returns aMapof the parameters currently set on this portlet URL via thesetParameterorsetParametersmethods.voidsetParameter(java.lang.String name, java.lang.String value)Sets the given String parameter to this URL.voidsetParameter(java.lang.String name, java.lang.String[] values)Sets the given String array parameter to this URL.voidsetParameters(java.util.Map<java.lang.String,java.lang.String[]> parameters)Sets a parameter map for this URL.voidsetProperty(java.lang.String key, java.lang.String value)Sets a String property on the URL.voidsetSecure(boolean secure)Indicated the security setting for this URL.java.lang.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(java.io.Writer out)Writes the portlet URL to the output stream using the provided writer.voidwrite(java.io.Writer out, boolean escapeXML)Writes the portlet URL to the output stream using the provided writer.
-
-
-
Method Detail
-
setParameter
void setParameter(java.lang.String name, java.lang.String value)Sets the given String parameter to this URL.This method replaces all parameters with the given key.
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.- Parameters:
name- the parameter namevalue- the parameter value- Throws:
java.lang.IllegalArgumentException- if name isnull.
-
setParameter
void setParameter(java.lang.String name, java.lang.String[] values)Sets the given String array parameter to this URL.This method replaces all parameters with the given key.
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.
- Parameters:
name- the parameter namevalues- the parameter values- Throws:
java.lang.IllegalArgumentException- if name isnull.
-
setParameters
void setParameters(java.util.Map<java.lang.String,java.lang.String[]> parameters)
Sets a parameter map for this URL.All previously set parameters are cleared.
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.
- 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[]).- Throws:
java.lang.IllegalArgumentException- if parameters isnull, if any of the keys in the Map arenull, if any of the keys is not a String, or if any of the values is not a String array.
-
setSecure
void setSecure(boolean secure) throws PortletSecurityExceptionIndicated 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.- 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
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.The returned URL is not XML escaped.
For writing URLs to an output stream the
write(java.io.Writer)orwrite(java.io.Writer, boolean)method should be used as these are more efficient.- Overrides:
toStringin classjava.lang.Object- Returns:
- the encoded URL as a string
-
getParameterMap
java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
Returns aMapof the parameters currently set on this portlet URL via thesetParameterorsetParametersmethods.The values in the returned
Mapare from type String array (String[]).If no parameters exist this method returns an empty
Map.- 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[]).- Since:
- 2.0
-
write
void write(java.io.Writer out) throws java.io.IOExceptionWrites 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
write(java.io.Writer, boolean).- Parameters:
out- the writer to write the portlet URL to- Throws:
java.io.IOException- if an I/O error occured while writing the URL- Since:
- 2.0
-
write
void write(java.io.Writer out, boolean escapeXML) throws java.io.IOExceptionWrites 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.
- 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:
java.io.IOException- if an I/O error occurred while writing the URL- Since:
- 2.0
-
addProperty
void addProperty(java.lang.String key, java.lang.String value)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.
- Parameters:
key- the key of the propertyvalue- the value of the property- Throws:
java.lang.IllegalArgumentException- if key isnull.- Since:
- 2.0
-
setProperty
void setProperty(java.lang.String key, java.lang.String value)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.
- Parameters:
key- the key of the propertyvalue- the value of the property- Throws:
java.lang.IllegalArgumentException- if key isnull.- Since:
- 2.0
-
-