com.bea.netuix.util
Class PortletParameters

java.lang.Object
  extended by com.bea.netuix.util.PortletParameters
All Implemented Interfaces
Serializable

public class PortletParameters
extends Object
implements Serializable

Represents a set of parameters for a portlet.

This class exists to avoid repeatedly serializing and deserializing parameters from a string whenever possible, and to ensure consistent encoding and decoding of parameter names and values. This class is NOT internally synchronized.

See Also
Serialized Form

Nested Class Summary
static interface PortletParameters.ParameterFilter
          Implementations of this interface are used to filter out or rename parameters when initially constructing a PortletParameters object.
 
Constructor Summary
PortletParameters()
          Construct an empty PortletParameters
PortletParameters(LinkedHashMap<String,List<String>> paramMap)
          Constructs a new PortletParameters with the given parameter mapping.
PortletParameters(PortletParameters params, PortletParameters.ParameterFilter filter)
          Constructs a new PortletParameters using the specified starting set and optional filter.
PortletParameters(String queryString)
          Construct a PortletParameters with the given initial parameter values.
PortletParameters(String queryString, PortletParameters.ParameterFilter filter, String encoding)
          Constructs a new PortletParameters using the specified query string and optional filter.
 
Method Summary
 void append(String name, List<String> additionalValues)
          Appends the specified values to the parameter with the given name.
 void append(String name, String[] additionalValues)
          Appends the specified values to the parameter with the given name.
 void appendAll(Map<String,String[]> sourceMap)
          Includes all parameters from the specified object into our own, appending any new values to existing values.
 void appendAll(PortletParameters other)
          Includes all parameters from the specified object into our own, appending any new values to existing values.
 void appendFilteredParameters(Map<String,String[]> other, PortletParameters.ParameterFilter filter)
          Includes all parameters from the specified Map into this PortletParameters, after running through the specified filter to eliminate and / or rename parameters from the supplied PortletParameters.
 void appendFilteredParameters(PortletParameters other, PortletParameters.ParameterFilter filter)
          Includes all parameters from the specified PortletParameters into this PortletParameters, after running through the specified filter to eliminate and / or rename parameters from the supplied PortletParameters.
 void appendFilteredParametersMapList(Map<String,List<String>> other, PortletParameters.ParameterFilter filter)
          Includes all parameters from the specified Map into this PortletParameters, after running through the specified filter to eliminate and / or rename parameters from the supplied PortletParameters.
 void appendValue(String name, String value)
          Appends the specified value to the parameter with the given name.
 void clear()
          Clears out the parameters
static PortletParameters createPortletParameters(Map<String,List<String>> parameters)
          Creates a new PortletParameters using the specified map.
static PortletParameters createPortletParametersFromXmlEscapedQueryString(String escapedQueryString)
          This method creates a PortletParameters object from a query string, first un-escaping any XML-escaped values for quote, apostrophe, ampersand, less-than and greater-than.
 String decode(String value)
          URL-decodes the specified value using the encoding set on this PortletParameters object.
 String encode(String value)
          URL-encodes the specified value using the encoding set on this PortletParameters object.
 boolean equals(Object o)
           
 String getAsString()
          Get a string representation (properly encoded) of the parameters
 String getAsString(PortletParameters.ParameterFilter filter)
          Get a string representation (properly encoded) of the parameters
 String getFirstValue(String name)
          Gets the first value for the specified parameter, if a value exists, otherwise null.
 LinkedHashMap<String,String[]> getParameterMap()
          Returns a deep copy of the internal map of parameters, with values as a String array.
 LinkedHashMap<String,String[]> getParameterMap(PortletParameters.ParameterFilter filter)
          Returns a deep copy of the internal map of parameters, with the specified filter applied, with values as a String array.
 LinkedHashMap<String,List<String>> getParameterMapList()
          Returns a deep copy of the internal map of parameters, with values as a List of String
 LinkedHashMap<String,List<String>> getParameterMapList(PortletParameters.ParameterFilter filter)
          Returns a deep copy of the internal map of parameters, with values as a List of String
 int getSize()
          Returns the number of discreet mappings contained
 String[] getValues(String name)
          Returns the set of values for the specified parameter
 boolean isEmpty()
          Determines if this PortletParameters object contains any parameter mappings.
 Set<String> keySet()
           
 boolean parameterValuesEqual(String paramName, PortletParameters other)
          Compares the values of the specified parameter in this PortletParameters object with the values of the same parameter in the supplied PortletParameters object, returning true only if all values are the same and in the same order.
static LinkedHashMap<String,List<String>> parseQueryString(String queryString, String encoding, PortletParameters.ParameterFilter filter)
          Parses a query string into a map, using the specified encoding and optional parameter filter.
 void put(String name, List<String> value)
          Puts the specified parameter mapping in, replacing any previous values
 void put(String name, String value)
           
 void put(String name, String[] value)
          Puts the specified parameter mapping in, replacing any previous values
 void remove(String name)
           
 void setEncoding(String encoding)
          Sets the encoding
 void setFromString(String params)
          Sets ALL values from the given string, wiping out all previous settings
 String toString()
           
static String xmlDecode(String escapedString)
          Utility method for decoding XML escape sequences for less-than, greater-than, ampersand, quote and apostrophe.
static String xmlEncode(String arg)
          Utility method for encoding XML escape sequences for less-than, greater-than, ampersand, quote and apostrophe.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PortletParameters

public PortletParameters(String queryString)
Construct a PortletParameters with the given initial parameter values. This assumes that ampersands are separating parameters in the query string- not the HTML-escaped ampersand form. If the HTML escaped ampersand, apostrophe, quote, less than and greater than forms are used in the query string, use the createPortletParametersFromXmlEscapedQueryString() method.

Parameters
queryString - the query string to use

PortletParameters

public PortletParameters()
Construct an empty PortletParameters


PortletParameters

public PortletParameters(LinkedHashMap<String,List<String>> paramMap)
Constructs a new PortletParameters with the given parameter mapping. The supplied map is not cloned, so it should not be altered externally after calling this constructor!


PortletParameters

public PortletParameters(String queryString,
                         PortletParameters.ParameterFilter filter,
                         String encoding)
Constructs a new PortletParameters using the specified query string and optional filter. The filter is applied ONLY when the object is constructed, not during subsequent operations.

Parameters
queryString - the query string to parse
encoding - the encoding to use
filter - the parameter filter to use when constructing this object, which can rename parameters or eliminate them from the resulting map.

PortletParameters

public PortletParameters(PortletParameters params,
                         PortletParameters.ParameterFilter filter)
Constructs a new PortletParameters using the specified starting set and optional filter. The filter is applied ONLY when the object is constructed, not during subsequent operations.

Parameters
params - the starting set of parameters
filter - the parameter filter to use when constructing this object, which can rename parameters or eliminate them from the original set.
Method Detail

createPortletParametersFromXmlEscapedQueryString

public static PortletParameters createPortletParametersFromXmlEscapedQueryString(String escapedQueryString)
This method creates a PortletParameters object from a query string, first un-escaping any XML-escaped values for quote, apostrophe, ampersand, less-than and greater-than.

Parameters
escapedQueryString - a string with ampersands escaped as "&amp;" to create the portlet parameters from. If null, it is treated the same as an empty query string.

createPortletParameters

public static PortletParameters createPortletParameters(Map<String,List<String>> parameters)
Creates a new PortletParameters using the specified map. The parameter order in the resulting PortletParameters object will have the order that the map iteration returns them in.

Parameters
parameters - the parameters to create the PortletParameters object from. If null, it is treated the same as an empty map. If there are keys in the map which have null values, the key is ignored. If a key has an empty list as a value, it is included in the resulting PortletParameters with no values.

xmlDecode

public static String xmlDecode(String escapedString)
Utility method for decoding XML escape sequences for less-than, greater-than, ampersand, quote and apostrophe.

Parameters
escapedString - the string to decode.
Returns
the decoded string, with all occurances of the XML escape sequences for less-than, greater-than, ampersand, quote and apostrophe replaced with the appropriate character.

xmlEncode

public static String xmlEncode(String arg)
Utility method for encoding XML escape sequences for less-than, greater-than, ampersand, quote and apostrophe.

Parameters
arg - the string to be encoded.
Returns
the argument string with all occurances of less-than, greater-than, ampersand, quote and apostrophe characters replaced with the appropriate XML escape sequence..

setEncoding

public void setEncoding(String encoding)
Sets the encoding


isEmpty

public boolean isEmpty()
Determines if this PortletParameters object contains any parameter mappings.

Returns
true if this PortletParameters contains no parameter mappings at all, false otherwise.

getAsString

public String getAsString()
Get a string representation (properly encoded) of the parameters


getAsString

public String getAsString(PortletParameters.ParameterFilter filter)
Get a string representation (properly encoded) of the parameters


encode

public String encode(String value)
URL-encodes the specified value using the encoding set on this PortletParameters object.


decode

public String decode(String value)
URL-decodes the specified value using the encoding set on this PortletParameters object.


setFromString

public void setFromString(String params)
Sets ALL values from the given string, wiping out all previous settings


put

public void put(String name,
                List<String> value)
Puts the specified parameter mapping in, replacing any previous values


put

public void put(String name,
                String[] value)
Puts the specified parameter mapping in, replacing any previous values


put

public void put(String name,
                String value)

getFirstValue

public String getFirstValue(String name)
Gets the first value for the specified parameter, if a value exists, otherwise null.


getValues

public String[] getValues(String name)
Returns the set of values for the specified parameter


parameterValuesEqual

public boolean parameterValuesEqual(String paramName,
                                    PortletParameters other)
Compares the values of the specified parameter in this PortletParameters object with the values of the same parameter in the supplied PortletParameters object, returning true only if all values are the same and in the same order.

Parameters
paramName - the name of the parameter to compare
other - the other PortletParameters object to compare the parameter values with
Returns
true if all values are the same for the specified parameter in this PortletParemeters object and the supplied PortletParameters object.

appendAll

public void appendAll(PortletParameters other)
Includes all parameters from the specified object into our own, appending any new values to existing values.


appendFilteredParameters

public void appendFilteredParameters(PortletParameters other,
                                     PortletParameters.ParameterFilter filter)
Includes all parameters from the specified PortletParameters into this PortletParameters, after running through the specified filter to eliminate and / or rename parameters from the supplied PortletParameters. The supplied object is NOT affected.


appendFilteredParameters

public void appendFilteredParameters(Map<String,String[]> other,
                                     PortletParameters.ParameterFilter filter)
Includes all parameters from the specified Map into this PortletParameters, after running through the specified filter to eliminate and / or rename parameters from the supplied PortletParameters. The supplied object is NOT affected.


appendFilteredParametersMapList

public void appendFilteredParametersMapList(Map<String,List<String>> other,
                                            PortletParameters.ParameterFilter filter)
Includes all parameters from the specified Map into this PortletParameters, after running through the specified filter to eliminate and / or rename parameters from the supplied PortletParameters. The supplied object is NOT affected.


appendAll

public void appendAll(Map<String,String[]> sourceMap)
Includes all parameters from the specified object into our own, appending any new values to existing values.


append

public void append(String name,
                   List<String> additionalValues)
Appends the specified values to the parameter with the given name.


append

public void append(String name,
                   String[] additionalValues)
Appends the specified values to the parameter with the given name.


appendValue

public void appendValue(String name,
                        String value)
Appends the specified value to the parameter with the given name.


clear

public void clear()
Clears out the parameters


getParameterMap

public LinkedHashMap<String,String[]> getParameterMap()
Returns a deep copy of the internal map of parameters, with values as a String array.


getParameterMap

public LinkedHashMap<String,String[]> getParameterMap(PortletParameters.ParameterFilter filter)
Returns a deep copy of the internal map of parameters, with the specified filter applied, with values as a String array.

Parameters
filter - the filter to use in renaming / removing parameters when creating the map, or null if no filter should be used.

getParameterMapList

public LinkedHashMap<String,List<String>> getParameterMapList()
Returns a deep copy of the internal map of parameters, with values as a List of String


getParameterMapList

public LinkedHashMap<String,List<String>> getParameterMapList(PortletParameters.ParameterFilter filter)
Returns a deep copy of the internal map of parameters, with values as a List of String

Parameters
filter - the filter to use in renaming / removing parameters when creating the map, or null if no filter should be used.

keySet

public Set<String> keySet()

remove

public void remove(String name)

getSize

public int getSize()
Returns the number of discreet mappings contained


toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

parseQueryString

public static LinkedHashMap<String,List<String>> parseQueryString(String queryString,
                                                                  String encoding,
                                                                  PortletParameters.ParameterFilter filter)
Parses a query string into a map, using the specified encoding and optional parameter filter.

Parameters
queryString - the query string to parse, cannot be null
encoding - the encoding to use, cannot be null
filter - the parameter filter to use when constructing the map, which can rename parameters or eliminate them from the resulting map.


Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.