org.geotools.parameter
Class ParameterGroup

Object
  extended by Formattable
      extended by AbstractParameter
          extended by ParameterGroup
All Implemented Interfaces:
Serializable, Cloneable, GeneralParameterValue, ParameterValueGroup
Direct Known Subclasses:
MatrixParameters

public class ParameterGroup
extends AbstractParameter
implements ParameterValueGroup

A group of related parameter values. The same group can be repeated more than once in an operation or higher level ParameterValueGroup, if those instances contain different values of one or more ParameterValues which suitably distinquish among those groups.

Since:
2.1
Author:
Martin Desruisseaux (IRD), Jody Garnett (Refractions Research)
See Also:
DefaultParameterDescriptorGroup, Parameter, Serialized Form
Module:
modules/library/referencing (gt-referencing.jar)

Field Summary
static ParameterValueGroup EMPTY
          An empty parameter value group.
 
Fields inherited from class Formattable
SINGLE_LINE
 
Constructor Summary
ParameterGroup(Map<String,?> properties, GeneralParameterValue[] values)
          Constructs a parameter group from the specified list of parameters.
ParameterGroup(ParameterDescriptorGroup descriptor)
          Constructs a parameter group from the specified descriptor.
ParameterGroup(ParameterDescriptorGroup descriptor, GeneralParameterValue[] values)
          Constructs a parameter group from the specified descriptor and list of parameters.
 
Method Summary
 ParameterValueGroup addGroup(String name)
          Creates a new group of the specified name.
 ParameterGroup clone()
          Returns a deep copy of this group of parameter values.
 boolean equals(Object object)
          Compares the specified object with this parameter for equality.
 ParameterDescriptorGroup getDescriptor()
          Returns the abstract definition of this group of parameters.
 List<ParameterValueGroup> groups(String name)
          Returns all subgroups with the specified name.
 int hashCode()
          Returns a hash value for this parameter.
 ParameterValue parameter(String name)
          Returns the value in this group for the specified identifier code.
 List<GeneralParameterValue> values()
          Returns the values in this group.
 
Methods inherited from class AbstractParameter
formatWKT, toString, write
 
Methods inherited from class Formattable
cleanupThreadLocals, toWKT, toWKT, toWKT
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static ParameterValueGroup EMPTY
An empty parameter value group. This group contains no parameter value.

Constructor Detail

ParameterGroup

public ParameterGroup(ParameterDescriptorGroup descriptor)
Constructs a parameter group from the specified descriptor. All parameter values will be initialized to their default value.

Parameters:
descriptor - The descriptor for this group.

ParameterGroup

public ParameterGroup(ParameterDescriptorGroup descriptor,
                      GeneralParameterValue[] values)
Constructs a parameter group from the specified descriptor and list of parameters.

Parameters:
descriptor - The descriptor for this group.
values - The list of parameter values.
Throws:
IllegalStateException - if the number of parameter occurences doesn't matches the number declared in the descriptor.

ParameterGroup

public ParameterGroup(Map<String,?> properties,
                      GeneralParameterValue[] values)
Constructs a parameter group from the specified list of parameters.

Parameters:
properties - The properties for the operation parameter group to construct from the list of parameters.
values - The list of parameter values.
Throws:
IllegalStateException - if the number of parameter occurences doesn't matches the number declared in the descriptor.
Method Detail

getDescriptor

public ParameterDescriptorGroup getDescriptor()
Returns the abstract definition of this group of parameters.

Specified by:
getDescriptor in interface GeneralParameterValue
Specified by:
getDescriptor in interface ParameterValueGroup
Overrides:
getDescriptor in class AbstractParameter

values

public List<GeneralParameterValue> values()
Returns the values in this group. Changes in this list are reflected on this ParameterValueGroup. The returned list supports the add operation.

Specified by:
values in interface ParameterValueGroup

parameter

public ParameterValue parameter(String name)
                         throws ParameterNotFoundException
Returns the value in this group for the specified identifier code. If no parameter value is found but a parameter descriptor is found (which may occurs if the parameter is optional, i.e. minimumOccurs == 0), then a parameter value is automatically created and initialized to its default value (if any).

This convenience method provides a way to get and set parameter values by name. For example the following idiom fetches a floating point value for the "false_easting" parameter:

double value = parameter("false_easting").doubleValue();

This method do not search recursively in subgroups. This is because more than one subgroup may exist for the same descriptor. The user must query all subgroups and select explicitly the appropriate one to use.

Specified by:
parameter in interface ParameterValueGroup
Parameters:
name - The case insensitive identifier code of the parameter to search for.
Returns:
The parameter value for the given identifier code.
Throws:
ParameterNotFoundException - if there is no parameter value for the given identifier code.

groups

public List<ParameterValueGroup> groups(String name)
                                 throws ParameterNotFoundException
Returns all subgroups with the specified name. This method do not create new groups. If the requested group is optional (i.e. minimumOccurs == 0) and no value were set, then this method returns an empty set.

Specified by:
groups in interface ParameterValueGroup
Parameters:
name - The case insensitive identifier code of the parameter group to search for.
Returns:
The set of all parameter group for the given identifier code.
Throws:
ParameterNotFoundException - if no descriptor was found for the given name.

addGroup

public ParameterValueGroup addGroup(String name)
                             throws ParameterNotFoundException,
                                    InvalidParameterCardinalityException
Creates a new group of the specified name. The specified name must be the identifier code of a descriptor group.

Specified by:
addGroup in interface ParameterValueGroup
Parameters:
name - The case insensitive identifier code of the parameter group to create.
Returns:
A newly created parameter group for the given identifier code.
Throws:
ParameterNotFoundException - if no descriptor was found for the given name.
InvalidParameterCardinalityException - if this parameter group already contains the maximum number of occurences of subgroups of the given name.

equals

public boolean equals(Object object)
Compares the specified object with this parameter for equality.

Overrides:
equals in class AbstractParameter
Parameters:
object - The object to compare to this.
Returns:
true if both objects are equal.

hashCode

public int hashCode()
Returns a hash value for this parameter.

Overrides:
hashCode in class AbstractParameter
Returns:
The hash code value. This value doesn't need to be the same in past or future versions of this class.

clone

public ParameterGroup clone()
Returns a deep copy of this group of parameter values. Included parameter values and subgroups are cloned recursively.

Specified by:
clone in interface GeneralParameterValue
Specified by:
clone in interface ParameterValueGroup
Overrides:
clone in class AbstractParameter
Returns:
A copy of this group of parameter values.


Copyright © 1996-2010 Geotools. All Rights Reserved.