Author: desruisseaux
Date: Mon Aug 24 03:46:04 2015
New Revision: 1697310
URL: http://svn.apache.org/r1697310
Log:
Merge from the JDK7 branch. This merge contains:
- JAXB annotations for <gml:ParameterValue> support.
- An update for a GeoAPI change: upgrade of PassThroughOperation from ISO
19111:2003 to ISO 19111:2007.
Added:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
- copied, changed from r1697309,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameter.java
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameter.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/IntegerList.java
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/IntegerList.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
- copied, changed from r1697309,
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
sis/branches/JDK6/core/sis-referencing/src/test/resources/org/apache/sis/parameter/
- copied from r1697309,
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/parameter/
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/MeasureList.java
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/MeasureList.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/MeasureTest.java
- copied unchanged from r1697309,
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/MeasureTest.java
Removed:
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NameIterator.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 24 03:46:04 2015
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
-/sis/branches/JDK7:1394913-1695758
-/sis/branches/JDK8:1584960-1695754
+/sis/branches/JDK7:1394913-1697309
+/sis/branches/JDK8:1584960-1697308
/sis/trunk:1394364-1508466,1519089-1519674
Modified:
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -1269,7 +1269,7 @@ public class Formatter implements Locali
final boolean appendValue(final Object value) {
if (value.getClass().isArray()) {
appendSeparator();
- buffer.appendCodePoint(symbols.getOpenSequence());
+ elementStart =
buffer.appendCodePoint(symbols.getOpenSequence()).length();
final int length = Array.getLength(value);
for (int i=0; i<length; i++) {
appendAny(Array.get(value, i));
Copied:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
(from r1697309,
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java&r1=1697309&r2=1697310&rev=1697310&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -86,6 +86,7 @@ public final class CC_GeneralParameterVa
@XmlElement(name = "ParameterValue", type =
DefaultParameterValue.class),
@XmlElement(name = "ParameterValueGroup", type =
DefaultParameterValueGroup.class)
})
+ @SuppressWarnings({"rawtypes", "unchecked"})
public GeneralParameterValue getElement() {
final GeneralParameterValue metadata = this.metadata;
if (metadata instanceof DefaultParameterValue<?>) {
@@ -95,7 +96,7 @@ public final class CC_GeneralParameterVa
return (DefaultParameterValueGroup) metadata;
}
if (metadata instanceof ParameterValue) {
- return new DefaultParameterValue<>((ParameterValue<?>) metadata);
+ return new DefaultParameterValue((ParameterValue<?>) metadata);
}
if (metadata instanceof ParameterValueGroup) {
return new DefaultParameterValueGroup((ParameterValueGroup)
metadata);
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -22,7 +22,7 @@ import javax.measure.unit.Unit;
import org.opengis.referencing.datum.Ellipsoid;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.internal.jaxb.Context;
-import org.apache.sis.internal.jaxb.gco.Measure;
+import org.apache.sis.internal.jaxb.gml.Measure;
import org.apache.sis.util.resources.Errors;
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -26,6 +26,8 @@ import org.opengis.metadata.extent.Exten
import org.apache.sis.xml.NilReason;
import org.apache.sis.xml.NilObject;
import org.apache.sis.io.wkt.UnformattableObjectException;
+import org.apache.sis.referencing.NamedIdentifier;
+import org.apache.sis.util.resources.Vocabulary;
/**
@@ -36,11 +38,25 @@ import org.apache.sis.io.wkt.Unformattab
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
public final class NilReferencingObject implements NilObject, ReferenceSystem {
/**
+ * The default name of {@code NilReferencingObject} instances.
+ * We use this value because {@link ReferenceSystem#getName()}
+ * is a mandatory property and not all code is tolerant to null name.
+ *
+ * <div class="note"><b>Note:</b>
+ * in theory we do not need a default name because it will be replaced by
+ * the value of the {@code <gml:name>} element anyway at XML unmarshalling
time.
+ * But not all XML documents are valid, so the {@code <gml:name>} may be
missing.</div>
+ *
+ * @since 0.6
+ */
+ public static final Identifier UNNAMED = new NamedIdentifier(null,
Vocabulary.format(Vocabulary.Keys.Unnamed));
+
+ /**
* The unique instance.
*/
public static final NilReferencingObject INSTANCE = new
NilReferencingObject();
@@ -64,7 +80,7 @@ public final class NilReferencingObject
* Returning null for collection are okay in the particular case of SIS
implementation,
* because the constructor will replace empty collections by null
references anyway.
*/
- @Override public Identifier getName() {return null;}
+ @Override public Identifier getName() {return
UNNAMED;}
@Override public Collection<GenericName> getAlias() {return null;}
@Override public Set<Identifier> getIdentifiers() {return null;}
@Override public InternationalString getRemarks() {return null;}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -18,6 +18,8 @@ package org.apache.sis.internal.referenc
import java.util.Collection;
import org.apache.sis.internal.jaxb.TypeRegistration;
+import org.apache.sis.parameter.DefaultParameterValue;
+import org.apache.sis.parameter.DefaultParameterValueGroup;
import org.apache.sis.referencing.AbstractIdentifiedObject;
@@ -37,5 +39,7 @@ public final class ReferencingTypes exte
@Override
public void getTypes(final Collection<Class<?>> addTo) {
addTo.add(AbstractIdentifiedObject.class);
+ addTo.add(DefaultParameterValue.class);
+ addTo.add(DefaultParameterValueGroup.class);
}
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -28,7 +28,6 @@ import org.opengis.referencing.datum.Pri
import org.apache.sis.util.Static;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.referencing.datum.DefaultPrimeMeridian;
@@ -210,7 +209,7 @@ public final class ReferencingUtilities
return (GeographicCRS) crs;
}
return new DefaultGeographicCRS(
- singletonMap(DefaultGeographicCRS.NAME_KEY,
Vocabulary.format(Vocabulary.Keys.Unnamed)),
+ singletonMap(DefaultGeographicCRS.NAME_KEY,
NilReferencingObject.UNNAMED),
((GeodeticCRS) crs).getDatum(), (EllipsoidalCS) cs);
}
if (crs instanceof CompoundCRS) {
@@ -268,7 +267,7 @@ public final class ReferencingUtilities
/**
* Ensures that the given argument value is {@code false}. This method is
invoked by private setter methods,
* which are themselves invoked by JAXB at unmarshalling time. Invoking
this method from those setter methods
- * serves two purposes:
+ * serves three purposes:
*
* <ul>
* <li>Make sure that a singleton property is not defined twice in the
XML document.</li>
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -17,7 +17,10 @@
package org.apache.sis.parameter;
import java.util.Map;
-import org.opengis.util.InternationalString;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlSchemaType;
import org.opengis.parameter.ParameterDirection;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
@@ -91,9 +94,17 @@ import org.apache.sis.internal.jdk7.Obje
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.6
* @module
*/
+@XmlType(name = "AbstractGeneralOperationParameterType", propOrder = {
+ "nonDefaultMinimumOccurs",
+ "nonDefaultMaximumOccurs"
+})
+@XmlSeeAlso({
+ DefaultParameterDescriptor.class,
+ DefaultParameterDescriptorGroup.class
+})
public abstract class AbstractParameterDescriptor extends
AbstractIdentifiedObject implements GeneralParameterDescriptor {
/**
* Serial number for inter-operability with different versions.
@@ -104,8 +115,11 @@ public abstract class AbstractParameterD
* The minimum number of times that values for this parameter group are
required, as an unsigned short.
* We use a short because this value is usually either 0 or 1, or a very
small number like 2 or 3.
* A large number would be a bad idea with this parameter implementation.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link
#setNonDefaultMinimumOccurs(Integer)}</p>
*/
- private final short minimumOccurs;
+ private short minimumOccurs;
/**
* The maximum number of times that values for this parameter group are
required, as an unsigned short.
@@ -113,8 +127,22 @@ public abstract class AbstractParameterD
*
* <p>We use a short because this value is usually 1 or a very small
number like 2 or 3. This also serve
* as a safety since a large number would be a bad idea with this
parameter implementation.</p>
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link
#setNonDefaultMaximumOccurs(Integer)}</p>
+ */
+ private short maximumOccurs;
+
+ /**
+ * Constructs a new object in which every attributes are set to a null
value.
+ * <strong>This is not a valid object.</strong> This constructor is
strictly
+ * reserved to JAXB, which will assign values to the fields using
reflexion.
*/
- private final short maximumOccurs;
+ AbstractParameterDescriptor() {
+
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
+ minimumOccurs = 1; // Default value is XML element is omitted.
+ maximumOccurs = 1;
+ }
/**
* Constructs a parameter descriptor from a set of properties. The
properties map is given unchanged to the
@@ -168,7 +196,7 @@ public abstract class AbstractParameterD
}
if (maximumOccurs > 0xFFFE && maximumOccurs != Integer.MAX_VALUE) {
throw new
IllegalArgumentException(Errors.getResources(properties).getString(
- Errors.Keys.TooManyOccurrences_2, 0xFFFE,
super.getName()));
+ Errors.Keys.TooManyOccurrences_2, 0xFFFE,
super.getName().getCode()));
}
}
@@ -187,6 +215,10 @@ public abstract class AbstractParameterD
maximumOccurs = crop(descriptor.getMaximumOccurs());
}
+ // NOTE: There is no 'castOrCopy' static method in this class because
AbstractParameterDescriptor is abstract.
+ // If nevertheless we choose to add such method in the future, then
CC_GeneralOperationParameter.getElement()
+ // should be simplified.
+
/**
* Crops the given integer in the [0 … 0xFFFF] range.
*/
@@ -218,18 +250,6 @@ public abstract class AbstractParameterD
}
/**
- * Returns a narrative explanation of the role of the parameter. The
default implementation returns
- * the {@linkplain
org.apache.sis.metadata.iso.ImmutableIdentifier#getDescription() description}
- * provided by the parameter {@linkplain #getName() name}.
- *
- * @return A narrative explanation of the role of the parameter, or {@code
null} if none.
- */
- @Override
- public InternationalString getDescription() {
- return getName().getDescription();
- }
-
- /**
* The minimum number of times that values for this parameter group or
parameter are required.
* A value of 0 means an optional parameter.
*
@@ -348,4 +368,48 @@ public abstract class AbstractParameterD
}
return WKTKeywords.Parameter;
}
+
+ // ---- XML SUPPORT ----------------------------------------------------
+
+ /**
+ * Invoked by JAXB for marshalling the {@link #minimumOccurs} value. Omit
marshalling of this
+ * {@code gml:minimumOccurs} element if its value is equals to the default
value, which is 1.
+ */
+ @XmlElement(name = "minimumOccurs")
+ @XmlSchemaType(name = "nonNegativeInteger")
+ private Integer getNonDefaultMinimumOccurs() {
+ final int n = getMinimumOccurs();
+ return (n != 1) ? n : null;
+ }
+
+ /**
+ * Invoked by JAXB for marshalling the {@link #maximumOccurs} value. Omit
marshalling of this
+ * {@code gml:maximumOccurs} element if its value is equals to the default
value, which is 1.
+ *
+ * <p>This property should not be marshalled in {@link
DefaultParameterDescriptor} objects (the GML schema
+ * does not allow that). It should be marshalled only for {@link
DefaultParameterDescriptorGroup} objects.
+ * Since SIS marshals {@code minimumOccurs} and {@code maximumOccurs}
properties only when their value is
+ * different than 1, and since {@code ParameterDescriptor} should not have
a {@code maximumOccurs} value
+ * different than 1 when ISO 19111 compliance is desired, the GML document
should be valid in most cases.</p>
+ */
+ @XmlElement(name = "maximumOccurs")
+ @XmlSchemaType(name = "nonNegativeInteger")
+ private Integer getNonDefaultMaximumOccurs() {
+ final int n = getMaximumOccurs();
+ return (n != 1) ? n : null;
+ }
+
+ /**
+ * Invoked by JAXB for unmarshalling the {@link #minimumOccurs} value.
+ */
+ private void setNonDefaultMinimumOccurs(final Integer n) {
+ minimumOccurs = (n != null) ? crop(n) : 1;
+ }
+
+ /**
+ * Invoked by JAXB for unmarshalling the {@link #maximumOccurs} value.
+ */
+ private void setNonDefaultMaximumOccurs(final Integer n) {
+ maximumOccurs = (n != null) ? crop(n) : 1;
+ }
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -19,6 +19,8 @@ package org.apache.sis.parameter;
import java.util.Arrays;
import java.util.Set;
import java.util.Map;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import javax.measure.unit.Unit;
import org.opengis.util.CodeList;
import org.opengis.parameter.ParameterValue;
@@ -31,6 +33,9 @@ import org.apache.sis.measure.Range;
import org.apache.sis.measure.MeasurementRange;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.gco.PropertyType;
+import org.apache.sis.internal.jaxb.referencing.CC_OperationParameter;
import org.apache.sis.referencing.IdentifiedObjects;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -64,12 +69,14 @@ import org.apache.sis.internal.jdk7.Obje
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Johann Sorel (Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.6
* @module
*
* @see DefaultParameterValue
* @see DefaultParameterDescriptorGroup
*/
+@XmlType(name = "OperationParameterType")
+@XmlRootElement(name = "OperationParameter")
public class DefaultParameterDescriptor<T> extends AbstractParameterDescriptor
implements ParameterDescriptor<T> {
/**
* Serial number for inter-operability with different versions.
@@ -85,7 +92,7 @@ public class DefaultParameterDescriptor<
/**
* A set of valid values (usually from a {@linkplain CodeList code list})
- * or {@code null} if it doesn't apply. This set is immutable.
+ * or {@code null} if it does not apply. This set is immutable.
*
* @see #getValidValues()
*/
@@ -114,6 +121,37 @@ public class DefaultParameterDescriptor<
private final T defaultValue;
/**
+ * Constructs a new object in which every attributes are set to a null
value.
+ * <strong>This is not a valid object.</strong> This constructor is
strictly
+ * reserved to JAXB, which will assign values to the fields using
reflexion.
+ *
+ * <p>This constructor fetches the value class and the unit of measurement
from the enclosing
+ * {@link DefaultParameterValue}, if presents, because those information
are not presents in GML.
+ * They are GeoAPI additions.</p>
+ */
+ @SuppressWarnings("unchecked")
+ private DefaultParameterDescriptor() {
+ final PropertyType<?,?> wrapper =
Context.getWrapper(Context.current());
+ if (wrapper instanceof CC_OperationParameter) {
+ final CC_OperationParameter param = (CC_OperationParameter)
wrapper;
+ /*
+ * This unsafe cast would be forbidden if this constructor was
public or used in any context where the
+ * user can choose the value of <T>. But this constructor should
be invoked only during unmarshalling,
+ * after the creation of the ParameterValue (this is the reverse
creation order than what we normally
+ * do through the public API). The 'valueClass' should be
compatible with DefaultParameterValue.value,
+ * and the parameterized type visible to the user should be only
<?>.
+ */
+ valueClass = (Class) param.valueClass;
+ valueDomain = param.valueDomain;
+ } else {
+ valueClass = null;
+ valueDomain = null;
+ }
+ validValues = null;
+ defaultValue = null;
+ }
+
+ /**
* Constructs a descriptor from the given properties. The properties map
is given unchanged to the
* {@linkplain
AbstractParameterDescriptor#AbstractParameterDescriptor(Map, int, int)
super-class constructor}.
* The following table is a reminder of main (not all) properties:
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -21,6 +21,10 @@ import java.util.Set;
import java.util.List;
import java.util.HashSet;
import java.util.Collections;
+import java.util.LinkedHashMap;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.parameter.ParameterDirection;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptorGroup;
@@ -29,6 +33,7 @@ import org.opengis.parameter.ParameterNo
import org.opengis.parameter.InvalidParameterNameException;
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.internal.util.UnmodifiableArrayList;
+import org.apache.sis.util.collection.Containers;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ComparisonMode;
@@ -39,19 +44,23 @@ import static org.apache.sis.util.Utilit
/**
* The definition of a group of related parameters used by an operation method.
* {@code DefaultParameterDescriptorGroup} instances are immutable and thus
thread-safe.
- * Each map projection or process will typically defines a single static
{@code ParameterDescriptorGroup},
- * to be shared by all users of that projection or process.
*
* <div class="section">Instantiation</div>
- * Coordinate operation or process <em>implementors</em> may use the {@link
ParameterBuilder} class for making
- * their task easier.
+ * Parameter descriptors are usually pre-defined by the SIS library and
available through the following methods:
+ *
+ * <ul>
+ * <li>{@link
org.apache.sis.referencing.operation.DefaultOperationMethod#getParameters()}</li>
+ * </ul>
+ *
+ * If nevertheless a {@code ParameterDescriptorGroup} needs to be instantiated
directly,
+ * then the {@link ParameterBuilder} class may make the task easier.
*
* <div class="note"><b>Example:</b>
* The following example declares the parameters for a <cite>Mercator (variant
A)</cite> projection method
* valid from 80°S to 84°N on all the longitude range (±180°).
*
* {@preformat java
- * public class Mercator {
+ * class Mercator {
* static final ParameterDescriptorGroup PARAMETERS;
* static {
* ParameterBuilder builder = new ParameterBuilder();
@@ -73,23 +82,17 @@ import static org.apache.sis.util.Utilit
* }
* </div>
*
- * <div class="section">Usage</div>
- * Users can simply reference the descriptor provided par a coordinate
operation or process providers like below:
- *
- * {@preformat java
- * ParameterValueGroup parameters = Mercator.PARAMETERS.createValue();
- * // See DefaultParameterValueGroup for examples on 'parameters' usage.
- * }
- *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Johann Sorel (Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.6
* @module
*
* @see DefaultParameterValueGroup
* @see DefaultParameterDescriptor
*/
+@XmlType(name = "OperationParameterGroupType")
+@XmlRootElement(name = "OperationParameterGroup")
public class DefaultParameterDescriptorGroup extends
AbstractParameterDescriptor implements ParameterDescriptorGroup {
/**
* Serial number for inter-operability with different versions.
@@ -98,8 +101,22 @@ public class DefaultParameterDescriptorG
/**
* The {@linkplain #descriptors() parameter descriptors} for this group.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link
#setDescriptors(GeneralParameterDescriptor[])}</p>
+ *
+ * @see #descriptors()
+ */
+ private List<GeneralParameterDescriptor> descriptors;
+
+ /**
+ * Constructs a new object in which every attributes are set to a null
value or an empty list.
+ * <strong>This is not a valid object.</strong> This constructor is
strictly reserved to JAXB,
+ * which will assign values to the fields using reflexion.
*/
- private final List<GeneralParameterDescriptor> descriptors;
+ private DefaultParameterDescriptorGroup() {
+ descriptors = Collections.emptyList();
+ }
/**
* Constructs a parameter group from a set of properties. The properties
map is given unchanged to the
@@ -170,6 +187,8 @@ public class DefaultParameterDescriptorG
/**
* Ensures that the given name array does not contain duplicate values.
+ *
+ * @param properties The properties given to the constructor, or {@code
null} if unknown.
*/
private static void verifyNames(final Map<String,?> properties, final
GeneralParameterDescriptor[] parameters) {
for (int i=0; i<parameters.length; i++) {
@@ -178,7 +197,7 @@ public class DefaultParameterDescriptorG
for (int j=0; j<i; j++) {
if (IdentifiedObjects.isHeuristicMatchForName(parameters[j],
name)) {
throw new
InvalidParameterNameException(Errors.getResources(properties).getString(
- Errors.Keys.DuplicatedParameterName_4,
parameters[j].getName().getCode(), j, name, i),
+ Errors.Keys.DuplicatedParameterName_4,
Verifier.getDisplayName(parameters[j]), j, name, i),
name);
}
}
@@ -310,8 +329,9 @@ public class DefaultParameterDescriptorG
* @return The parameter descriptors in this group.
*/
@Override
+ @SuppressWarnings("ReturnOfCollectionOrArrayField")
public List<GeneralParameterDescriptor> descriptors() {
- return descriptors;
+ return descriptors; // Unmodifiable.
}
/**
@@ -347,8 +367,10 @@ public class DefaultParameterDescriptorG
return fallback;
}
throw new ParameterNotFoundException(ambiguity != null
- ? Errors.format(Errors.Keys.AmbiguousName_3,
fallback.getName(), ambiguity.getName(), name)
- : Errors.format(Errors.Keys.ParameterNotFound_2, getName(),
name), name);
+ ? Errors.format(Errors.Keys.AmbiguousName_3,
+ IdentifiedObjects.toString(fallback.getName()),
+ IdentifiedObjects.toString(ambiguity.getName()), name)
+ : Errors.format(Errors.Keys.ParameterNotFound_2,
Verifier.getDisplayName(this), name), name);
}
/**
@@ -396,4 +418,48 @@ public class DefaultParameterDescriptorG
protected long computeHashCode() {
return super.computeHashCode() + descriptors.hashCode();
}
+
+ // ---- XML SUPPORT ----------------------------------------------------
+
+ /**
+ * Invoked by JAXB for getting the parameters to marshal.
+ */
+ @XmlElement(name = "parameter", required = true)
+ private GeneralParameterDescriptor[] getDescriptors() {
+ final List<GeneralParameterDescriptor> descriptors = descriptors();
// Give to user a chance to override.
+ return descriptors.toArray(new
GeneralParameterDescriptor[descriptors.size()]);
+ }
+
+ /**
+ * Invoked by JAXB or by {@link DefaultParameterValueGroup} for setting
the unmarshalled parameters.
+ * If parameters already exist, them this method computes the union of the
two parameter collections
+ * with the new parameters having precedence over the old ones.
+ *
+ * <div class="note"><b>Rational:</b>
+ * this method is invoked twice during {@link DefaultParameterValueGroup}
unmarshalling:
+ * <ol>
+ * <li>First, this method is invoked during unmarshalling of this {@code
DefaultParameterDescriptorGroup}.
+ * But the value class of {@code ParameterDescriptor} components are
unknown because this information
+ * is not part of GML.</li>
+ * <li>Next, this method is invoked during unmarshalling of the {@code
DefaultParameterValueGroup} enclosing
+ * element with the descriptors found inside the {@code
ParameterValue} components. The later do have the
+ * {@code valueClass} information, so we want to use them in
replacement of descriptors of step 1.</li>
+ * </ol>
+ * </div>
+ */
+ final void setDescriptors(GeneralParameterDescriptor[] parameters) {
+ verifyNames(null, parameters);
+ if (!descriptors.isEmpty()) {
+ final Map<String,GeneralParameterDescriptor> union =
+ new
LinkedHashMap<String,GeneralParameterDescriptor>(Containers.hashMapCapacity(descriptors.size()));
+ for (final GeneralParameterDescriptor p : descriptors) {
+ union.put(p.getName().getCode(), p);
+ }
+ for (final GeneralParameterDescriptor p : parameters) {
+ union.put(p.getName().getCode(), p);
+ }
+ parameters = union.values().toArray(new
GeneralParameterDescriptor[union.size()]);
+ }
+ descriptors = asList(parameters);
+ }
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -21,6 +21,10 @@ import java.io.File;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
import javax.measure.unit.Unit;
import javax.measure.converter.UnitConverter;
import javax.measure.converter.ConversionException;
@@ -33,13 +37,17 @@ import org.apache.sis.io.wkt.Formattable
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.ElementKind;
+import org.apache.sis.internal.jaxb.gml.Measure;
+import org.apache.sis.internal.jaxb.gml.MeasureList;
import org.apache.sis.internal.referencing.WKTUtilities;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.internal.util.PatchedUnitFormat;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.LenientComparable;
+import org.apache.sis.util.ObjectConverters;
import org.apache.sis.util.resources.Errors;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -114,6 +122,11 @@ import org.apache.sis.internal.jdk7.Obje
* @see DefaultParameterDescriptor
* @see DefaultParameterValueGroup
*/
+@XmlType(name = "ParameterValueType", propOrder = {
+ "xmlValue",
+ "descriptor"
+})
+@XmlRootElement(name = "ParameterValue")
public class DefaultParameterValue<T> extends FormattableObject implements
ParameterValue<T>,
LenientComparable, Serializable, Cloneable
{
@@ -124,8 +137,13 @@ public class DefaultParameterValue<T> ex
/**
* The definition of this parameter.
+ *
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link
#setDescriptor(ParameterDescriptor)}</p>
+ *
+ * @see #getDescriptor()
*/
- private final ParameterDescriptor<T> descriptor;
+ private ParameterDescriptor<T> descriptor;
/**
* The value, or {@code null} if undefined.
@@ -142,6 +160,13 @@ public class DefaultParameterValue<T> ex
private Unit<?> unit;
/**
+ * Default constructor for JAXB only. The descriptor is initialized to
{@code null},
+ * but will be assigned a value after XML unmarshalling.
+ */
+ private DefaultParameterValue() {
+ }
+
+ /**
* Creates a parameter value from the specified descriptor.
* The value will be initialized to the default value, if any.
*
@@ -177,6 +202,7 @@ public class DefaultParameterValue<T> ex
* @return The definition of this parameter.
*/
@Override
+ @XmlElement(name = "operationParameter", required = true)
public ParameterDescriptor<T> getDescriptor() {
return descriptor;
}
@@ -352,7 +378,7 @@ public class DefaultParameterValue<T> ex
private UnitConverter getConverterTo(final Unit<?> unit) {
final Unit<?> source = getUnit();
if (source == null) {
- throw new
IllegalStateException(Errors.format(Errors.Keys.UnitlessParameter_1,
Verifier.getName(descriptor)));
+ throw new
IllegalStateException(Errors.format(Errors.Keys.UnitlessParameter_1,
Verifier.getDisplayName(descriptor)));
}
ensureNonNull("unit", unit);
final short expectedID = Verifier.getUnitMessageID(source);
@@ -470,7 +496,7 @@ public class DefaultParameterValue<T> ex
} catch (URISyntaxException exception) {
cause = exception;
}
- final String name = Verifier.getName(descriptor);
+ final String name = Verifier.getDisplayName(descriptor);
if (value != null) {
throw new InvalidParameterTypeException(getClassTypeError(), name);
}
@@ -488,7 +514,7 @@ public class DefaultParameterValue<T> ex
* Returns the exception to throw when an incompatible method is invoked
for the value type.
*/
private IllegalStateException missingOrIncompatibleValue(final Object
value) {
- final String name = Verifier.getName(descriptor);
+ final String name = Verifier.getDisplayName(descriptor);
if (value != null) {
return new InvalidParameterTypeException(getClassTypeError(),
name);
}
@@ -500,7 +526,7 @@ public class DefaultParameterValue<T> ex
*/
private String getClassTypeError() {
return Errors.format(Errors.Keys.IllegalOperationForValueClass_1,
- ((ParameterDescriptor<?>) descriptor).getValueClass());
+ (descriptor != null) ? ((ParameterDescriptor<?>)
descriptor).getValueClass() : "?");
}
/**
@@ -540,7 +566,7 @@ public class DefaultParameterValue<T> ex
public void setValue(final boolean value) throws
InvalidParameterValueException {
// Use 'unit' instead than 'getUnit()' despite class Javadoc claims
because units are not expected
// to be involved in this method. We just want the current unit
setting to be unchanged.
- setValue(Boolean.valueOf(value), unit);
+ setValue(value, unit);
}
/**
@@ -557,7 +583,7 @@ public class DefaultParameterValue<T> ex
*/
@Override
public void setValue(final int value) throws
InvalidParameterValueException {
- Number n = Integer.valueOf(value);
+ Number n = value;
final Class<T> valueClass = descriptor.getValueClass();
if (Number.class.isAssignableFrom(valueClass)) {
@SuppressWarnings("unchecked")
@@ -606,7 +632,7 @@ public class DefaultParameterValue<T> ex
// to be involved in this method. We just want the current unit
setting to be unchanged.
setValue(wrap(value, descriptor.getValueClass()), unit);
} catch (IllegalArgumentException e) {
- throw new InvalidParameterValueException(e.getLocalizedMessage(),
Verifier.getName(descriptor), value);
+ throw new InvalidParameterValueException(e.getLocalizedMessage(),
Verifier.getDisplayName(descriptor), value);
}
}
@@ -629,7 +655,7 @@ public class DefaultParameterValue<T> ex
try {
setValue(wrap(value, descriptor.getValueClass()), unit);
} catch (IllegalArgumentException e) {
- throw new InvalidParameterValueException(e.getLocalizedMessage(),
Verifier.getName(descriptor), value);
+ throw new InvalidParameterValueException(e.getLocalizedMessage(),
Verifier.getDisplayName(descriptor), value);
}
}
@@ -894,8 +920,9 @@ public class DefaultParameterValue<T> ex
* Note that we take the descriptor unit as a starting point
instead than this parameter unit
* in order to give precedence to the descriptor units in
Convention.WKT1_COMMON_UNITS mode.
*/
- Unit<?> contextualUnit = descriptor.getUnit();
- if (contextualUnit == null) { // Should be very rare (probably a
buggy descriptor), but we try to be safe.
+ Unit<?> contextualUnit;
+ if (descriptor == null || (contextualUnit = descriptor.getUnit())
== null) {
+ // Should be very rare (probably a buggy descriptor), but we
try to be safe.
contextualUnit = unit;
}
contextualUnit = formatter.toContextualUnit(contextualUnit);
@@ -915,7 +942,13 @@ public class DefaultParameterValue<T> ex
} catch (IllegalStateException exception) {
// May happen if a parameter is mandatory (e.g. "semi-major")
// but no value has been set for this parameter.
- formatter.setInvalidWKT(descriptor, exception);
+ if (descriptor != null) {
+ formatter.setInvalidWKT(descriptor, exception);
+ } else {
+ // Null descriptor should be illegal but may happen after
unmarshalling of invalid GML.
+ // We make this WKT formatting robust since it is used by
'toString()' implementation.
+ formatter.setInvalidWKT(DefaultParameterValue.class,
exception);
+ }
value = Double.NaN;
}
formatter.append(value);
@@ -933,7 +966,13 @@ public class DefaultParameterValue<T> ex
if (!isWKT1) {
formatter.append(unit);
} else if (!ignoreUnits) {
- formatter.setInvalidWKT(descriptor, null);
+ if (descriptor != null) {
+ formatter.setInvalidWKT(descriptor, null);
+ } else {
+ // Null descriptor should be illegal but may happen
after unmarshalling of invalid GML.
+ // We make this WKT formatting robust since it is used
by 'toString()' implementation.
+ formatter.setInvalidWKT(DefaultParameterValue.class,
null);
+ }
}
}
}
@@ -958,4 +997,100 @@ public class DefaultParameterValue<T> ex
return formatter.hasContextualUnit(1) || // In WKT1
formatter.hasContextualUnit(2); // In WKT2
}
+
+ // ---- XML SUPPORT ----------------------------------------------------
+
+ /**
+ * Invoked by JAXB for obtaining the object to marshal.
+ * The property name depends on its type after conversion by this method.
+ */
+ @XmlElements({
+ @XmlElement(name = "value", type = Measure.class),
+ @XmlElement(name = "integerValue", type = Integer.class),
+ @XmlElement(name = "booleanValue", type = Boolean.class),
+ @XmlElement(name = "stringValue", type = String .class),
+ @XmlElement(name = "valueFile", type = URI .class),
+ @XmlElement(name = "integerValueList", type = IntegerList.class),
+ @XmlElement(name = "valueList", type = MeasureList.class)
+ })
+ private Object getXmlValue() {
+ final Object value = getValue(); // Give to user a chance to
override.
+ if (value != null) {
+ if (value instanceof Number) {
+ final Number n = (Number) value;
+ if (Numbers.isInteger(n.getClass())) {
+ final int xmlValue = n.intValue();
+ if (xmlValue >= 0 && xmlValue == n.doubleValue()) {
+ return xmlValue;
+ }
+ }
+ return new Measure(((Number) value).doubleValue(), getUnit());
+ }
+ if (value instanceof CharSequence) {
+ return value.toString();
+ }
+ if (isFile(value)) {
+ return ObjectConverters.convert(value, URI.class);
+ }
+ final Class<?> type =
Numbers.primitiveToWrapper(value.getClass().getComponentType());
+ if (type != null && Number.class.isAssignableFrom(type)) {
+ if (Numbers.isInteger(type)) {
+ return new IntegerList(value);
+ }
+ return new MeasureList(value, type, getUnit());
+ }
+ }
+ return value;
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ */
+ @SuppressWarnings("unchecked")
+ private void setXmlValue(Object xmlValue) {
+ if (ReferencingUtilities.canSetProperty(DefaultParameterValue.class,
+ "setXmlValue", "value", value != null || unit != null))
+ {
+ if (xmlValue instanceof Measure) {
+ final Measure measure = (Measure) xmlValue;
+ xmlValue = measure.value;
+ unit = measure.unit;
+ } else if (xmlValue instanceof MeasureList) {
+ final MeasureList measure = (MeasureList) xmlValue;
+ xmlValue = measure.toArray();
+ unit = measure.unit;
+ } else if (xmlValue instanceof IntegerList) {
+ xmlValue = ((IntegerList) xmlValue).toArray();
+ }
+ if (descriptor != null) {
+ /*
+ * Should never happen with default SIS implementation, but
may happen if the user created
+ * a sub-type of DefaultParameterValue with a default
constructor providing the descriptor.
+ */
+ value = ObjectConverters.convert(xmlValue,
descriptor.getValueClass());
+ } else {
+ /*
+ * Temporarily accept the value without checking its type.
This is required because the
+ * descriptor is normally defined after the value in a GML
document. The type will need
+ * to be verified when the descriptor will be set.
+ *
+ * There is no way we can prove that this cast is correct
before the descriptor is set,
+ * and maybe that descriptor will never be set if the GML
document is illegal. However
+ * this code is executed only during XML unmarshalling, in
which case our unmarshalling
+ * process will construct a descriptor compatible with the
value rather than the converse.
+ */
+ value = (T) xmlValue;
+ }
+ }
+ }
+
+ /**
+ * Invoked by JAXB at unmarshalling time.
+ *
+ * @see #getDescriptor()
+ */
+ private void setDescriptor(final ParameterDescriptor<T> descriptor) {
+ this.descriptor = descriptor;
+ assert (value == null) || descriptor.getValueClass().isInstance(value)
: this;
+ }
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -18,7 +18,11 @@ package org.apache.sis.parameter;
import java.util.List;
import java.util.ArrayList;
+import java.util.Arrays;
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.parameter.ParameterValue;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.parameter.ParameterDescriptor;
@@ -27,6 +31,8 @@ import org.opengis.parameter.GeneralPara
import org.opengis.parameter.GeneralParameterDescriptor;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.parameter.InvalidParameterCardinalityException;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.util.LenientComparable;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.resources.Errors;
@@ -103,6 +109,11 @@ import org.apache.sis.internal.jdk7.Obje
* @see DefaultParameterDescriptorGroup
* @see DefaultParameterValue
*/
+@XmlType(name = "ParameterValueGroupType", propOrder = {
+ "values",
+ "descriptor"
+})
+@XmlRootElement(name = "ParameterValueGroup")
public class DefaultParameterValueGroup extends Parameters implements
LenientComparable, Serializable {
/**
* Serial number for inter-operability with different versions.
@@ -112,12 +123,23 @@ public class DefaultParameterValueGroup
/**
* Contains the descriptor and the {@linkplain #values() parameter values}
for this group.
*
- * <p>Consider this field as final. It is not for the purpose of {@link
#clone()}.</p>
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only by the {@link #clone()} method and
+ * at unmarshalling time by {@link #setValues(GeneralParameterValue[])}</p>
+ *
+ * @see #values()
*/
private ParameterValueList values;
/**
- * Constructs a parameter group from the specified descriptor.
+ * Default constructor for JAXB only. The values list is initialized to
{@code null},
+ * but will be assigned a value after XML unmarshalling.
+ */
+ private DefaultParameterValueGroup() {
+ }
+
+ /**
+ * Creates a parameter group from the specified descriptor.
*
* <p><b>Usage note:</b> {@code ParameterValueGroup} are usually not
instantiated directly. Instead, consider
* invoking <code>descriptor.{@linkplain
DefaultParameterDescriptorGroup#createValue() createValue()}</code>
@@ -131,6 +153,23 @@ public class DefaultParameterValueGroup
}
/**
+ * Creates a new instance initialized with all values from the specified
parameter group.
+ * This is a <em>shallow</em> copy constructor, since the values contained
in the given
+ * group is not cloned.
+ *
+ * @param parameters The parameters to copy values from.
+ *
+ * @see #clone()
+ *
+ * @since 0.6
+ */
+ public DefaultParameterValueGroup(final ParameterValueGroup parameters) {
+ ArgumentChecks.ensureNonNull("parameters", parameters);
+ values = new ParameterValueList(parameters.getDescriptor());
+ values.addAll(parameters.values());
+ }
+
+ /**
* Conservatively returns {@code false} if this instance is for a
subclass, because we do not know if the
* subclass overrides {@link #parameter(String)} in a way incompatible
with {@link #parameterIfExist(String)}.
* (note: using {@code Class.getMethod(…).getDeclaringClass()} is presumed
not worth the cost.
@@ -146,8 +185,11 @@ public class DefaultParameterValueGroup
* @return The abstract definition of this group of parameters.
*/
@Override
+ @XmlElement(name = "group")
public ParameterDescriptorGroup getDescriptor() {
- return values.descriptor;
+ // The descriptor is not allowed to be null, but this situation
+ // may exist temporarily during XML unmarshalling.
+ return (values != null) ? values.descriptor : null;
}
/**
@@ -169,8 +211,9 @@ public class DefaultParameterValueGroup
* @return The values in this group.
*/
@Override
+ @SuppressWarnings("ReturnOfCollectionOrArrayField")
public List<GeneralParameterValue> values() {
- return values;
+ return values; // Intentionally modifiable.
}
/**
@@ -224,7 +267,7 @@ public class DefaultParameterValueGroup
final GeneralParameterDescriptor descriptor =
values.descriptor.descriptor(name);
if (!(descriptor instanceof ParameterDescriptor<?>) ||
descriptor.getMaximumOccurs() == 0) {
throw new
ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,
- values.descriptor.getName(), name), name);
+ Verifier.getDisplayName(values.descriptor), name),
name);
}
/*
* Create the optional parameter and add it to our internal list.
Note that this is
@@ -283,7 +326,8 @@ public class DefaultParameterValueGroup
return (ParameterValue<?>) values.get(fallback); // May
lazily create a ParameterValue.
}
throw new
ParameterNotFoundException(Errors.format(Errors.Keys.AmbiguousName_3,
- values.descriptor(fallback).getName(),
values.descriptor(ambiguity).getName(), name), name);
+ IdentifiedObjects.toString(values.descriptor(fallback)
.getName()),
+
IdentifiedObjects.toString(values.descriptor(ambiguity).getName()), name),
name);
}
return null;
}
@@ -459,4 +503,54 @@ public class DefaultParameterValueGroup
public void print() {
ParameterFormat.print(this);
}
+
+ // ---- XML SUPPORT ----------------------------------------------------
+
+ /**
+ * Invoked by JAXB for getting the parameters to marshal.
+ */
+ @XmlElement(name = "parameterValue", required = true)
+ private GeneralParameterValue[] getValues() {
+ final List<GeneralParameterValue> values = values(); // Gives to
user a chance to override.
+ return values.toArray(new GeneralParameterValue[values.size()]);
+ }
+
+ /**
+ * Invoked by JAXB for setting the unmarshalled parameters. This method
should be invoked last
+ * (after {@link #setDescriptor(ParameterDescriptorGroup)}) even if the
{@code parameterValue}
+ * elements were first in the XML document. This is the case at least with
the JAXB reference
+ * implementation.
+ */
+ private void setValues(final GeneralParameterValue[] parameters) {
+ final GeneralParameterDescriptor[] descriptors = new
GeneralParameterDescriptor[parameters.length];
+ for (int i=0; i<descriptors.length; i++) {
+ descriptors[i] = parameters[i].getDescriptor();
+ }
+ if (values == null) {
+ // Should never happen, unless the XML document is invalid and
does not have a 'group' element.
+
+ } else {
+ // We known that the descriptor is an instance of our
DefaultParameterDescriptorGroup
+ // implementation because this is what we declare to the
JAXBContext and in adapters.
+ ((DefaultParameterDescriptorGroup)
values.descriptor).setDescriptors(descriptors);
+ values.clear(); // Because references to parameter descriptors
have changed.
+ }
+ values.addAll(Arrays.asList(parameters));
+ }
+
+ /**
+ * Invoked by JAXB for setting the group parameter descriptor. Those
parameter are redundant with
+ * the parameters associated to the values given to {@link
#setValues(GeneralParameterValue[])},
+ * except the the group identification (name, <i>etc.</i>) and for any
optional parameters which
+ * were not present in the above {@code GeneralParameterValue} array.
+ *
+ * @see #getDescriptor()
+ */
+ private void setDescriptor(final ParameterDescriptorGroup descriptor) {
+ if (ReferencingUtilities.canSetProperty(DefaultParameterValue.class,
+ "setDescriptor", "group", values != null))
+ {
+ values = new ParameterValueList(descriptor);
+ }
+ }
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -629,7 +629,9 @@ public class ParameterFormat extends Tab
*/
final ParameterDescriptor<?> descriptor =
(ParameterDescriptor<?>) generalDescriptor;
final Class<?> valueClass = descriptor.getValueClass();
- table.append(getFormat(Class.class).format(valueClass, buffer,
dummyFP).toString());
+ if (valueClass != null) { // Should never be null, but let be
safe.
+ table.append(getFormat(Class.class).format(valueClass,
buffer, dummyFP).toString());
+ }
nextColumn(table);
buffer.setLength(0);
/*
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -247,8 +247,8 @@ final class ParameterValueList extends A
Errors.Keys.MismatchedParameterDescriptor_1,
name));
}
}
- throw new InvalidParameterNameException(Errors.format(
- Errors.Keys.ParameterNotFound_2, descriptor.getName(),
name), name.getCode());
+ throw new
InvalidParameterNameException(Errors.format(Errors.Keys.ParameterNotFound_2,
+ Verifier.getDisplayName(descriptor), name),
name.getCode());
}
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -20,6 +20,7 @@ import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlTransient;
import javax.measure.unit.Unit;
import org.opengis.util.MemberName;
import org.opengis.metadata.Identifier;
@@ -113,6 +114,7 @@ import org.apache.sis.internal.jdk8.JDK8
* @version 0.6
* @module
*/
+@XmlTransient
public abstract class Parameters implements ParameterValueGroup, Cloneable {
/**
* For subclass constructors only.
@@ -174,13 +176,14 @@ public abstract class Parameters impleme
public static <T> ParameterDescriptor<T> cast(final ParameterDescriptor<?>
descriptor, final Class<T> valueClass)
throws ClassCastException
{
+ ArgumentChecks.ensureNonNull("valueClass", valueClass);
if (descriptor != null) {
final Class<?> actual = descriptor.getValueClass();
// We require a strict equality - not
type.isAssignableFrom(actual) - because in
// the later case we could have (to be strict) to return a <?
extends T> type.
if (!valueClass.equals(actual)) {
throw new
ClassCastException(Errors.format(Errors.Keys.IllegalParameterType_2,
- descriptor.getName().getCode(), actual));
+ Verifier.getDisplayName(descriptor), actual));
}
}
return (ParameterDescriptor<T>) descriptor;
@@ -190,9 +193,9 @@ public abstract class Parameters impleme
* Casts the given parameter value to the given type.
* An exception is thrown immediately if the parameter does not have the
expected value class.
*
- * @param <T> The expected value class.
- * @param value The value to cast, or {@code null}.
- * @param type The expected value class.
+ * @param <T> The expected value class.
+ * @param parameter The parameter to cast, or {@code null}.
+ * @param valueClass The expected value class.
* @return The value casted to the given type, or {@code null} if the
given value was null.
* @throws ClassCastException if the given value doesn't have the expected
value class.
*
@@ -201,18 +204,19 @@ public abstract class Parameters impleme
* @category verification
*/
@SuppressWarnings("unchecked")
- public static <T> ParameterValue<T> cast(final ParameterValue<?> value,
final Class<T> type)
+ public static <T> ParameterValue<T> cast(final ParameterValue<?>
parameter, final Class<T> valueClass)
throws ClassCastException
{
- if (value != null) {
- final ParameterDescriptor<?> descriptor = value.getDescriptor();
+ ArgumentChecks.ensureNonNull("valueClass", valueClass);
+ if (parameter != null) {
+ final ParameterDescriptor<?> descriptor =
parameter.getDescriptor();
final Class<?> actual = descriptor.getValueClass();
- if (!type.equals(actual)) { // Same comment than
cast(ParameterDescriptor)...
+ if (!valueClass.equals(actual)) { // Same comment than
cast(ParameterDescriptor).
throw new
ClassCastException(Errors.format(Errors.Keys.IllegalParameterType_2,
- descriptor.getName().getCode(), actual));
+ Verifier.getDisplayName(descriptor), actual));
}
}
- return (ParameterValue<T>) value;
+ return (ParameterValue<T>) parameter;
}
/**
@@ -440,8 +444,8 @@ public abstract class Parameters impleme
if (value != null) {
return value;
} else {
- throw new IllegalStateException(Errors.format(
- Errors.Keys.MissingValueForParameter_1,
Verifier.getName(parameter)));
+ throw new
IllegalStateException(Errors.format(Errors.Keys.MissingValueForParameter_1,
+ Verifier.getDisplayName(parameter)));
}
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/Verifier.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -22,6 +22,7 @@ import java.lang.reflect.Array;
import javax.measure.unit.Unit;
import javax.measure.converter.UnitConverter;
import javax.measure.converter.ConversionException;
+import org.opengis.metadata.Identifier;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.GeneralParameterDescriptor;
import org.opengis.parameter.InvalidParameterValueException;
@@ -29,6 +30,7 @@ import org.apache.sis.measure.Range;
import org.apache.sis.measure.Units;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.resources.Vocabulary;
/**
@@ -92,7 +94,6 @@ final class Verifier {
* then casted to the descriptor parameterized type.
* @throws InvalidParameterValueException if the parameter value is
invalid.
*/
- @SuppressWarnings("unchecked")
static <T> T ensureValidValue(final ParameterDescriptor<T> descriptor,
final Object value, final Unit<?> unit)
throws InvalidParameterValueException
{
@@ -107,7 +108,7 @@ final class Verifier {
if (unit != null) {
final Unit<?> def = descriptor.getUnit();
if (def == null) {
- final String name = getName(descriptor);
+ final String name = getDisplayName(descriptor);
throw new
InvalidParameterValueException(Errors.format(Errors.Keys.UnitlessParameter_1,
name), name, unit);
}
if (!unit.equals(def)) {
@@ -121,7 +122,7 @@ final class Verifier {
*/
if (value != null) {
if (!valueClass.isInstance(value)) {
- final String name = getName(descriptor);
+ final String name = getDisplayName(descriptor);
throw new InvalidParameterValueException(
Errors.format(Errors.Keys.IllegalParameterValueClass_3,
name, valueClass, value.getClass()), name,
value);
@@ -145,9 +146,10 @@ final class Verifier {
*/
Number n = converter.convert(((Number)
value).doubleValue());
try {
- convertedValue = Numbers.cast(n, (Class<? extends
Number>) valueClass);
+ convertedValue = Numbers.cast(n,
valueClass.asSubclass(Number.class));
} catch (IllegalArgumentException e) {
- throw new
InvalidParameterValueException(e.getLocalizedMessage(), getName(descriptor),
value);
+ throw new
InvalidParameterValueException(e.getLocalizedMessage(),
+ getDisplayName(descriptor), value);
}
} else {
/*
@@ -161,10 +163,10 @@ final class Verifier {
Number n = (Number) Array.get(value, i);
n = converter.convert(n.doubleValue()); // Value
in units that we can compare.
try {
- n = Numbers.cast(n, (Class<? extends Number>)
componentType);
+ n = Numbers.cast(n,
componentType.asSubclass(Number.class));
} catch (IllegalArgumentException e) {
throw new
InvalidParameterValueException(e.getLocalizedMessage(),
- getName(descriptor) + '[' + i + ']',
value);
+ getDisplayName(descriptor) + '[' + i +
']', value);
}
Array.set(convertedValue, i, n);
}
@@ -189,11 +191,11 @@ final class Verifier {
}
if (error != null) {
error.convertRange(converter);
- final String name = getName(descriptor);
+ final String name = getDisplayName(descriptor);
throw new InvalidParameterValueException(error.message(null,
name, value), name, value);
}
}
- return (T) convertedValue;
+ return valueClass.cast(convertedValue);
}
/**
@@ -311,9 +313,25 @@ final class Verifier {
* Convenience method returning the name of the specified descriptor.
* This method is used mostly for output to be read by human, not for
processing.
* Consequently, we may consider to returns a localized name in a future
version.
+ *
+ * <p>This method is null-safe even if none of the references checked here
should be null.
+ * We make this method safe because it is indirectly invoked by methods
like {@code toString()}
+ * which are not expected to fail even if the object is invalid.</p>
+ *
+ * <p><b>This method should NOT be invoked for programmatic usage</b>
(e.g. setting a parameter
+ * value) because the string returned in case of invalid descriptor is
arbitrary.</p>
*/
- static String getName(final GeneralParameterDescriptor descriptor) {
- return descriptor.getName().getCode();
+ static String getDisplayName(final GeneralParameterDescriptor descriptor) {
+ if (descriptor != null) {
+ final Identifier name = descriptor.getName();
+ if (name != null) {
+ final String code = name.getCode();
+ if (code != null) {
+ return code;
+ }
+ }
+ }
+ return Vocabulary.format(Vocabulary.Keys.Unnamed);
}
/**
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -88,4 +88,25 @@
* @version 0.6
* @module
*/
+@XmlSchema(elementFormDefault= XmlNsForm.QUALIFIED, namespace =
Namespaces.GML, xmlns = {
+ @XmlNs(prefix = "gml", namespaceURI = Namespaces.GML),
+ @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI)
+})
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlJavaTypeAdapters({
+ @XmlJavaTypeAdapter(CC_OperationParameter.class),
+ @XmlJavaTypeAdapter(CC_OperationParameterGroup.class),
+ @XmlJavaTypeAdapter(CC_GeneralOperationParameter.class),
+ @XmlJavaTypeAdapter(CC_GeneralParameterValue.class)
+})
package org.apache.sis.parameter;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
+import org.apache.sis.internal.jaxb.referencing.*;
+import org.apache.sis.xml.Namespaces;
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -46,6 +46,7 @@ import org.apache.sis.internal.util.Unmo
import org.apache.sis.internal.metadata.NameToIdentifier;
import org.apache.sis.internal.referencing.WKTUtilities;
import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.referencing.NilReferencingObject;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.io.wkt.FormattableObject;
import org.apache.sis.io.wkt.Formatter;
@@ -123,6 +124,7 @@ import org.apache.sis.internal.jdk7.Obje
* @module
*/
@XmlType(name="IdentifiedObjectType", propOrder={
+ "description",
"identifier",
"names",
"remarks"
@@ -612,7 +614,7 @@ public class AbstractIdentifiedObject ex
* for access to private fields without compiler-generated bridge methods.
*/
final void addName(final Identifier id) {
- if (name == null) {
+ if (name == NilReferencingObject.UNNAMED) {
name = id;
} else {
/*
@@ -705,6 +707,25 @@ public class AbstractIdentifiedObject ex
}
/**
+ * Returns a narrative explanation of the role of this object.
+ *
+ * <div class="section">Default value</div>
+ * The default implementation returns the
+ * {@linkplain
org.apache.sis.metadata.iso.ImmutableIdentifier#getDescription() description}
+ * provided by this object's {@linkplain #getName() name}.
+ *
+ * @return A narrative explanation of the role of this object, or {@code
null} if none.
+ *
+ * @see org.apache.sis.metadata.iso.ImmutableIdentifier#getDescription()
+ *
+ * @since 0.6
+ */
+ @XmlElement
+ public InternationalString getDescription() {
+ return (name != null) ? name.getDescription() : null;
+ }
+
+ /**
* Returns comments on or information about this object, including data
source information.
* If this object {@linkplain #isDeprecated() is deprecated}, then the
remarks should give
* indication about the replacement (e.g. <cite>"superceded by …"</cite>).
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NameIterator.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NameIterator.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NameIterator.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/NameIterator.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -20,6 +20,7 @@ import java.util.Iterator;
import org.opengis.util.GenericName;
import org.opengis.metadata.Identifier;
import org.opengis.referencing.IdentifiedObject;
+import org.apache.sis.internal.referencing.NilReferencingObject;
/**
@@ -53,7 +54,8 @@ final class NameIterator implements Iter
NameIterator(final IdentifiedObject object) {
alias = object.getAlias().iterator();
next = object.getName();
- if (next == null) { // Should never be null in a well-formed
IdentifiedObject, but let be safe.
+ // Should never be null in a well-formed IdentifiedObject, but let be
safe.
+ if (next == null || next == NilReferencingObject.UNNAMED) {
next();
}
}
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -43,13 +43,11 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.referencing.AbstractIdentifiedObject;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.NamedIdentifier;
import org.apache.sis.measure.Longitude;
import org.apache.sis.measure.Latitude;
import org.apache.sis.measure.Units;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.Convention;
@@ -64,6 +62,14 @@ import static org.apache.sis.util.Argume
import static org.apache.sis.util.CharSequences.trimWhitespaces;
import static org.apache.sis.util.collection.Containers.property;
+/*
+ * The identifier for axis of unknown name. We have to use this identifier
when the axis direction changed,
+ * because such change often implies a name change too (e.g. "Westing" →
"Easting"), and we can not always
+ * guess what the new name should be. This constant is used as a sentinel
value set by Normalizer and checked
+ * by DefaultCoordinateSystemAxis for skipping axis name comparisons when the
axis name is unknown.
+ */
+import static org.apache.sis.internal.referencing.NilReferencingObject.UNNAMED;
+
// Branch-dependent imports
import org.apache.sis.internal.jdk7.Objects;
@@ -125,16 +131,6 @@ public class DefaultCoordinateSystemAxis
public static final String RANGE_MEANING_KEY = "rangeMeaning";
/**
- * The identifier for axis of unknown name. We have to use this identifier
when the axis direction changed,
- * because such change often implies a name change too (e.g. "Westing" →
"Easting"), and we can not always
- * guess what the new name should be.
- *
- * <p>This constant is used as a sentinel value for skipping axis name
comparisons when the axis name is
- * unknown.</p>
- */
- static final NamedIdentifier UNNAMED = new NamedIdentifier(null,
Vocabulary.format(Vocabulary.Keys.Unnamed));
-
- /**
* Some names to be treated as equivalent. This is needed because axis
names are the primary way to
* distinguish between {@link CoordinateSystemAxis} instances. Those names
are strictly defined by
* ISO 19111 as "Geodetic latitude" and "Geodetic longitude" among others,
but the legacy WKT
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -36,6 +36,14 @@ import static java.util.Collections.sing
import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
import static org.opengis.referencing.IdentifiedObject.IDENTIFIERS_KEY;
+/*
+ * The identifier for axis of unknown name. We have to use this identifier
when the axis direction changed,
+ * because such change often implies a name change too (e.g. "Westing" →
"Easting"), and we can not always
+ * guess what the new name should be. This constant is used as a sentinel
value set by Normalizer and checked
+ * by DefaultCoordinateSystemAxis for skipping axis name comparisons when the
axis name is unknown.
+ */
+import static org.apache.sis.internal.referencing.NilReferencingObject.UNNAMED;
+
/**
* Derives an coordinate system from an existing one for {@link
AxesConvention}.
@@ -165,7 +173,7 @@ final class Normalizer implements Compar
if (newAbbr.equals(abbreviation)) {
properties.putAll(IdentifiedObjects.getProperties(axis, EXCLUDES));
} else {
- properties.put(NAME_KEY, DefaultCoordinateSystemAxis.UNNAMED);
+ properties.put(NAME_KEY, UNNAMED);
}
/*
* Converts the axis range and build the new axis.
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -31,7 +31,7 @@ import org.opengis.referencing.datum.Ell
import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.internal.jaxb.Context;
-import org.apache.sis.internal.jaxb.gco.Measure;
+import org.apache.sis.internal.jaxb.gml.Measure;
import org.apache.sis.internal.jaxb.referencing.SecondDefiningParameter;
import org.apache.sis.internal.referencing.Formulas;
import org.apache.sis.internal.metadata.WKTKeywords;
Modified:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1697310&r1=1697309&r2=1697310&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
[UTF-8] Mon Aug 24 03:46:04 2015
@@ -32,7 +32,7 @@ import org.apache.sis.referencing.Abstra
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.util.PatchedUnitFormat;
import org.apache.sis.internal.metadata.WKTKeywords;
-import org.apache.sis.internal.jaxb.gco.Measure;
+import org.apache.sis.internal.jaxb.gml.Measure;
import org.apache.sis.internal.util.Numerics;
import org.apache.sis.io.wkt.Formatter;
import org.apache.sis.io.wkt.Convention;