| java.lang.Object org.geotools.parameter.Parameters
Parameters | public class Parameters (Code) | | Utility class for methods helping implementing, and working with the
parameter API from
org.opengis.parameter package.
Design note
This class contains some methods working on a specific parameter in a group (e.g.
,
, etc.).
Parameters are identified by their
instead of
their full
object, because:
- The parameter descriptor may not be always available. For example a user may looks for
the
"semi_major" axis length (because it is documented in OGC specification under
that name) but doesn't know and doesn't care about who is providing the implementation. In
such case, he doesn't have the parameter's descriptor. He only have the parameter's name,
and creating a descriptor from that name (a descriptor independent of any implementation)
is tedious.
.
- Parameter descriptors are implementation-dependent. For example if a user searchs for
the above-cited
"semi_major" axis length using the
for this parameter, we will fail to find this parameter in any
alternative
ParameterValueGroup implementations. This is against GeoAPI's
inter-operability goal.
The above doesn't mean that parameter's descriptor should not be used. They are used for
inspecting meta-data about parameters, not as a key for searching parameters in a group.
Since each parameter's name should be unique in a given parameter group (because
is always 1 for single
parameter), the parameter name is a suffisient key.
since: 2.1 version: $Id: Parameters.java 27862 2007-11-12 19:51:19Z desruisseaux $ author: Jody Garnett (Refractions Research) author: Martin Desruisseaux |
Field Summary | |
public static ParameterDescriptorGroup | EMPTY_GROUP An empty parameter group. |
Method Summary | |
public static void | copy(ParameterValueGroup source, ParameterValueGroup target) Copies all parameter values from
source to
target . | public static boolean | ensureSet(ParameterValueGroup parameters, String name, double value, Unit unit, boolean force) Ensures that the specified parameter is set. | public static boolean | isValid(ParameterValue parameter) Checks a parameter value against its
.
This method takes care of handling checking arrays and collections against parameter
descriptor.
When the
is an array (like
double[].class ) or a
(like
List.class ),
the descriptor
,
and
will be used to check the elements.
Parameters: parameter - The parameter to test. | public static List | search(GeneralParameterValue param, String name, int maxDepth) Searchs all parameters with the specified name. | public static Map | toNameValueMap(GeneralParameterValue parameters, Map destination) Gets a flat view of
-
pairs. |
EMPTY_GROUP | public static ParameterDescriptorGroup EMPTY_GROUP(Code) | | An empty parameter group. This group contains no parameters.
|
copy | public static void copy(ParameterValueGroup source, ParameterValueGroup target)(Code) | | Copies all parameter values from
source to
target . A typical usage of
this method is for transfering values from an arbitrary implementation to some specific
implementation (e.g. a parameter group implementation backed by a
java.awt.image.renderable.ParameterBlock for image processing operations).
since: 2.2 |
ensureSet | public static boolean ensureSet(ParameterValueGroup parameters, String name, double value, Unit unit, boolean force)(Code) | | Ensures that the specified parameter is set. The
value is set if and only if
no value were already set by the user for the given
name .
The
force 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
force is
true , then the parameter is overridden with the specified
value . Otherwise,
the parameter is left unchanged but a warning is logged with the
Level.FINE FINE level.
Parameters: parameters - The set of projection parameters. Parameters: name - The parameter name to set. Parameters: value - The value to set, or to expect if the parameter is already set. Parameters: unit - The value unit. Parameters: force - true for forcing the parameter to the specified value is case of mismatch. true if the were a mismatch, or false if the parameters can beused with no change. |
isValid | public static boolean isValid(ParameterValue parameter)(Code) | | Checks a parameter value against its
.
This method takes care of handling checking arrays and collections against parameter
descriptor.
When the
is an array (like
double[].class ) or a
(like
List.class ),
the descriptor
,
and
will be used to check the elements.
Parameters: parameter - The parameter to test. true if parameter is valid. See Also: Parameter.ensureValidValue |
search | public static List search(GeneralParameterValue param, String name, int maxDepth)(Code) | | Searchs all parameters with the specified name. The given
name is compared against
parameter
GeneralParameterDescriptor.getName name and
GeneralParameterDescriptor.getAlias alias . This method search recursively
in subgroups up to the specified depth:
- If
maxDepth is equals to 0, then this method returns
param if and only if it matches the specified name.
- If
maxDepth is equals to 1 and
param is an instance of
ParameterDescriptorGroup , then this method checks all elements
in this group but not in subgroups.
- ...
- If
maxDepth is a high number (e.g. 100), then this method checks all elements
in all subgroups up to the specified depth, which is likely to be never reached. In
this case,
maxDepth can be seen as a safeguard against never ending loops, for
example if parameters graph contains cyclic entries.
Parameters: param - The parameter to inspect. Parameters: name - The name of the parameter to search for. See the class javadocfor a rational about the usage of name as a key instead of. The set (possibly empty) of parameters with the given name. |
toNameValueMap | public static Map toNameValueMap(GeneralParameterValue parameters, Map destination)(Code) | | Gets a flat view of
-
pairs. This method copies all parameter values into the supplied
destination 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. Parameters: destination - The destination map, or null for a default one. destination , or a new map if destination was null. |
|
|