sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1818791 [2/2] - in /sis/branches/ISO-19115-3/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/ sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-...
Date Wed, 20 Dec 2017 13:36:52 GMT
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlType
 import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.util.MemberName;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.Identifier;
@@ -29,6 +30,9 @@ import org.opengis.metadata.content.Samp
 import org.apache.sis.metadata.iso.ISOMetadata;
 import org.apache.sis.metadata.TitleProperty;
 import org.apache.sis.internal.metadata.Dependencies;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
+import org.apache.sis.internal.jaxb.FilterByVersion;
+import org.apache.sis.internal.jaxb.gco.InternationalStringAdapter;
 
 
 /**
@@ -47,7 +51,8 @@ import org.apache.sis.internal.metadata.
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
  * @author  Rémi Maréchal (Geomatys)
- * @version 0.5
+ * @author  Cullen Rombach (Image Matters)
+ * @version 1.0
  * @since   0.3
  * @module
  */
@@ -55,8 +60,9 @@ import org.apache.sis.internal.metadata.
 @TitleProperty(name = "sequenceIdentifier")
 @XmlType(name = "MD_RangeDimension_Type", propOrder = {
     "sequenceIdentifier",
-    "descriptor",
-/// "names"
+    "description",          // ISO 19115-3
+    "descriptor",           // ISO 19139:2007 (legacy)
+    "name"
 })
 @XmlRootElement(name = "MD_RangeDimension")
 @XmlSeeAlso(DefaultBand.class)
@@ -166,7 +172,8 @@ public class DefaultRangeDimension exten
      * @since 0.5
      */
     @Override
-/// @XmlElement(name = "description")
+    @XmlElement(name = "description")
+    @XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class)
     public InternationalString getDescription() {
         return description;
     }
@@ -193,10 +200,10 @@ public class DefaultRangeDimension exten
      */
     @Override
     @Deprecated
-    @XmlElement(name = "descriptor")
     @Dependencies("getDescription")
+    @XmlElement(name = "descriptor", namespace = LegacyNamespaces.GMD)
     public InternationalString getDescriptor() {
-        return getDescription();
+        return FilterByVersion.LEGACY_METADATA.accept() ? getDescription() : null;
     }
 
     /**
@@ -221,7 +228,7 @@ public class DefaultRangeDimension exten
      * @since 0.5
      */
     @Override
-/// @XmlElement(name = "name")
+    // @XmlElement at the end of this class.
     public Collection<Identifier> getNames() {
         return names = nonNullCollection(names, Identifier.class);
     }
@@ -236,4 +243,28 @@ public class DefaultRangeDimension exten
     public void setNames(final Collection<? extends Identifier> newValues) {
         names = writeCollection(newValues, names, Identifier.class);
     }
+
+
+
+
+    //////////////////////////////////////////////////////////////////////////////////////////////////
+    ////////                                                                            
     ////////
+    ////////                               XML support with JAXB                        
     ////////
+    ////////                                                                            
     ////////
+    ////////        The following methods are invoked by JAXB using reflection (even if 
     ////////
+    ////////        they are private) or are helpers for other methods invoked by JAXB. 
     ////////
+    ////////        Those methods can be safely removed if Geographic Markup Language   
     ////////
+    ////////        (GML) support is not needed.                                        
     ////////
+    ////////                                                                            
     ////////
+    //////////////////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Invoked by JAXB at both marshalling and unmarshalling time.
+     * This attribute has been added by ISO 19115:2014 standard.
+     * If (and only if) marshalling an older standard version, we omit this attribute.
+     */
+    @XmlElement(name = "name")
+    private Collection<Identifier> getName() {
+        return FilterByVersion.CURRENT_METADATA.accept() ? getNames() : null;
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.metadata.content.Band;
 import org.opengis.metadata.content.SampleDimension;
 import org.opengis.metadata.content.CoverageContentType;
@@ -28,6 +29,10 @@ import org.opengis.metadata.content.Tran
 import org.opengis.util.Record;
 import org.opengis.util.RecordType;
 import org.apache.sis.measure.ValueRange;
+import org.apache.sis.internal.jaxb.gco.GO_Real;
+import org.apache.sis.internal.jaxb.gco.GO_Integer;
+import org.apache.sis.internal.jaxb.gco.GO_Record;
+import org.apache.sis.internal.jaxb.gco.GO_RecordType;
 
 import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
 
@@ -51,7 +56,8 @@ import static org.apache.sis.internal.me
  *
  * @author  Rémi Maréchal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @author  Cullen Rombach (Image Matters)
+ * @version 1.0
  * @since   0.5
  * @module
  */
@@ -60,14 +66,16 @@ import static org.apache.sis.internal.me
     "maxValue",
     "minValue",
     "units",
-/// "scaleFactor",
-/// "offset",
-/// "meanValue",
-/// "numberOfValues",
-/// "standardDeviation",
-/// "otherPropertyType",
-/// "otherProperty",
-/// "bitsPerValue"
+
+    // New in ISO 19115-3
+    "scaleFactor",
+    "offset",
+    "meanValue",
+    "numberOfValues",
+    "standardDeviation",
+    "otherPropertyType",
+    "otherProperty",
+    "bitsPerValue"
 })
 @XmlRootElement(name = "MD_SampleDimension")
 @XmlSeeAlso({DefaultBand.class, DefaultRangeDimension.class})
@@ -224,7 +232,8 @@ public class DefaultSampleDimension exte
      */
     @Override
     @ValueRange(minimum = 0)
-/// @XmlElement(name = "numberOfValues")
+    @XmlElement(name = "numberOfValues")
+    @XmlJavaTypeAdapter(GO_Integer.Since2014.class)
     public Integer getNumberOfValues() {
         return numberOfValues;
     }
@@ -290,7 +299,8 @@ public class DefaultSampleDimension exte
      * @return the mean value of data values in each dimension included in the resource,
or {@code null} if none.
      */
     @Override
-/// @XmlElement(name = "meanValue")
+    @XmlElement(name = "meanValue")
+    @XmlJavaTypeAdapter(GO_Real.Since2014.class)
     public Double getMeanValue() {
         return meanValue;
     }
@@ -311,7 +321,8 @@ public class DefaultSampleDimension exte
      * @return standard deviation of data values in each dimension included in the resource,
or {@code null} if none.
      */
     @Override
-/// @XmlElement(name = "standardDeviation")
+    @XmlElement(name = "standardDeviation")
+    @XmlJavaTypeAdapter(GO_Real.Since2014.class)
     public Double getStandardDeviation() {
         return standardDeviation;
     }
@@ -353,7 +364,8 @@ public class DefaultSampleDimension exte
      * @return scale factor which has been applied to the cell value, or {@code null} if
none.
      */
     @Override
-/// @XmlElement(name = "scaleFactor")
+    @XmlElement(name = "scaleFactor")
+    @XmlJavaTypeAdapter(GO_Real.Since2014.class)
     public Double getScaleFactor() {
         return scaleFactor;
     }
@@ -374,7 +386,8 @@ public class DefaultSampleDimension exte
      * @return the physical value corresponding to a cell value of zero, or {@code null}
if none.
      */
     @Override
-/// @XmlElement(name = "offset")
+    @XmlElement(name = "offset")
+    @XmlJavaTypeAdapter(GO_Real.Since2014.class)
     public Double getOffset() {
         return offset;
     }
@@ -418,7 +431,8 @@ public class DefaultSampleDimension exte
      */
     @Override
     @ValueRange(minimum = 1)
-/// @XmlElement(name = "bitsPerValues")
+    @XmlElement(name = "bitsPerValues")
+    @XmlJavaTypeAdapter(GO_Integer.Since2014.class)
     public Integer getBitsPerValue() {
         return bitsPerValue;
     }
@@ -469,7 +483,8 @@ public class DefaultSampleDimension exte
      * @return type of other attribute description, or {@code null} if none.
      */
     @Override
-/// @XmlElement(name = "otherPropertyType")
+    @XmlElement(name = "otherPropertyType")
+    @XmlJavaTypeAdapter(GO_RecordType.Since2014.class)
     public RecordType getOtherPropertyType() {
         return otherPropertyType;
     }
@@ -491,7 +506,8 @@ public class DefaultSampleDimension exte
      * @return instance of other/attributeType that defines attributes, or {@code null} if
none.
      */
     @Override
-/// @XmlElement(name = "otherProperty")
+    @XmlElement(name = "otherProperty")
+    @XmlJavaTypeAdapter(GO_Record.Since2014.class)
     public Record getOtherProperty() {
         return otherProperty;
     }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -80,19 +80,25 @@
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
- * @version 0.5
+ * @author  Cullen Rombach (Image Matters)
+ * @version 1.0
  * @since   0.3
  * @module
  */
-@XmlSchema(location=Schemas.METADATA_XSD, elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.GMD,
xmlns = {
-    @XmlNs(prefix = "gmi", namespaceURI = Namespaces.GMI),
-    @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD),
+@XmlSchema(location=Schemas.METADATA_XSD_CONTENT, elementFormDefault=XmlNsForm.QUALIFIED,
namespace=Namespaces.MRC, xmlns = {
+    @XmlNs(prefix = "mrc", namespaceURI = Namespaces.MRC),
+    @XmlNs(prefix = "mcc", namespaceURI = Namespaces.MCC),
+    @XmlNs(prefix = "fcc", namespaceURI = Namespaces.FCC),
+    @XmlNs(prefix = "lan", namespaceURI = Namespaces.LAN),
     @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO),
-    @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI)
+    @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI),
+    @XmlNs(prefix = "gmd", namespaceURI = LegacyNamespaces.GMD),
+    @XmlNs(prefix = "gmi", namespaceURI = LegacyNamespaces.GMI)
 })
 @XmlAccessorType(XmlAccessType.NONE)
 @XmlJavaTypeAdapters({
     @XmlJavaTypeAdapter(CI_Citation.class),
+    @XmlJavaTypeAdapter(MD_AttributeGroup.class),
     @XmlJavaTypeAdapter(MD_CoverageContentTypeCode.class),
     @XmlJavaTypeAdapter(MD_Identifier.class),
     @XmlJavaTypeAdapter(MD_ImagingConditionCode.class),
@@ -122,6 +128,7 @@ import javax.xml.bind.annotation.XmlAcce
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
 import org.apache.sis.xml.Namespaces;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.internal.jaxb.gco.*;
 import org.apache.sis.internal.jaxb.gmd.*;

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -22,14 +22,14 @@ import javax.xml.bind.annotation.XmlType
 
 
 /**
- * Surrounds integer values by {@code <gco:Integer>}.
- * The ISO-19139 standard requires most types to be surrounded by an element representing
the value type.
+ * Wraps integer values in {@code <gco:Integer>} element.
+ * The ISO-19139 standard requires most types to be wrapped by an element representing the
value type.
  * The JAXB default behavior is to marshal primitive Java types directly, without such wrapper
element.
  * The role of this class is to add the {@code <gco:…>} wrapper element required
by ISO 19139.
  *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.4
+ * @version 1.0
  *
  * @see GO_Integer64
  *
@@ -37,11 +37,11 @@ import javax.xml.bind.annotation.XmlType
  * @module
  */
 @XmlType(name = "Integer_PropertyType")
-public final class GO_Integer extends PropertyType<GO_Integer, Integer> {
+public class GO_Integer extends PropertyType<GO_Integer, Integer> {
     /**
      * Empty constructor used only by JAXB.
      */
-    public GO_Integer() {
+    GO_Integer() {
     }
 
     /**
@@ -59,7 +59,7 @@ public final class GO_Integer extends Pr
      * @return {@code Integer.class}
      */
     @Override
-    protected Class<Integer> getBoundType() {
+    protected final Class<Integer> getBoundType() {
         return Integer.class;
     }
 
@@ -67,8 +67,8 @@ public final class GO_Integer extends Pr
      * Allows JAXB to change the result of the marshalling process, according to the
      * ISO-19139 standard and its requirements about primitive types.
      *
-     * @param  value  the integer value we want to surround by an element representing its
type.
-     * @return an adaptation of the integer value, that is to say an integer value surrounded
+     * @param  value  the integer value we want to wrap in an element representing its type.
+     * @return a wrapper for the integer value, that is to say an integer value wrapped
      *         by {@code <gco:Integer>} element.
      */
     @Override
@@ -83,7 +83,7 @@ public final class GO_Integer extends Pr
      */
     @XmlElement(name = "Integer")
     @XmlSchemaType(name = "integer")
-    public Integer getElement() {
+    public final Integer getElement() {
         return metadata;
     }
 
@@ -92,7 +92,26 @@ public final class GO_Integer extends Pr
      *
      * @param  metadata  the unmarshalled value.
      */
-    public void setElement(final Integer metadata) {
+    public final void setElement(final Integer metadata) {
         this.metadata = metadata;
     }
+
+    /**
+     * Wraps the value only if marshalling ISO 19115-3 element.
+     * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element.
+     */
+    public static final class Since2014 extends GO_Integer {
+        /** Empty constructor used only by JAXB. */
+        private Since2014() {
+        }
+
+        /**
+         * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an
older document.
+         *
+         * @return a non-null value only if marshalling ISO 19115-3 or newer.
+         */
+        @Override public GO_Integer wrap(final Integer value) {
+            return accept2014() ? super.wrap(value) : null;
+        }
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -22,8 +22,8 @@ import javax.xml.bind.annotation.XmlType
 
 
 /**
- * Surrounds double values by {@code <gco:Real>}.
- * The ISO-19139 standard requires most types to be surrounded by an element representing
the value type.
+ * Wraps double values in {@code <gco:Real>} element.
+ * The ISO-19139 standard requires most types to be wrapped by an element representing the
value type.
  * The JAXB default behavior is to marshal primitive Java types directly, without such wrapper
element.
  * The role of this class is to add the {@code <gco:…>} wrapper element required
by ISO 19139.
  *
@@ -33,16 +33,17 @@ import javax.xml.bind.annotation.XmlType
  * The few exceptions are documented in {@link GO_Decimal}.
  *
  * @author  Cédric Briançon (Geomatys)
- * @version 0.3
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
  * @since   0.3
  * @module
  */
 @XmlType(name = "Real_PropertyType")
-public final class GO_Real extends PropertyType<GO_Real, Double> {
+public class GO_Real extends PropertyType<GO_Real, Double> {
     /**
      * Empty constructor used only by JAXB.
      */
-    public GO_Real() {
+    GO_Real() {
     }
 
     /**
@@ -60,7 +61,7 @@ public final class GO_Real extends Prope
      * @return {@code Double.class}
      */
     @Override
-    protected Class<Double> getBoundType() {
+    protected final Class<Double> getBoundType() {
         return Double.class;
     }
 
@@ -68,8 +69,8 @@ public final class GO_Real extends Prope
      * Allows JAXB to change the result of the marshalling process, according to the
      * ISO-19139 standard and its requirements about primitive types.
      *
-     * @param  value  the double value we want to surround by an element representing its
type.
-     * @return an adaptation of the double value, that is to say a double value surrounded
+     * @param  value  the double value we want to wrap in an element representing its type.
+     * @return a wrapper for the double value, that is to say a double value wrapped
      *         by {@code <gco:Real>} element.
      */
     @Override
@@ -84,7 +85,7 @@ public final class GO_Real extends Prope
      */
     @XmlElement(name = "Real")
     @XmlSchemaType(name = "double")
-    public Double getElement() {
+    public final Double getElement() {
         return metadata;
     }
 
@@ -93,7 +94,26 @@ public final class GO_Real extends Prope
      *
      * @param  metadata  the unmarshalled value.
      */
-    public void setElement(final Double metadata) {
+    public final void setElement(final Double metadata) {
         this.metadata = metadata;
     }
+
+    /**
+     * Wraps the value only if marshalling ISO 19115-3 element.
+     * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element.
+     */
+    public static final class Since2014 extends GO_Real {
+        /** Empty constructor used only by JAXB. */
+        private Since2014() {
+        }
+
+        /**
+         * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an
older document.
+         *
+         * @return a non-null value only if marshalling ISO 19115-3 or newer.
+         */
+        @Override public GO_Real wrap(final Double value) {
+            return accept2014() ? super.wrap(value) : null;
+        }
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Record.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Record.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Record.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Record.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -26,15 +26,16 @@ import org.apache.sis.util.iso.DefaultRe
  * See package documentation for more information about JAXB and interface.
  *
  * @author  Cullen Rombach (Image Matters)
- * @since   1.0
+ * @author  Martin Desruisseaux (Geomatys)
  * @version 1.0
+ * @since   1.0
  * @module
  */
-public final class GO_Record extends PropertyType<GO_Record, Record> {
+public class GO_Record extends PropertyType<GO_Record, Record> {
     /**
      * Empty constructor for JAXB only.
      */
-    public GO_Record() {
+    GO_Record() {
     }
 
     /**
@@ -47,24 +48,24 @@ public final class GO_Record extends Pro
     }
 
     /**
-     * Returns a wrapper for the given {@code Record} element.
+     * Returns the GeoAPI interface which is bound by this adapter.
      *
-     * @param  value  the value to marshal.
-     * @return the wrapper around the given metadata value.
+     * @return {@code Record.class}
      */
     @Override
-    protected GO_Record wrap(final Record value) {
-        return new GO_Record(value);
+    protected final Class<Record> getBoundType() {
+        return Record.class;
     }
 
     /**
-     * Returns the GeoAPI interface which is bound by this adapter.
+     * Returns a wrapper for the given {@code Record} element.
      *
-     * @return {@code Record.class}
+     * @param  value  the value to marshal.
+     * @return the wrapper around the given metadata value.
      */
     @Override
-    protected Class<Record> getBoundType() {
-        return Record.class;
+    protected GO_Record wrap(final Record value) {
+        return new GO_Record(value);
     }
 
     /**
@@ -74,7 +75,7 @@ public final class GO_Record extends Pro
      * @return the metadata to be marshalled.
      */
     @XmlElement(name = "Record")
-    public DefaultRecord getElement() {
+    public final DefaultRecord getElement() {
         return DefaultRecord.castOrCopy(metadata);
     }
 
@@ -84,7 +85,26 @@ public final class GO_Record extends Pro
      *
      * @param  metadata  the unmarshalled metadata.
      */
-    public void setElement(final DefaultRecord metadata) {
+    public final void setElement(final DefaultRecord metadata) {
         this.metadata = metadata;
     }
+
+    /**
+     * Wraps the value only if marshalling ISO 19115-3 element.
+     * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element.
+     */
+    public static final class Since2014 extends GO_Record {
+        /** Empty constructor used only by JAXB. */
+        private Since2014() {
+        }
+
+        /**
+         * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an
older document.
+         *
+         * @return a non-null value only if marshalling ISO 19115-3 or newer.
+         */
+        @Override public GO_Record wrap(final Record value) {
+            return accept2014() ? super.wrap(value) : null;
+        }
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -26,15 +26,16 @@ import org.apache.sis.util.iso.DefaultRe
  * See package documentation for more information about JAXB and interface.
  *
  * @author  Cédric Briançon (Geomatys)
- * @version 0.3
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
  * @since   0.3
  * @module
  */
-public final class GO_RecordType extends PropertyType<GO_RecordType, RecordType> {
+public class GO_RecordType extends PropertyType<GO_RecordType, RecordType> {
     /**
      * Empty constructor for JAXB only.
      */
-    public GO_RecordType() {
+    GO_RecordType() {
     }
 
     /**
@@ -47,24 +48,24 @@ public final class GO_RecordType extends
     }
 
     /**
-     * Returns a wrapper for the given {@code RecordType} element.
+     * Returns the GeoAPI interface which is bound by this adapter.
      *
-     * @param  value  the value to marshal.
-     * @return the wrapper around the given metadata value.
+     * @return {@code RecordType.class}
      */
     @Override
-    protected GO_RecordType wrap(final RecordType value) {
-        return new GO_RecordType(value);
+    protected final Class<RecordType> getBoundType() {
+        return RecordType.class;
     }
 
     /**
-     * Returns the GeoAPI interface which is bound by this adapter.
+     * Returns a wrapper for the given {@code RecordType} element.
      *
-     * @return {@code RecordType.class}
+     * @param  value  the value to marshal.
+     * @return the wrapper around the given metadata value.
      */
     @Override
-    protected Class<RecordType> getBoundType() {
-        return RecordType.class;
+    protected GO_RecordType wrap(final RecordType value) {
+        return new GO_RecordType(value);
     }
 
     /**
@@ -74,7 +75,7 @@ public final class GO_RecordType extends
      * @return the metadata to be marshalled.
      */
     @XmlElement(name = "RecordType")
-    public DefaultRecordType getElement() {
+    public final DefaultRecordType getElement() {
         return DefaultRecordType.castOrCopy(metadata);
     }
 
@@ -84,7 +85,26 @@ public final class GO_RecordType extends
      *
      * @param  metadata  the unmarshalled metadata.
      */
-    public void setElement(final DefaultRecordType metadata) {
+    public final void setElement(final DefaultRecordType metadata) {
         this.metadata = metadata;
     }
+
+    /**
+     * Wraps the value only if marshalling ISO 19115-3 element.
+     * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element.
+     */
+    public static final class Since2014 extends GO_RecordType {
+        /** Empty constructor used only by JAXB. */
+        private Since2014() {
+        }
+
+        /**
+         * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an
older document.
+         *
+         * @return a non-null value only if marshalling ISO 19115-3 or newer.
+         */
+        @Override public GO_RecordType wrap(final RecordType value) {
+            return accept2014() ? super.wrap(value) : null;
+        }
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -19,6 +19,7 @@ package org.apache.sis.internal.jaxb.gco
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import org.opengis.util.InternationalString;
 import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.internal.jaxb.FilterByVersion;
 
 
 /**
@@ -30,15 +31,15 @@ import org.apache.sis.util.iso.SimpleInt
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Guilhem Legal (Geomatys)
- * @version 0.3
+ * @version 1.0
  * @since   0.3
  * @module
  */
-public final class InternationalStringAdapter extends XmlAdapter<GO_CharacterString, InternationalString>
{
+public class InternationalStringAdapter extends XmlAdapter<GO_CharacterString, InternationalString>
{
     /**
      * Empty constructor for JAXB.
      */
-    private InternationalStringAdapter() {
+    InternationalStringAdapter() {
     }
 
     /**
@@ -49,7 +50,7 @@ public final class InternationalStringAd
      * @return the unwrapped {@link String} value, or {@code null}.
      */
     @Override
-    public InternationalString unmarshal(final GO_CharacterString value) {
+    public final InternationalString unmarshal(final GO_CharacterString value) {
         if (value != null) {
             final CharSequence text = value.toCharSequence();
             if (text != null) {
@@ -73,4 +74,23 @@ public final class InternationalStringAd
     public GO_CharacterString marshal(final InternationalString value) {
         return CharSequenceAdapter.wrap(value);
     }
+
+    /**
+     * Wraps the value only if marshalling ISO 19115-3 element.
+     * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element.
+     */
+    public static final class Since2014 extends InternationalStringAdapter {
+        /** Empty constructor used only by JAXB. */
+        private Since2014() {
+        }
+
+        /**
+         * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an
older document.
+         *
+         * @return a non-null value only if marshalling ISO 19115-3 or newer.
+         */
+        @Override public GO_CharacterString marshal(final InternationalString value) {
+            return FilterByVersion.CURRENT_METADATA.accept() ? super.marshal(value) : null;
+        }
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -31,6 +31,7 @@ import org.apache.sis.xml.IdentifierSpac
 import org.apache.sis.xml.IdentifiedObject;
 import org.apache.sis.xml.ReferenceResolver;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.FilterByVersion;
 import org.apache.sis.internal.jaxb.PrimitiveTypeProperties;
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.util.resources.Errors;
@@ -544,6 +545,16 @@ public abstract class PropertyType<Value
     protected abstract Class<BoundType> getBoundType();
 
     /**
+     * Returns {@code true} if a {@code Since2014} subclasses should return a non-null value.
+     * This is a convenience method for {@code FilterByVersion.CURRENT_METADATA.accept()}.
+     *
+     * @return whether {@code Since2014} subclasses should return a non-null value.
+     */
+    protected final boolean accept2014() {
+        return FilterByVersion.CURRENT_METADATA.accept();
+    }
+
+    /**
      * Creates a new instance of this class wrapping the given metadata.
      * This method is invoked by {@link #marshal} after making sure that
      * {@code value} is not null.

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -20,6 +20,7 @@ import java.util.Locale;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import org.opengis.util.InternationalString;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.FilterByVersion;
 
 
 /**
@@ -30,7 +31,7 @@ import org.apache.sis.internal.jaxb.Cont
  *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
  * @since   0.3
  * @module
  */
@@ -109,4 +110,23 @@ public class StringAdapter extends XmlAd
     public GO_CharacterString marshal(final String value) {
         return CharSequenceAdapter.wrap(Context.current(), value, value);
     }
+
+    /**
+     * Wraps the value only if marshalling ISO 19115-3 element.
+     * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element.
+     */
+    public static final class Since2014 extends StringAdapter {
+        /** Empty constructor used only by JAXB. */
+        private Since2014() {
+        }
+
+        /**
+         * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an
older document.
+         *
+         * @return a non-null value only if marshalling ISO 19115-3 or newer.
+         */
+        @Override public GO_CharacterString marshal(final String value) {
+            return FilterByVersion.CURRENT_METADATA.accept() ? super.marshal(value) : null;
+        }
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java?rev=1818791&r1=1818790&r2=1818791&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java
[UTF-8] Wed Dec 20 13:36:52 2017
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.adapter
 import org.opengis.util.CodeList;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.FilterByVersion;
 
 
 /**
@@ -40,7 +41,7 @@ import org.apache.sis.internal.jaxb.Cont
  *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
  *
  * @param <ValueType> The subclass implementing this adapter.
  * @param <BoundType> The code list being adapted.
@@ -96,6 +97,16 @@ public abstract class CodeListAdapter<Va
     protected abstract Class<BoundType> getCodeListClass();
 
     /**
+     * Returns {@code true} if a {@code Since2014} subclasses should return a non-null value.
+     * This is a convenience method for {@code FilterByVersion.CURRENT_METADATA.accept()}.
+     *
+     * @return whether {@code Since2014} subclasses should return a non-null value.
+     */
+    protected final boolean accept2014() {
+        return FilterByVersion.CURRENT_METADATA.accept();
+    }
+
+    /**
      * Substitutes the adapter value read from an XML stream by the object which will
      * contain the value. JAXB calls automatically this method at unmarshalling time.
      *



Mime
View raw message