public abstract class Parameters extends Object implements ParameterValueGroup, Cloneable
DefaultParameterValueGroup
javadoc for a description of the standard way to get and set a particular
parameter in a group. The remaining of this javadoc is specific to Apache SIS.
cast(…, Class)
for type safety with parameterized types.getMemberName(ParameterDescriptor)
for inter-operability between ISO 19111 and ISO 19115.getValueDomain(ParameterDescriptor)
for information purpose.copy(ParameterValueGroup, ParameterValueGroup)
for copying values into an existing instance.ParameterValue
interface.
Those methods are themselves inspired by JDK methods:
Parameters method | ParameterValue method | JDK methods |
---|---|---|
getValue(ParameterDescriptor) | getValue() | |
booleanValue(ParameterDescriptor) | booleanValue() | Boolean.booleanValue() |
intValue(ParameterDescriptor) | intValue() | Number.intValue() |
intValueList(ParameterDescriptor) | intValueList() | |
doubleValue(ParameterDescriptor) | doubleValue() | Number.doubleValue() |
doubleValueList(ParameterDescriptor) | doubleValueList() | |
stringValue(ParameterDescriptor) | stringValue() |
ParameterValueGroup.parameter(String)
method.
This Parameters
class provides alternative ways, using a ParameterDescriptor
argument
instead than a String
argument. Those descriptors provide additional information like the various
aliases under which the same parameter may be known.
By using this information, Parameters
can choose the most appropriate parameter name or alias
(by searching for a common authority)
when it delegates its work to the parameter(String)
method.
"semi_major"
.
But that parameter can also be named "semi_major_axis"
, "earth_radius"
or simply "a"
in other libraries. When fetching parameter values, we do not always know in advance which of the above-cited
names is recognized by an arbitrary ParameterValueGroup
instance.Parameters
uses also the descriptor information for applying type and unit conversions
(i.e. returned values are converted to the units of measurement specified by the given parameter descriptor).
ParameterValueGroup
interface
(this class is not named “AbstractParameterValueGroup
” for that reason).
Extending this class or extending Object
make almost no difference for implementors;
Parameters
purpose is mostly to extend the API for users convenience.
All methods in this class get their information from the ParameterValueGroup
methods.
In addition, unless otherwise specified, methods in this class is isolated from all others:
overriding one method has no impact on other methods.Defined in the sis-referencing
module
Modifier | Constructor and Description |
---|---|
protected |
Parameters()
For subclass constructors only.
|
Modifier and Type | Method and Description |
---|---|
boolean |
booleanValue(ParameterDescriptor<Boolean> parameter)
Returns the boolean value of the parameter identified by the given descriptor.
|
static <T> ParameterDescriptor<T> |
cast(ParameterDescriptor<?> descriptor,
Class<T> valueClass)
Casts the given parameter descriptor to the given type.
|
static <T> ParameterValue<T> |
cast(ParameterValue<?> parameter,
Class<T> valueClass)
Casts the given parameter value to the given type.
|
static Parameters |
castOrWrap(ParameterValueGroup parameters)
Returns the given parameter value group as a
Parameters instance. |
Parameters |
clone()
Returns a copy of this group of parameter values.
|
static void |
copy(ParameterValueGroup values,
ParameterValueGroup destination)
Copies the values of a parameter group into another parameter group.
|
double |
doubleValue(ParameterDescriptor<? extends Number> parameter)
Returns the floating point value of the parameter identified by the given descriptor.
|
double[] |
doubleValueList(ParameterDescriptor<double[]> parameter)
Returns the floating point values of the parameter identified by the given descriptor.
|
static GeneralParameterDescriptor[] |
getDescriptors(GeneralParameterValue... parameters)
Returns the descriptors of the given parameters, in the same order.
|
<T> T |
getMandatoryValue(ParameterDescriptor<T> parameter)
Returns the value of the parameter identified by the given descriptor, or throws an exception if none.
|
static MemberName |
getMemberName(ParameterDescriptor<?> parameter)
Gets the parameter name as an instance of
MemberName . |
<T> ParameterValue<T> |
getOrCreate(ParameterDescriptor<T> parameter)
Returns the parameter identified by the given descriptor.
|
<T> T |
getValue(ParameterDescriptor<T> parameter)
Returns the value of the parameter identified by the given descriptor, or
null if none. |
static Range<?> |
getValueDomain(ParameterDescriptor<?> descriptor)
Returns the domain of valid values defined by the given descriptor, or
null if none. |
int |
intValue(ParameterDescriptor<? extends Number> parameter)
Returns the integer value of the parameter identified by the given descriptor.
|
int[] |
intValueList(ParameterDescriptor<int[]> parameter)
Returns the integer values of the parameter identified by the given descriptor.
|
void |
print()
Prints a string representation of this group to the standard output stream.
|
String |
stringValue(ParameterDescriptor<? extends CharSequence> parameter)
Returns the string value of the parameter identified by the given descriptor.
|
String |
toString()
Returns a string representation of this group.
|
static Parameters |
unmodifiable(ParameterValueGroup parameters)
Returns the given parameter value group as an unmodifiable
Parameters instance. |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addGroup, getDescriptor, groups, parameter, values
public static Parameters unmodifiable(ParameterValueGroup parameters)
Parameters
instance.
If the given parameters is already an unmodifiable instance of Parameters
,
then it is returned as-is. Otherwise this method copies all parameter values in a new,
unmodifiable, parameter group instance.parameters
- the parameters to make unmodifiable, or null
.null
if the given argument was null.DefaultParameterValue.unmodifiable(ParameterValue)
public static Parameters castOrWrap(ParameterValueGroup parameters)
Parameters
instance.
If the given parameters is already an instance of Parameters
, then it is returned as-is.
Otherwise this method returns a wrapper which delegate all method invocations to the given instance.
This method provides a way to get access to the non-static Parameters
methods, like
getValue(ParameterDescriptor)
, for an arbitrary ParameterValueGroup
instance.
parameters
- the object to cast or wrap, or null
.Parameters
(may be the same reference),
or null
if the given argument was null.public static <T> ParameterDescriptor<T> cast(ParameterDescriptor<?> descriptor, Class<T> valueClass) throws ClassCastException
T
- the expected value class.descriptor
- the descriptor to cast, or null
.valueClass
- the expected value class.null
if the given descriptor was null.ClassCastException
- if the given descriptor does not have the expected value class.Class.cast(Object)
public static <T> ParameterValue<T> cast(ParameterValue<?> parameter, Class<T> valueClass) throws ClassCastException
T
- the expected value class.parameter
- the parameter to cast, or null
.valueClass
- the expected value class.null
if the given value was null.ClassCastException
- if the given value doesn't have the expected value class.Class.cast(Object)
public static GeneralParameterDescriptor[] getDescriptors(GeneralParameterValue... parameters)
null
, then this method returns null
.
null
, then the corresponding
element of the returned array is also null
.parameters
- the parameter values from which to get the descriptors, or null
.null
if the parameters
argument was null.public static MemberName getMemberName(ParameterDescriptor<?> parameter)
MemberName
.
This method performs the following checks:
MemberName
,
returns that primary name.MemberName
. If found, that alias is returned.DefaultTypeName
javadoc.CC_OperationParameter
) and the one
defined by ISO 19115 (namely SV_Parameter
).parameter
- the parameter from which to get the name (may be null
).null
if none.Names.createMemberName(CharSequence, String, CharSequence, Class)
public static Range<?> getValueDomain(ParameterDescriptor<?> descriptor)
null
if none.
This method performs the following operations:
DefaultParameterDescriptor
,
delegate to DefaultParameterDescriptor.getValueDomain()
.descriptor
- the parameter descriptor, or null
.null
if none.DefaultParameterDescriptor.getValueDomain()
public <T> T getValue(ParameterDescriptor<T> parameter) throws ParameterNotFoundException
null
if none.
This method uses the following information from the given parameter
descriptor:
ParameterValueGroup
, chosen as below:
ParameterDescriptor
are known in advance, for example in the
implementation of some coordinate
operation method. If the caller has no such ParameterDescriptor
at hand, then the
parameter(String)
method is probably more convenient.T
- the type of the parameter value.parameter
- the name or alias of the parameter to look for, together with the desired type and unit of value.null
).ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.getMandatoryValue(ParameterDescriptor)
,
getOrCreate(ParameterDescriptor)
,
DefaultParameterValueGroup.parameter(String)
,
DefaultParameterValue.getValue()
public <T> T getMandatoryValue(ParameterDescriptor<T> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
and verifies that the returned
value is non-null.T
- the type of the parameter value.parameter
- the name or alias of the parameter to look for, together with the desired type and unit of value.null
.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.getValue(ParameterDescriptor)
,
getOrCreate(ParameterDescriptor)
public boolean booleanValue(ParameterDescriptor<Boolean> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- the name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.booleanValue()
public int intValue(ParameterDescriptor<? extends Number> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- the name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.intValue()
public int[] intValueList(ParameterDescriptor<int[]> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- the name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.intValueList()
public double doubleValue(ParameterDescriptor<? extends Number> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this method
uses the given parameter
argument.
If the given descriptor supplies a unit of measurement, then the returned value will be converted into that unit.
parameter
- the name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.doubleValue(Unit)
public double[] doubleValueList(ParameterDescriptor<double[]> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this method
uses the given parameter
argument.
If the given descriptor supplies a unit of measurement, then the returned values will be converted into that unit.
parameter
- the name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.doubleValueList(Unit)
public String stringValue(ParameterDescriptor<? extends CharSequence> parameter) throws ParameterNotFoundException
getValue(ParameterDescriptor)
for more information about how this
method uses the given parameter
argument.parameter
- the name or alias of the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.IllegalStateException
- if the value is not defined and there is no default value.DefaultParameterValue.stringValue()
public <T> ParameterValue<T> getOrCreate(ParameterDescriptor<T> parameter) throws ParameterNotFoundException
The default implementation is equivalent to:
return cast(parameter(name), parameter.getValueClass());where
name
is a parameter
name
or alias chosen by the same algorithm than
getValue(ParameterDescriptor)
.T
- the type of the parameter value.parameter
- the parameter to look for.ParameterNotFoundException
- if the given parameter
name or alias is not legal for this group.getValue(ParameterDescriptor)
,
getMandatoryValue(ParameterDescriptor)
,
DefaultParameterValueGroup.parameter(String)
public Parameters clone()
clone
in interface GeneralParameterValue
clone
in interface ParameterValueGroup
clone
in class Object
copy(ParameterValueGroup, ParameterValueGroup)
public static void copy(ParameterValueGroup values, ParameterValueGroup destination) throws InvalidParameterNameException, InvalidParameterValueException
source
group shall be valid for the destination
group,
but the destination
may have more parameters.
Sub-groups are copied recursively.
A typical usage of this method is for transferring values from an arbitrary implementation to some specific implementation, or to a parameter group using a different but compatible descriptor.
values
- the parameters values to copy.destination
- where to copy the values.InvalidParameterNameException
- if a source
parameter name is unknown to the destination
.InvalidParameterValueException
- if the value of a source
parameter is invalid for the destination
.clone()
@Debug public String toString()
ParameterFormat
.
This method is for information purpose only and may change in future SIS version.
@Debug public void print()
This is a convenience method for debugging purpose and for console applications.
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.