Class CC_GeneralOperationParameter
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 associatedOperationMethod
.
- Since:
- 0.6
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final short
The default value ofminimumOccurs
andmaximumOccurs
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
ConstructorsModifierConstructorDescriptionEmpty constructor for JAXB only.private
CC_GeneralOperationParameter
(org.opengis.parameter.GeneralParameterDescriptor parameter) Constructor for thewrap(GeneralParameterDescriptor)
method only. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> boolean
containsAll
(Collection<T> complete, Collection<T> provided) Returnstrue
if thecomplete
collection contains all elements in theprovided
collection, where each element have been converted to the canonicalNamedIdentifier
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 theprovided
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) Returnstrue
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 theprovided
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 typeCollection
identified by the given key.void
setElement
(AbstractParameterDescriptor parameter) Invoked by JAXB at unmarshalling time for storing the result temporarily.private static NamedIdentifier
toNamedIdentifier
(Object name) Given anIdentifier
orGenericName
instance, returns that instance as aNamedIdentifier
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.protected CC_GeneralOperationParameter
wrap
(org.opengis.parameter.GeneralParameterDescriptor parameter) Invoked byPropertyType
at marshalling time for wrapping the given value in a<gml:OperationParameter>
or<gml:OperationParameterGroup>
XML element.Methods inherited from class org.apache.sis.internal.jaxb.gco.PropertyType
accept2014, getActuate, getArcRole, getHRef, getNilReason, getRole, getShow, getTitle, getUUIDREF, incomplete, marshal, setActuate, setArcRole, setHRef, setNilReason, setRole, setShow, setTitle, setUUIDREF, unmarshal
-
Field Details
-
DEFAULT_OCCURRENCE
public static final short DEFAULT_OCCURRENCEThe default value ofminimumOccurs
andmaximumOccurs
if the XML element is not provided.- See Also:
-
IGNORE_DURING_MERGE
The properties to ignore in the descriptor parsed from GML when this descriptor is merged with a predefined descriptor. Remarks:- We ignore the name because the comparisons shall be performed by the caller with
IdentifiedObjects.isHeuristicMatchForName(org.opengis.referencing.IdentifiedObject, java.lang.String)
or something equivalent. - We ignore aliases and identifiers because they are collections, which require handling in a special way.
- We ignore the name because the comparisons shall be performed by the caller with
-
-
Constructor Details
-
CC_GeneralOperationParameter
public CC_GeneralOperationParameter()Empty constructor for JAXB only. -
CC_GeneralOperationParameter
private CC_GeneralOperationParameter(org.opengis.parameter.GeneralParameterDescriptor parameter) Constructor for thewrap(GeneralParameterDescriptor)
method only.
-
-
Method Details
-
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 classPropertyType<CC_GeneralOperationParameter,
org.opengis.parameter.GeneralParameterDescriptor> - Returns:
GeneralParameterDescriptor.class
-
wrap
protected CC_GeneralOperationParameter wrap(org.opengis.parameter.GeneralParameterDescriptor parameter) Invoked byPropertyType
at marshalling time for wrapping the given value in a<gml:OperationParameter>
or<gml:OperationParameterGroup>
XML element.- Specified by:
wrap
in classPropertyType<CC_GeneralOperationParameter,
org.opengis.parameter.GeneralParameterDescriptor> - Parameters:
parameter
- the element to marshal.- Returns:
- a
PropertyType
wrapping the given the element.
-
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 thewrap
method.- Returns:
- the element to be marshalled.
- See Also:
-
setElement
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 aNullPointerException
to occur in some arbitrary place.- Parameters:
descriptor
- the descriptor to validate.parent
- the name of the element to report as the parent ofproperty
.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) Returnstrue
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 theprovided
one, but completed with information not found in GML. Those missing information are given by thecomplete
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 thevalueClass
. - 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:
- The descriptor for a
-
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 thecomplete
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 ifcomplete
is incompatible.merged
- more complete properties, to be used ifcomplete
is compatible.minimumOccurs
- value to assign toAbstractParameterDescriptor.getMinimumOccurs()
.maximumOccurs
- value to assign toAbstractParameterDescriptor.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 returncomplete
.- 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 theprovided
one, but completed with information not found in GML. Those extra information are given by thecomplete
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 ofmergeArrays(String, Class, Collection, Map, Identifier)
among others. -
containsAll
Returnstrue
if thecomplete
collection contains all elements in theprovided
collection, where each element have been converted to the canonicalNamedIdentifier
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 ofcomplete
.- Returns:
true
ifcomplete
contains allprovided
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 typeCollection
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 themerged
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
Given anIdentifier
orGenericName
instance, returns that instance as aNamedIdentifier
implementation. The intent is to allowObject.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.
-