org.geotools.parameter
Class Parameters

java.lang.Object
  extended byorg.geotools.parameter.Parameters

public class Parameters
extends java.lang.Object

Utility class for methods helping implementing, and working with the parameter API from org.opengis.parameter package.

Version:
$Id$
Author:
Jody Garnett (Refractions Research), Martin Desruisseaux

Field Summary
static org.opengis.parameter.ParameterDescriptorGroup EMPTY_GROUP
          An empty parameter group.
 
Constructor Summary
Parameters()
           
 
Method Summary
static int count(org.opengis.parameter.ParameterValueGroup group, org.opengis.parameter.GeneralParameterDescriptor type)
          Deprecated. Use ParameterValueGroup.groups(type.getName().getCode()) instead. It allows to fetch groups by name independently of the actual descriptor implementation. The returned list can be used for many operation, including fetching the count with size().
static boolean ensureSet(org.opengis.parameter.ParameterValueGroup parameters, java.lang.String name, double value, javax.units.Unit unit, boolean force)
          Ensures that the specified parameter is set.
static int indexOf(org.opengis.parameter.ParameterValueGroup group, org.opengis.parameter.GeneralParameterDescriptor type)
          Deprecated. Use ParameterValueGroup.parameter(java.lang.String) or ParameterValueGroup.groups(java.lang.String) instead. We would like to encourage peoples to use parameter name as key instead of parameter descriptor, because the parameter descriptor may not be always available. For example if a user know he is looking for the "semi_major" axis length (because it is documented in OpenGIS specification under that name) but don't know and don't care about who is providing the implementation, then he doesn't have the parameter descriptor; he only have the parameter name. Furthermore, parameter descriptor is implementation dependent. For example if we search for the "semi_major" axis length using the Geotools descriptor for this parameter, we will fail to find this parameter in a ParameterValueGroup provided by an other implementation. This is against GeoAPI goal, which is inter-operability. This doesn't mean that parameter descriptor should not be used. They are used for inspecting meta-data about parameters, not for searching parameters. Since each parameter name should be unique in a given parameter group (because DefaultParameterDescriptor.getMaximumOccurs() is always 1 for single parameter), the parameter name is a suffisient key for searching.
static boolean isValid(org.opengis.parameter.ParameterValue parameter)
          Check a parameter value against its parameter descriptor.
static java.util.List list(org.opengis.parameter.ParameterValueGroup group, org.opengis.parameter.GeneralParameterDescriptor type)
          Deprecated. Use search(group, type.getName().getCode(), 1) instead. See comments in indexOf(org.opengis.parameter.ParameterValueGroup, org.opengis.parameter.GeneralParameterDescriptor) for a rational about why name should be used as key instead of parameter descriptor.
static java.util.List search(org.opengis.parameter.GeneralParameterValue param, java.lang.String name, int maxDepth)
          Search all parameters with the specified name.
static java.util.List search(org.opengis.parameter.ParameterValueGroup group, org.opengis.parameter.GeneralParameterDescriptor type)
          Deprecated. Use search(group, type.getName().getCode(), 100) instead. See comments in indexOf(org.opengis.parameter.ParameterValueGroup, org.opengis.parameter.GeneralParameterDescriptor) for a rational about why name should be used as key instead of parameter descriptor.
static java.util.Map toNameValueMap(org.opengis.parameter.GeneralParameterValue parameters, java.util.Map destination)
          Gets a flat view of name-value pairs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_GROUP

public static org.opengis.parameter.ParameterDescriptorGroup EMPTY_GROUP
An empty parameter group. This group contains no parameters.

Constructor Detail

Parameters

public Parameters()
Method Detail

count

public static int count(org.opengis.parameter.ParameterValueGroup group,
                        org.opengis.parameter.GeneralParameterDescriptor type)
Deprecated. Use ParameterValueGroup.groups(type.getName().getCode()) instead. It allows to fetch groups by name independently of the actual descriptor implementation. The returned list can be used for many operation, including fetching the count with size().

Number of type in group.

Parameters:
group -
type -
Returns:
count of type in group
See Also:
ParameterValueGroup.groups(java.lang.String)

isValid

public static boolean isValid(org.opengis.parameter.ParameterValue parameter)
Check a parameter value against its parameter descriptor. This method takes care of handling checking arrays and collections against parameter descriptor.

When the value class is an array (like ) or a collection (like ), the descriptor minimum value, maximum value and valid values will be used to check the elements.

Parameters:
parameter - The parameter to test.
Returns:
true if parameter is valid.
See Also:
Parameter.ensureValidValue(org.opengis.parameter.ParameterDescriptor, java.lang.Object)

indexOf

public static int indexOf(org.opengis.parameter.ParameterValueGroup group,
                          org.opengis.parameter.GeneralParameterDescriptor type)
Deprecated. Use ParameterValueGroup.parameter(java.lang.String) or ParameterValueGroup.groups(java.lang.String) instead. We would like to encourage peoples to use parameter name as key instead of parameter descriptor, because the parameter descriptor may not be always available. For example if a user know he is looking for the "semi_major" axis length (because it is documented in OpenGIS specification under that name) but don't know and don't care about who is providing the implementation, then he doesn't have the parameter descriptor; he only have the parameter name. Furthermore, parameter descriptor is implementation dependent. For example if we search for the "semi_major" axis length using the Geotools descriptor for this parameter, we will fail to find this parameter in a ParameterValueGroup provided by an other implementation. This is against GeoAPI goal, which is inter-operability. This doesn't mean that parameter descriptor should not be used. They are used for inspecting meta-data about parameters, not for searching parameters. Since each parameter name should be unique in a given parameter group (because DefaultParameterDescriptor.getMaximumOccurs() is always 1 for single parameter), the parameter name is a suffisient key for searching.

Search for an exact match for the provided GeneralParameterDescriptor.

This method does not search in subgroups.

Parameters:
type - GeneralParameterDescriptor to search for
Returns:
List (possibly empty of GeneralParameter

list

public static java.util.List list(org.opengis.parameter.ParameterValueGroup group,
                                  org.opengis.parameter.GeneralParameterDescriptor type)
Deprecated. Use search(group, type.getName().getCode(), 1) instead. See comments in indexOf(org.opengis.parameter.ParameterValueGroup, org.opengis.parameter.GeneralParameterDescriptor) for a rational about why name should be used as key instead of parameter descriptor.

Search for an exact match for the provided GeneralParameterDescriptor.

This method does not search in subgroups.

Parameters:
type - GeneralParameterDescriptor to search for
Returns:
List (possibly empty) of GeneralParameter

search

public static java.util.List search(org.opengis.parameter.ParameterValueGroup group,
                                    org.opengis.parameter.GeneralParameterDescriptor type)
Deprecated. Use search(group, type.getName().getCode(), 100) instead. See comments in indexOf(org.opengis.parameter.ParameterValueGroup, org.opengis.parameter.GeneralParameterDescriptor) for a rational about why name should be used as key instead of parameter descriptor.

Search for an exact match for the provided GeneralParameterDescriptor.

This method does search in subgroups.

Parameters:
type - GeneralParameterDescriptor to search for
Returns:
List (possibly empty of GeneralParameter

search

public static java.util.List search(org.opengis.parameter.GeneralParameterValue param,
                                    java.lang.String name,
                                    int maxDepth)
Search all parameters with the specified name. The given is compared against parameter name and alias. This method search recursively in subgroups up to the specified depth:

Parameters:
param - The parameter to inspect.
name - The name of the parameter to search for.
Returns:
The set (possibly empty) of parameters with the given name.

toNameValueMap

public static java.util.Map toNameValueMap(org.opengis.parameter.GeneralParameterValue parameters,
                                           java.util.Map destination)
Gets a flat view of name-value pairs. This method copies all parameter values into the supplied map. Keys are parameter names as String objects, and values are parameter values as arbitrary objects. All subgroups (if any) are extracted recursively.

Parameters:
parameters - The parameters to extract values from.
destination - The destination map, or for a default one.
Returns:
[@code destination}, or a new map if was null.

ensureSet

public static boolean ensureSet(org.opengis.parameter.ParameterValueGroup parameters,
                                java.lang.String name,
                                double value,
                                javax.units.Unit unit,
                                boolean force)
Ensures that the specified parameter is set. The is set if and only if no value were already set by the user for the given .

The argument said what to do if the named parameter is already set. If the value matches, nothing is done in all case. If there is a mismatch and is , then the parameter is overriden with the specified . Otherwise, the parameter is left unchanged but a warning is logged with the FINE level.

Parameters:
parameters - The set of projection parameters.
name - The parameter name to set.
value - The value to set, or to expect if the parameter is already set.
unit - The value unit.
force - for forcing the parameter to the specified is case of mismatch.
Returns:
if the were a mismatch, or if the parameters can be used with no change.


Copyright © GeoTools. All Rights Reserved.