org.jboss.portal.common.util
Class ParameterMap

java.lang.Object
  extended by org.jboss.portal.common.util.TypedMap
      extended by org.jboss.portal.common.util.ParameterMap
All Implemented Interfaces:
java.util.Map
Direct Known Subclasses:
PortletParameters

public class ParameterMap
extends TypedMap

A decorator that enforce the map content to be

Version:
$Revision: 6671 $
Author:
Julien Viet

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.portal.common.util.TypedMap
TypedMap.KeySet, TypedMap.TypedEntrySet, TypedMap.ValueCollection
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.jboss.portal.common.util.TypedMap
accessor
 
Constructor Summary
ParameterMap()
           
ParameterMap(boolean cloneInternalValue, boolean cloneExternalValue)
           
ParameterMap(java.util.Map delegate)
           
ParameterMap(MapAccessor accessor)
           
ParameterMap(MapAccessor accessor, boolean cloneInternalValue, boolean cloneExternalValue)
           
ParameterMap(java.util.Map delegate, boolean cloneInternalValue, boolean cloneExternalValue)
           
 
Method Summary
protected  void assertKeyValidity(java.lang.Object value)
          Only accept non null string objects.
protected  java.lang.Object getExternalValue(java.lang.Object value)
          Wrap the internal value into its external representation.
protected  java.lang.Object getInternalValue(java.lang.Object value)
          Only check are made to the value.
 java.lang.String getValue(java.lang.String name)
          Return the parameter value or null if it does not exist.
 java.lang.String[] getValues(java.lang.String name)
          Return the parameter values or null if it does not exist.
protected  boolean internalValueEquals(java.lang.Object left, java.lang.Object right)
          Compare internal values, the default implementation delegates the operation to the equals method of the left argument.
 boolean isCloneInternalValue()
          Return true if values returned by the map are cloned.
 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.
 
Methods inherited from class org.jboss.portal.common.util.TypedMap
clear, containsKey, containsValue, convert, entrySet, equals, get, getDelegate, getExternalKey, getInternalKey, isEmpty, keySet, put, putAll, remove, replace, size, toString, unwrapKey, unwrapValue, validate, values, wrapKey, wrapValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
hashCode
 

Constructor Detail

ParameterMap

public ParameterMap(boolean cloneInternalValue,
                    boolean cloneExternalValue)

ParameterMap

public ParameterMap(MapAccessor accessor,
                    boolean cloneInternalValue,
                    boolean cloneExternalValue)

ParameterMap

public ParameterMap(java.util.Map delegate,
                    boolean cloneInternalValue,
                    boolean cloneExternalValue)

ParameterMap

public ParameterMap(MapAccessor accessor)

ParameterMap

public ParameterMap(java.util.Map delegate)

ParameterMap

public ParameterMap()
Method Detail

isCloneInternalValue

public boolean isCloneInternalValue()
Return true if values returned by the map are cloned.

Returns:
true if returned values are cloned

assertKeyValidity

protected void assertKeyValidity(java.lang.Object value)
                          throws java.lang.ClassCastException
Only accept non null string objects.

Overrides:
assertKeyValidity in class TypedMap
Throws:
java.lang.ClassCastException - if the value is not an instance of string

getInternalValue

protected java.lang.Object getInternalValue(java.lang.Object value)
                                     throws java.lang.NullPointerException,
                                            java.lang.ClassCastException,
                                            java.lang.IllegalArgumentException
Only check are made to the value. The only valid values accepted are string arrays with non zero length and containing non null values.

Overrides:
getInternalValue in class TypedMap
Parameters:
value - the value to unwrap
Returns:
the unwrapped value
Throws:
java.lang.NullPointerException - if the value is null
java.lang.ClassCastException - if the value type is not an array of string
java.lang.IllegalArgumentException - if the array length is zero or one of the array value is null

getExternalValue

protected java.lang.Object getExternalValue(java.lang.Object value)
Description copied from class: TypedMap
Wrap the internal value into its external representation. The external representation value should not be null. If it is not possible to obtain an external value representation of the internal value, then the the null value should be returned from this method.

Overrides:
getExternalValue in class TypedMap
Parameters:
value - the param value which will not be null
Returns:
the external value

internalValueEquals

protected boolean internalValueEquals(java.lang.Object left,
                                      java.lang.Object right)
Description copied from class: TypedMap
Compare internal values, the default implementation delegates the operation to the equals method of the left argument.

Overrides:
internalValueEquals in class TypedMap
Returns:
true if the values are equals

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.NullPointerException - if the name is null
java.lang.IllegalArgumentException

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.NullPointerException - if the name is null
java.lang.IllegalArgumentException

setValue

public void setValue(java.lang.String name,
                     java.lang.String value)
Set the a parameter value.

Parameters:
name - the parameter name
value - the parameter value
Throws:
java.lang.NullPointerException - if the name or the value is null

setValues

public void setValues(java.lang.String name,
                      java.lang.String[] values)
               throws java.lang.NullPointerException,
                      java.lang.IllegalArgumentException
Set the parameter values. This method does not make a defensive copy of the values.

Parameters:
name - the parameter name
values - the parameter values
Throws:
java.lang.NullPointerException - if the name or the value is null
java.lang.IllegalArgumentException - if the values length is zero or contains a null element