org.jboss.portal.common.util
Class ParameterMap
java.lang.Object
org.jboss.portal.common.util.AbstractTypedMap<java.lang.String,java.lang.String[],java.lang.String,java.lang.String[]>
org.jboss.portal.common.util.ParameterMap
- All Implemented Interfaces:
- java.io.Serializable, java.util.Map<java.lang.String,java.lang.String[]>
public final class ParameterMap
- extends AbstractTypedMap<java.lang.String,java.lang.String[],java.lang.String,java.lang.String[]>
- implements java.io.Serializable
A decorator that enforce the map content to be . It also provides capabilities for
making a copy of the value either on a read or on a write.
- Version:
- $Revision: 6671 $
- Author:
- Julien Viet
- See Also:
- Serialized Form
|
Nested Class Summary |
static class |
ParameterMap.AccessMode
Defines how the state of the values of a parameter map are managed. |
| Nested classes/interfaces inherited from interface java.util.Map |
java.util.Map.Entry<K,V> |
|
Method Summary |
void |
append(java.util.Map<java.lang.String,java.lang.String[]> params)
Append the content of the argument map to that map. |
ParameterMap |
as(ParameterMap.AccessMode accessMode)
|
static ParameterMap |
clone(java.util.Map<java.lang.String,java.lang.String[]> map)
Copy the parameter map. |
static ParameterMap |
clone(java.util.Map<java.lang.String,java.lang.String[]> map,
ParameterMap.AccessMode accessMode)
Copy the parameter map. |
ParameterMap.AccessMode |
getAccessMode()
|
protected java.util.Map<java.lang.String,java.lang.String[]> |
getDelegate()
|
AbstractTypedMap.Converter<java.lang.String,java.lang.String> |
getKeyConverter()
|
java.lang.String |
getValue(java.lang.String name)
Return the parameter value or null if it does not exist. |
AbstractTypedMap.Converter<java.lang.String[],java.lang.String[]> |
getValueConverter()
|
java.lang.String[] |
getValues(java.lang.String name)
Return the parameter values or null if it does not exist. |
void |
setValue(java.lang.String name,
java.lang.String value)
Set the a parameter value. |
void |
setValues(java.lang.String name,
java.lang.String[] values)
Set the parameter values. |
java.lang.String |
toString()
|
static ParameterMap |
wrap(java.util.Map<java.lang.String,java.lang.String[]> map)
Safely wrap the map as a portlet parameters object. |
static ParameterMap |
wrap(java.util.Map<java.lang.String,java.lang.String[]> map,
ParameterMap.AccessMode accessMode)
Safely wrap the map as a portlet parameters object. |
| Methods inherited from class org.jboss.portal.common.util.AbstractTypedMap |
clear, containsKey, containsValue, convert, entrySet, equals, get, isEmpty, keySet, put, putAll, remove, replace, size, validate, values |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
hashCode |
ParameterMap
public ParameterMap()
ParameterMap
public ParameterMap(ParameterMap.AccessMode accessMode)
ParameterMap
public ParameterMap(java.util.Map<java.lang.String,java.lang.String[]> delegate)
ParameterMap
public ParameterMap(java.util.Map<java.lang.String,java.lang.String[]> delegate,
ParameterMap.AccessMode accessMode)
clone
public static ParameterMap clone(java.util.Map<java.lang.String,java.lang.String[]> map)
throws java.lang.NullPointerException,
java.lang.ClassCastException,
java.lang.IllegalArgumentException
- Copy the parameter map.
- Parameters:
map - the parameter map to copy
- Returns:
- a parameter map initialized from the argument map
- Throws:
java.lang.NullPointerException - if the map contains a null key or a null value
java.lang.IllegalArgumentException - if the map is null or it contains a value with a zero length array or a null
element in the array
java.lang.ClassCastException - if the map contains a key that is not a string or a value that is not a string
array
clone
public static ParameterMap clone(java.util.Map<java.lang.String,java.lang.String[]> map,
ParameterMap.AccessMode accessMode)
throws java.lang.NullPointerException,
java.lang.ClassCastException,
java.lang.IllegalArgumentException
- Copy the parameter map.
- Parameters:
map - the parameter map to copyaccessMode - the access mode
- Returns:
- a parameter map initialized from the argument map
- Throws:
java.lang.NullPointerException - if the map contains a null key or a null value
java.lang.IllegalArgumentException - if the map is null or it contains a value with a zero length array or a null
element in the array
java.lang.ClassCastException - if the map contains a key that is not a string or a value that is not a string
array
wrap
public static ParameterMap wrap(java.util.Map<java.lang.String,java.lang.String[]> map)
- Safely wrap the map as a portlet parameters object. If the map is already a parameter map object, just return
that object otherwise return a wrapper around the map.
- Parameters:
map - the map
- Returns:
- the portlet parameters
wrap
public static ParameterMap wrap(java.util.Map<java.lang.String,java.lang.String[]> map,
ParameterMap.AccessMode accessMode)
- Safely wrap the map as a portlet parameters object. If the map is already a parameter map object, just return
that object with the new access mode otherwise return a wrapper around the map.
- Parameters:
map - the mapaccessMode - the access mode
- Returns:
- the portlet parameters
getAccessMode
public ParameterMap.AccessMode getAccessMode()
as
public ParameterMap as(ParameterMap.AccessMode accessMode)
getKeyConverter
public AbstractTypedMap.Converter<java.lang.String,java.lang.String> getKeyConverter()
- Specified by:
getKeyConverter in class AbstractTypedMap<java.lang.String,java.lang.String[],java.lang.String,java.lang.String[]>
getValueConverter
public AbstractTypedMap.Converter<java.lang.String[],java.lang.String[]> getValueConverter()
- Specified by:
getValueConverter in class AbstractTypedMap<java.lang.String,java.lang.String[],java.lang.String,java.lang.String[]>
getDelegate
protected java.util.Map<java.lang.String,java.lang.String[]> getDelegate()
- Specified by:
getDelegate in class AbstractTypedMap<java.lang.String,java.lang.String[],java.lang.String,java.lang.String[]>
getValue
public java.lang.String getValue(java.lang.String name)
throws java.lang.IllegalArgumentException
- Return the parameter value or null if it does not exist.
- Parameters:
name - the parameter name
- Returns:
- the parameter value or null if it does not exist
- Throws:
java.lang.IllegalArgumentException - if the name is null
getValues
public java.lang.String[] getValues(java.lang.String name)
throws java.lang.IllegalArgumentException
- Return the parameter values or null if it does not exist.
- Parameters:
name - the value to get
- Returns:
- the parameter values
- Throws:
java.lang.IllegalArgumentException - if the name is null
setValue
public void setValue(java.lang.String name,
java.lang.String value)
throws java.lang.IllegalArgumentException
- Set the a parameter value.
- Parameters:
name - the parameter namevalue - the parameter value
- Throws:
java.lang.IllegalArgumentException - if the name or the value is null
setValues
public void setValues(java.lang.String name,
java.lang.String[] values)
throws java.lang.IllegalArgumentException
- Set the parameter values. This method does not make a defensive copy of the values.
- Parameters:
name - the parameter namevalues - the parameter values
- Throws:
java.lang.NullPointerException - if the name or the value is null
java.lang.IllegalArgumentException - if the name is null or the values is null or the values length is zero or contains a null element
append
public void append(java.util.Map<java.lang.String,java.lang.String[]> params)
throws java.lang.ClassCastException,
java.lang.NullPointerException,
java.lang.IllegalArgumentException
- Append the content of the argument map to that map. If both maps contains an entry sharing the same key, then the
string arrays or the two entries will be concatenated into a single array. Each entry present on the argument map
and not in the current map will be kept as is. The argument validation is performed before the state is updated.
- Parameters:
params - the parameters to appends
- Throws:
java.lang.NullPointerException - if the map contains a null key or a null value
java.lang.IllegalArgumentException - if the map is null or it contains a value with a zero length array or a null
element in the array
java.lang.ClassCastException - if the map contains a key that is not a string or a value that is not a string
array
toString
public java.lang.String toString()
- Overrides:
toString in class AbstractTypedMap<java.lang.String,java.lang.String[],java.lang.String,java.lang.String[]>
Copyright © 2008. All Rights Reserved.