Class CC_GeneralOperationParameter

java.lang.Object
javax.xml.bind.annotation.adapters.XmlAdapter<CC_GeneralOperationParameter,org.opengis.parameter.GeneralParameterDescriptor>
org.apache.sis.internal.jaxb.gco.PropertyType<CC_GeneralOperationParameter,org.opengis.parameter.GeneralParameterDescriptor>
org.apache.sis.internal.jaxb.referencing.CC_GeneralOperationParameter

public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralOperationParameter,org.opengis.parameter.GeneralParameterDescriptor>
JAXB adapter mapping implementing class to the GeoAPI interface. See package documentation for more information about JAXB and interface.

This class provides additional merge(…) methods for building a unique descriptor instance when the same descriptor is declared in more than one place in the GML document. Some examples of duplications are:

  • The descriptors listed under the <gml:group> element, which duplicate the descriptors listed under each <gml:parameterValue> element.
  • The descriptors declared in each parameter value of a SingleOperation, which duplicate the descriptors declared in the associated OperationMethod.
Since:
0.6
Version:
1.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final short
    The default value of minimumOccurs and maximumOccurs if the XML element is not provided.
    private static final String[]
    The properties to ignore in the descriptor parsed from GML when this descriptor is merged with a predefined descriptor.

    Fields inherited from class org.apache.sis.internal.jaxb.gco.PropertyType

    metadata
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Empty constructor for JAXB only.
    private
    CC_GeneralOperationParameter(org.opengis.parameter.GeneralParameterDescriptor parameter)
    Constructor for the wrap(GeneralParameterDescriptor) method only.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static <T> boolean
    containsAll(Collection<T> complete, Collection<T> provided)
    Returns true if the complete collection contains all elements in the provided collection, where each element have been converted to the canonical NamedIdentifier implementation for comparison purpose.
    private static <T> org.opengis.parameter.ParameterDescriptor<T>
    create(Map<String,?> merged, org.opengis.parameter.ParameterDescriptor<?> provided, org.opengis.parameter.ParameterDescriptor<T> complete)
    Creates a new descriptor with the same properties than the provided one, but completed with information not found in GML.
    protected Class<org.opengis.parameter.GeneralParameterDescriptor>
    Returns the GeoAPI interface which is bound by this adapter.
    Invoked by JAXB at marshalling time for getting the actual element to write inside the <gml:parameter> XML element.
    private static boolean
    isRestricted(org.opengis.parameter.ParameterDescriptor<?> descriptor)
    Returns true if the given descriptor is restricted to a constant value.
    (package private) static org.opengis.parameter.ParameterDescriptorGroup
    merge(Class<?> caller, Map<String,?> properties, Map<String,?> merged, int minimumOccurs, int maximumOccurs, org.opengis.parameter.GeneralParameterDescriptor[] provided, org.opengis.parameter.ParameterDescriptorGroup complete, boolean canSubstitute)
    Returns a descriptor with the given properties, completed with information not found in GML.
    (package private) static org.opengis.parameter.GeneralParameterDescriptor
    merge(org.opengis.parameter.GeneralParameterDescriptor provided, org.opengis.parameter.GeneralParameterDescriptor complete)
    Returns a descriptor with the same properties than the provided one, but completed with information not found in GML.
    private static <T> void
    mergeArrays(String key, Class<T> componentType, Collection<T> provided, Map<String,Object> merged, org.opengis.metadata.Identifier remove)
    Merges the property of type Collection identified by the given key.
    void
    Invoked by JAXB at unmarshalling time for storing the result temporarily.
    private static NamedIdentifier
    Given an Identifier or GenericName instance, returns that instance as a NamedIdentifier implementation.
    (package private) static void
    validate(org.opengis.parameter.GeneralParameterDescriptor descriptor, String parent, String property)
    Verifies that the given descriptor is non-null and contains at least a name.
    wrap(org.opengis.parameter.GeneralParameterDescriptor parameter)
    Invoked by PropertyType at marshalling time for wrapping the given value in a <gml:OperationParameter> or <gml:OperationParameterGroup> XML element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_OCCURRENCE

      public static final short DEFAULT_OCCURRENCE
      The default value of minimumOccurs and maximumOccurs if the XML element is not provided.
      See Also:
    • IGNORE_DURING_MERGE

      private static final String[] IGNORE_DURING_MERGE
      The properties to ignore in the descriptor parsed from GML when this descriptor is merged with a predefined descriptor. Remarks:
  • Constructor Details

    • CC_GeneralOperationParameter

      public CC_GeneralOperationParameter()
      Empty constructor for JAXB only.
    • CC_GeneralOperationParameter

      private CC_GeneralOperationParameter(org.opengis.parameter.GeneralParameterDescriptor parameter)
      Constructor for the wrap(GeneralParameterDescriptor) method only.
  • Method Details

    • getBoundType

      protected Class<org.opengis.parameter.GeneralParameterDescriptor> getBoundType()
      Returns the GeoAPI interface which is bound by this adapter. This method is indirectly invoked by the private constructor below, so it shall not depend on the state of this object.
      Specified by:
      getBoundType in class PropertyType<CC_GeneralOperationParameter,org.opengis.parameter.GeneralParameterDescriptor>
      Returns:
      GeneralParameterDescriptor.class
    • wrap

      protected CC_GeneralOperationParameter wrap(org.opengis.parameter.GeneralParameterDescriptor parameter)
      Invoked by PropertyType at marshalling time for wrapping the given value in a <gml:OperationParameter> or <gml:OperationParameterGroup> XML element.
      Specified by:
      wrap in class PropertyType<CC_GeneralOperationParameter,org.opengis.parameter.GeneralParameterDescriptor>
      Parameters:
      parameter - the element to marshal.
      Returns:
      a PropertyType wrapping the given the element.
    • getElement

      public AbstractParameterDescriptor getElement()
      Invoked by JAXB at marshalling time for getting the actual element to write inside the <gml:parameter> XML element. This is the value or a copy of the value given in argument to the wrap method.
      Returns:
      the element to be marshalled.
      See Also:
    • setElement

      public void setElement(AbstractParameterDescriptor parameter)
      Invoked by JAXB at unmarshalling time for storing the result temporarily.
      Parameters:
      parameter - the unmarshalled element.
    • validate

      static void validate(org.opengis.parameter.GeneralParameterDescriptor descriptor, String parent, String property)
      Verifies that the given descriptor is non-null and contains at least a name. This method is used after unmarshalling. We do this validation because parameter descriptors are mandatory and SIS classes need them. So we provide an error message here instead of waiting for a NullPointerException to occur in some arbitrary place.
      Parameters:
      descriptor - the descriptor to validate.
      parent - the name of the element to report as the parent of property.
      property - the name of the property to report as missing if an exception is thrown.
      Throws:
      GeodeticException - if the parameters are missing or invalid.
    • isRestricted

      private static boolean isRestricted(org.opengis.parameter.ParameterDescriptor<?> descriptor)
      Returns true if the given descriptor is restricted to a constant value. This constraint exists in some predefined map projections.
      Example: the "Latitude of natural origin" parameter of "Mercator (1SP)" projection is provided for completeness, but should never be different than zero in this particular projection (otherwise it would be a "Mercator (variant C)" projection). But if this parameter is nevertheless provided, the SIS implementation will use it. From this point of view, SIS is tolerant to non-zero value.

      If the GML document declares explicitly a restricted parameter, maybe it intends to use it with a non-zero value. Consequently, the merge(…) method will not propagate this restriction.

    • merge

      static org.opengis.parameter.GeneralParameterDescriptor merge(org.opengis.parameter.GeneralParameterDescriptor provided, org.opengis.parameter.GeneralParameterDescriptor complete)
      Returns a descriptor with the same properties than the provided one, but completed with information not found in GML. Those missing information are given by the complete descriptor, which may come from two sources:
      • The descriptor for a <gml:ParameterValue> element. Those descriptors are more complete than the ones provided by <gml:OperationParameter> elements alone because the parameter value allows SIS to infer the valueClass.
      • A predefined parameter descriptor from the org.apache.sis.internal.referencing.provider package.
      Parameters:
      provided - the descriptor unmarshalled from the GML document.
      complete - the descriptor to use for completing missing information.
      Returns:
      the descriptor to use. May be one of the arguments given to this method, or a new instance.
      See Also:
    • merge

      static org.opengis.parameter.ParameterDescriptorGroup merge(Class<?> caller, Map<String,?> properties, Map<String,?> merged, int minimumOccurs, int maximumOccurs, org.opengis.parameter.GeneralParameterDescriptor[] provided, org.opengis.parameter.ParameterDescriptorGroup complete, boolean canSubstitute)
      Returns a descriptor with the given properties, completed with information not found in GML. Those extra information are given by the complete descriptor.
      Parameters:
      caller - the public source class to report if a log message need to be emitted.
      properties - properties as declared in the GML document, to be used if complete is incompatible.
      merged - more complete properties, to be used if complete is compatible.
      minimumOccurs - value to assign to AbstractParameterDescriptor.getMinimumOccurs().
      maximumOccurs - value to assign to AbstractParameterDescriptor.getMaximumOccurs().
      provided - parameter descriptors declared in the GML document. This array will be overwritten.
      complete - more complete parameter descriptors.
      canSubstitute - true if this method is allowed to return complete.
      Returns:
      the parameter descriptor group to use (may be the complete instance).
      See Also:
    • create

      private static <T> org.opengis.parameter.ParameterDescriptor<T> create(Map<String,?> merged, org.opengis.parameter.ParameterDescriptor<?> provided, org.opengis.parameter.ParameterDescriptor<T> complete)
      Creates a new descriptor with the same properties than the provided one, but completed with information not found in GML. Those extra information are given by the complete descriptor.

      It is the caller's responsibility to construct the merged properties as a merge of the properties of the two given descriptors. This can be done with the help of mergeArrays(String, Class, Collection, Map, Identifier) among others.

    • containsAll

      private static <T> boolean containsAll(Collection<T> complete, Collection<T> provided)
      Returns true if the complete collection contains all elements in the provided collection, where each element have been converted to the canonical NamedIdentifier implementation for comparison purpose.
      Type Parameters:
      T - the type of elements in the collection.
      Parameters:
      complete - the collection which is expected to contains all elements.
      provided - the collection which may be a subset of complete.
      Returns:
      true if complete contains all provided elements.
    • mergeArrays

      private static <T> void mergeArrays(String key, Class<T> componentType, Collection<T> provided, Map<String,Object> merged, org.opengis.metadata.Identifier remove)
      Merges the property of type Collection identified by the given key. This is used when we cannot just substitute one collection by the other.
      Type Parameters:
      T - the type of elements in the array or collection.
      Parameters:
      key - the key where to fetch or store the array in the merged map.
      componentType - the type of elements in the array or collection.
      provided - the elements unmarshalled from the XML document.
      merged - the map used for completing missing information.
    • toNamedIdentifier

      private static NamedIdentifier toNamedIdentifier(Object name)
      Given an Identifier or GenericName instance, returns that instance as a NamedIdentifier implementation. The intent is to allow Object.equals(Object) and hash code to correctly recognize two names or identifiers as equal even if they are of different implementations.

      Note that NamedIdentifier is the type of unmarshalled names, aliases and identifiers. So this method should not create any new object in a majority of cases.