org.n52.oxf.util.web
Class MultimapRequestParameters

java.lang.Object
  extended by org.n52.oxf.util.web.MultimapRequestParameters
All Implemented Interfaces:
RequestParameters

public abstract class MultimapRequestParameters
extends Object
implements RequestParameters


Constructor Summary
protected MultimapRequestParameters()
           
 
Method Summary
 boolean addBulkParameterValues(String parameter, Iterable<String> values)
          Adds a bulk of parameter values to the given parameter.
 boolean addBulkParameterValues(String parameter, String... values)
          Adds a bulk of parameter values to the given parameter.
 boolean addNonEmpty(String key, String value)
          Adds a required parameter to the map doing a non-null check beforehand.
 boolean addParameterValue(String parameter, String value)
          Adds a new parameter value to the given parameter.
 boolean contains(String key)
          Checks if the given parameter is present in the assembly.
 boolean containsValue(String value)
          Checks if the assembly contains the given value.
 Iterable<String> getAllValues(String parameter)
          Get read-only access to all parameter values associated with the given parameter.
 Collection<String> getAvailableKeys()
          Returns all parameter keys available in this parameter assembly wrapped via Collections.unmodifiableCollection(Collection).
 String getSingleValue(String parameter)
          Gets the first parameter value for the given parameter.
 boolean hasMultipleValues(String parameter)
          Checks if the assembly has more than one parameter value associated to the given key.
 boolean isEmpty()
           
protected  boolean isEmptyString(String value)
           
protected  boolean isEmptyValue(String parameter)
          Checks if value of the given parameter is empty.
 boolean isSingleValue(String parameter)
          Checks if the assembly has exact one parameter value associated to the given key.
 boolean mergeWith(RequestParameters parameters)
          Merge the given parameter assembly with this instance.
 boolean overrideSingleValue(String parameter, String value)
          Overrides a a value already associated with the given parameter.
 boolean remove(String parameter, String value)
          Removes a particular parameter value for the given parameter.
 void removeAll()
          Performs a complete clean of this assembly instance.
 Collection<String> removeValues(String parameter)
          Removes all parameter values associated with the given parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.n52.oxf.util.web.RequestParameters
isValid
 

Constructor Detail

MultimapRequestParameters

protected MultimapRequestParameters()
Method Detail

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface RequestParameters
Returns:
true if there are no key-value pairs available, false if the assembly contains at least one key-value pair.

contains

public boolean contains(String key)
Description copied from interface: RequestParameters
Checks if the given parameter is present in the assembly.

Specified by:
contains in interface RequestParameters
Parameters:
key - the parameter name to check.
Returns:
true if the passed parameter has one or more associated value(s), false if parameter is not present.

containsValue

public boolean containsValue(String value)
Description copied from interface: RequestParameters
Checks if the assembly contains the given value. It does not play a role to which parameter the value may associated with.

Specified by:
containsValue in interface RequestParameters
Parameters:
value - the value to check.
Returns:
true if the passed value is available. false if no parameter is associated with the given value.

isSingleValue

public boolean isSingleValue(String parameter)
Description copied from interface: RequestParameters
Checks if the assembly has exact one parameter value associated to the given key. If the value is not present at all the method will return false. This method is not threadsafe, so do not expect it as a reliable check; other threads may have added new values in the meantime.

Specified by:
isSingleValue in interface RequestParameters
Parameters:
parameter - the parameter name to check.
Returns:
true if there is exact one value associated with the given parameter, false if there are more than one parameter value, or the parameter is not present.

hasMultipleValues

public boolean hasMultipleValues(String parameter)
Description copied from interface: RequestParameters
Checks if the assembly has more than one parameter value associated to the given key. If the value is not present at all the method will return false. This method is not threadsafe, so do not expect it as a reliable check; other threads may have added new values in the meantime.

Specified by:
hasMultipleValues in interface RequestParameters
Parameters:
parameter - the parameter name to check.
Returns:
true if more than one value is associated with the given parameter, false if there is only one parameter value, or the parameter is not present.

overrideSingleValue

public boolean overrideSingleValue(String parameter,
                                   String value)
Description copied from interface: RequestParameters
Overrides a a value already associated with the given parameter. Associated value(s) are removed first.If no value was associated with the parameter is will be just added to the assembly. In this case it will have the same effect as when calling RequestParameters.addParameterValue(String, String).

Note: If the given parameter is associated with multiple values, all values are removed.

Specified by:
overrideSingleValue in interface RequestParameters
Parameters:
parameter - the parameter which value shall be overridden.
value - the new value.
Returns:
true if the size of the assembly has changed.

getSingleValue

public String getSingleValue(String parameter)
Description copied from interface: RequestParameters
Gets the first parameter value for the given parameter. It is not guaranteed that, if multiple parameters are associated with the given parameter, always the same value is returned. It is meant as convenient method for parameters which have a cardinality of one, or it is clear that only one parameter value is associated with the parameter.

Note: If the given parameter is not contained by the assembly null will be returned! Any null value associated to a parameter will be hold as en empty string:

Specified by:
getSingleValue in interface RequestParameters
Parameters:
parameter - the parameter name to check.
Returns:
the first parameter value associated to the given parameter.
See Also:
to ensure if the parameter is contained by assembly.

getAllValues

public Iterable<String> getAllValues(String parameter)
Description copied from interface: RequestParameters
Get read-only access to all parameter values associated with the given parameter. If the parameter is not present in the assembly, the returned Iterable is one from an emtpy Collection.

Specified by:
getAllValues in interface RequestParameters
Parameters:
parameter - the parameter to check.
Returns:
read-only access on the parameter values associated with the given parameter.

addNonEmpty

public boolean addNonEmpty(String key,
                           String value)
Adds a required parameter to the map doing a non-null check beforehand.

Parameters:
key - the parameter's name.
value - the non-null value.
Returns:
if the assembly has changed.
Throws:
IllegalArgumentException - if the key's associated value is null or empty.

getAvailableKeys

public Collection<String> getAvailableKeys()
Description copied from interface: RequestParameters
Returns all parameter keys available in this parameter assembly wrapped via Collections.unmodifiableCollection(Collection).

Specified by:
getAvailableKeys in interface RequestParameters
Returns:
a read-only collection to all parameter keys added to this assembly.

mergeWith

public boolean mergeWith(RequestParameters parameters)
Description copied from interface: RequestParameters
Merge the given parameter assembly with this instance.

Specified by:
mergeWith in interface RequestParameters
Parameters:
parameters - the parameter assembly to merge with.
Returns:
true if the assembly has changed, false otherwise.

addParameterValue

public boolean addParameterValue(String parameter,
                                 String value)
Description copied from interface: RequestParameters
Adds a new parameter value to the given parameter. A parameter can have multiple parameter values associated with it. No replacement takes place when adding different values to exactly the same parameter key. If you want to remove a particular parameter value use RequestParameters.remove(String, String).

Note: null values are stored as empty Strings.

Specified by:
addParameterValue in interface RequestParameters
Parameters:
parameter - the parameter key.
value - the value to associate the with parameter.
Returns:
true if the assembly has changed (size has increased).

addBulkParameterValues

public boolean addBulkParameterValues(String parameter,
                                      String... values)
Description copied from interface: RequestParameters
Adds a bulk of parameter values to the given parameter. No replacements take place. If you want to remove a particular parameter value use RequestParameters.remove(String, String).

Note: null values are stored as empty Strings.

Specified by:
addBulkParameterValues in interface RequestParameters
Parameters:
parameter - the parameter key.
values - the values to associate with the parameter.
Returns:
true if the assembly has changed (size has increased).

addBulkParameterValues

public boolean addBulkParameterValues(String parameter,
                                      Iterable<String> values)
Description copied from interface: RequestParameters
Adds a bulk of parameter values to the given parameter. No replacements take place. If you want to remove a particular parameter value use RequestParameters.remove(String, String).

Note: null values are stored as empty Strings.

Specified by:
addBulkParameterValues in interface RequestParameters
Parameters:
parameter - the parameter key.
values - the values to associate with the parameter.
Returns:
true if the assembly has changed (size has increased).

remove

public boolean remove(String parameter,
                      String value)
Description copied from interface: RequestParameters
Removes a particular parameter value for the given parameter.

Specified by:
remove in interface RequestParameters
Parameters:
parameter - the parameter to remove the value from.
value - the value to remove.
Returns:
true if the assembly has changed, false otherwise.

removeValues

public Collection<String> removeValues(String parameter)
Description copied from interface: RequestParameters
Removes all parameter values associated with the given parameter.

Specified by:
removeValues in interface RequestParameters
Parameters:
parameter - the parameter to remove all values from.
Returns:
all parameters which were associated with the given parameter. Modifying the returned collection will not have any effect on the parameter assembly.

removeAll

public void removeAll()
Description copied from interface: RequestParameters
Performs a complete clean of this assembly instance.

Specified by:
removeAll in interface RequestParameters

isEmptyValue

protected boolean isEmptyValue(String parameter)
Checks if value of the given parameter is empty.

Parameters:
parameterName - the parameter name.
Returns:
true if parameter value is null or empty, false otherwise.

isEmptyString

protected boolean isEmptyString(String value)


Copyright © 2012-2013 52north.org. All Rights Reserved.