org.n52.oxf.util.web
Interface RequestParameters

All Known Implementing Classes:
MultimapRequestParameters

public interface RequestParameters

Represents an assembly of request parameters (key-value pairs). Multiple parameter values are allowed, i.e. one key can be associated to one or more parameter values. null values are hold as empty strings.


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 addParameterValue(String parameter, String value)
          Adds a new parameter value to the given parameter.
 boolean contains(String parameter)
          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()
           
 boolean isSingleValue(String parameter)
          Checks if the assembly has exact one parameter value associated to the given key.
 boolean isValid()
          Performs a check if this parameter assembly is valid according to a defined schema.
 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.
 

Method Detail

isValid

boolean isValid()
Performs a check if this parameter assembly is valid according to a defined schema.

Returns:
true if the assembly is valie, false otherwise.

isEmpty

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

contains

boolean contains(String parameter)
Checks if the given parameter is present in the assembly.

Parameters:
parameter - 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

boolean containsValue(String value)
Checks if the assembly contains the given value. It does not play a role to which parameter the value may associated with.

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

boolean isSingleValue(String parameter)
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.

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

boolean hasMultipleValues(String parameter)
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.

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

boolean overrideSingleValue(String parameter,
                            String value)
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 addParameterValue(String, String).

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

Parameters:
parameter - the parameter which value shall be overridden.
value - the new value.
Returns:
true if the size of the assembly has changed.

getSingleValue

String getSingleValue(String parameter)
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:

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.

getAvailableKeys

Collection<String> getAvailableKeys()
Returns all parameter keys available in this parameter assembly wrapped via Collections.unmodifiableCollection(Collection).

Returns:
a read-only collection to all parameter keys added to this assembly.

getAllValues

Iterable<String> getAllValues(String parameter)
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.

Parameters:
parameter - the parameter to check.
Returns:
read-only access on the parameter values associated with the given parameter.

mergeWith

boolean mergeWith(RequestParameters parameters)
Merge the given parameter assembly with this instance.

Parameters:
parameters - the parameter assembly to merge with.
Returns:
true if the assembly has changed, false otherwise.

addParameterValue

boolean addParameterValue(String parameter,
                          String value)
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 remove(String, String).

Note: null values are stored as empty Strings.

Parameters:
parameter - the parameter key.
value - the value to associate the with parameter.
Returns:
true if the assembly has changed (size has increased).

addBulkParameterValues

boolean addBulkParameterValues(String parameter,
                               String... values)
Adds a bulk of parameter values to the given parameter. No replacements take place. If you want to remove a particular parameter value use remove(String, String).

Note: null values are stored as empty Strings.

Parameters:
parameter - the parameter key.
values - the values to associate with the parameter.
Returns:
true if the assembly has changed (size has increased).

addBulkParameterValues

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

Note: null values are stored as empty Strings.

Parameters:
parameter - the parameter key.
values - the values to associate with the parameter.
Returns:
true if the assembly has changed (size has increased).

remove

boolean remove(String parameter,
               String value)
Removes a particular parameter value for the given parameter.

Parameters:
parameter - the parameter to remove the value from.
value - the value to remove.
Returns:
true if the assembly has changed, false otherwise.

removeValues

Collection<String> removeValues(String parameter)
Removes all parameter values associated with the given parameter.

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

void removeAll()
Performs a complete clean of this assembly instance.



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