public class PortletParametersWrapper extends Object implements PortletParameters
PortletParametersWrapper
provides a convenient
implementation of the PortletParameters
interface
that can be subclassed by developers.
This class implements the Wrapper or Decorator pattern.
Methods default to calling through to the wrapped request object.
Modifier and Type | Field and Description |
---|---|
protected PortletParameters |
wrapped |
Constructor and Description |
---|
PortletParametersWrapper(PortletParameters wrapped) |
Modifier and Type | Method and Description |
---|---|
MutablePortletParameters |
clone()
Returns a
MutablePortletParameters object encapsulating a copy of the same
parameters as the original object. |
Set<String> |
getNames()
Returns a
Set of String
objects containing the names of the parameters contained
in this object. |
String |
getValue(String name)
Returns the value of a parameter as a
String . |
String[] |
getValues(String name)
Returns an array of
String objects containing
all of the values the given parameter, or
null if the parameter does not exist. |
PortletParameters |
getWrapped()
Gets the wrapped object.
|
boolean |
isEmpty()
Returns a
true if no parameters have been set. |
void |
setWrapped(PortletParameters wrapped)
Sets the wrapped object.
|
int |
size()
Returns the number of parameters in this object.
|
protected PortletParameters wrapped
public PortletParametersWrapper(PortletParameters wrapped)
wrapped
- the wrapped object to set.IllegalArgumentException
- if the PortletParameters is null.public PortletParameters getWrapped()
public void setWrapped(PortletParameters wrapped)
wrapped
- the wrapped object to set.IllegalArgumentException
- if the PortletParameters is null.public String getValue(String name)
PortletParameters
String
.
Note that null
is a valid parameter value.
To determine whether a
parameter is present, use the Set.contains(Object)
method on the set returned by PortletParameters.getNames()
.
Only parameters targeted to the current portlet are accessible.
This method should only be used if the
parameter has only one value. If the parameter might have
more than one value, use PortletParameters.getValues(java.lang.String)
.
If this method is used with a multivalued
parameter, the value returned is equal to the first value
in the array returned by getValues
.
getValue
in interface PortletParameters
name
- a String
specifying the
name of the parameterString
representing the
single value of the parameter, or null
.PortletParameters.getValues(java.lang.String)
,
PortletParameters.getNames()
public Set<String> getNames()
PortletParameters
Set
of String
objects containing the names of the parameters contained
in this object.
Changing the Set
has no effect on the originating
PortletParameters object.
Only parameter names targeted to the current portlet are returned.
getNames
in interface PortletParameters
Set
of String
objects, each String
containing
the name of a parameter; or an
empty Set
if the
PortletParameters object has no parameters.public String[] getValues(String name)
PortletParameters
String
objects containing
all of the values the given parameter, or
null
if the parameter does not exist.
If the parameter has a single value, the array has a length of 1.
Note that individual parameter values in the returned array
may be null
.
getValues
in interface PortletParameters
name
- a String
containing the name of
the parameter the value of which is requestedString
objects
containing the parameter values, or null
if the parameter does not exist.PortletParameters.getValue(java.lang.String)
public boolean isEmpty()
PortletParameters
true
if no parameters have been set.
isEmpty
in interface PortletParameters
true
if the object contains no parameters.
false
otherwisepublic int size()
PortletParameters
size
in interface PortletParameters
public MutablePortletParameters clone()
PortletParameters
MutablePortletParameters
object encapsulating a copy of the same
parameters as the original object.
Changing a mutable copy will not influence the source object.
clone
in interface PortletParameters
clone
in class Object
Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.