Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -83,7 +83,7 @@ public final class GO_Distance extends X /** * Allows JAXB to change the result of the marshalling process, according to the - * ISO-19139 standard and its requirements about {@code measures}. + * ISO 19115-3 standard and its requirements about {@code measures}. * * @param value the double value we want to integrate into a {@code <gco:Distance>} element. * @return an adaptation of the double value, that is to say a double value surrounded
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -17,6 +17,7 @@ package org.apache.sis.internal.jaxb.gco; import org.opengis.util.GenericName; +import org.apache.sis.internal.jaxb.FilterByVersion; /** @@ -34,11 +35,11 @@ import org.opengis.util.GenericName; * @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 GO_GenericName extends NameAdapter<GO_GenericName, GenericName> { +public class GO_GenericName extends NameAdapter<GO_GenericName, GenericName> { /** * Empty constructor for JAXB only. */ @@ -53,7 +54,7 @@ public final class GO_GenericName extend } /** - * Does the link between an {@link GenericName} and the adapter associated. + * Replaces a generic name by its wrapper. * JAXB calls automatically this method at marshalling-time. * * @param value the implementing class for this metadata value. @@ -65,14 +66,33 @@ public final class GO_GenericName extend } /** - * Does the link between adapters and the way they will be unmarshalled. + * Unwraps the generic name from the given element. * JAXB calls automatically this method at unmarshalling-time. * * @param value the wrapper, or {@code null} if none. * @return the implementing class. */ @Override - public GenericName unmarshal(final GO_GenericName value) { + public final GenericName unmarshal(final GO_GenericName value) { return (value != null) ? value.name : null; } + + /** + * 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_GenericName { + /** Empty constructor used only by JAXB. */ + public 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_GenericName marshal(final GenericName value) { + return FilterByVersion.CURRENT_METADATA.accept() ? super.marshal(value) : null; + } + } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -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 19115-3 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. + * The role of this class is to add the {@code <gco:…>} wrapper element required by ISO 19115-3. * * @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,16 +59,16 @@ public final class GO_Integer extends Pr * @return {@code Integer.class} */ @Override - protected Class<Integer> getBoundType() { + protected final Class<Integer> getBoundType() { return Integer.class; } /** * Allows JAXB to change the result of the marshalling process, according to the - * ISO-19139 standard and its requirements about primitive types. + * ISO 19115-3 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. */ + public 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/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -22,9 +22,9 @@ import javax.xml.bind.annotation.XmlSche /** * Surrounds long values by {@code <gco:Integer>}. - * The ISO-19139 standard requires most types to be surrounded by an element representing the value type. + * The ISO 19115-3 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. + * The role of this class is to add the {@code <gco:…>} wrapper element required by ISO 19115-3. * * @author Cédric Briançon (Geomatys) * @version 0.4 @@ -59,7 +59,7 @@ public final class GO_Integer64 extends /** * Allows JAXB to change the result of the marshalling process, according to the - * ISO-19139 standard and its requirements about primitive types. + * ISO 19115-3 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 a integer value surrounded Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -20,7 +20,10 @@ import org.opengis.util.LocalName; /** - * JAXB wrapper in order to map implementing class with the GeoAPI interface. + * Same as {@link GO_GenericName}, but for cases where the element type is declared as {@code LocalName} + * instead than {@code GenericName}. This adapter does not provide any new functionality; + * its sole purpose is to declare types matching JAXB expectation. + * * This adapter is used for all the following mutually exclusive properties * (only one can be defined at time): * @@ -52,8 +55,8 @@ public final class GO_LocalName extends } /** - * Does the link between an {@link org.apache.sis.util.iso.AbstractName} and the adapter associated. - * JAXB calls automatically this method at marshalling-time. + * Replaces a generic name by its wrapper. + * JAXB calls automatically this method at marshalling time. * * @param value the implementing class for this metadata value. * @return an wrapper which contains the metadata value. @@ -64,8 +67,8 @@ public final class GO_LocalName extends } /** - * Does the link between adapters and the way they will be unmarshalled. - * JAXB calls automatically this method at unmarshalling-time. + * Unwraps the generic name from the given element. + * JAXB calls automatically this method at unmarshalling time. * * @param value the wrapper, or {@code null} if none. * @return the implementing class. Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -83,11 +83,10 @@ public final class GO_Measure extends Xm /** * Allows JAXB to change the result of the marshalling process, according to the - * ISO-19139 standard and its requirements about {@code measures}. + * ISO 19115-3 standard and its requirements about {@code measures}. * - * @param value the double value we want to integrate into a {@code <gco:Measure>} element. - * @return an adaptation of the double value, that is to say a double value surrounded - * by {@code <gco:Measure>} element, with an {@code uom} attribute. + * @param value the double value we want to wrap into a {@code <gco:Measure>} element. + * @return a double value wrapped by {@code <gco:Measure>} element with an {@code uom} attribute. */ @Override public GO_Measure marshal(final Double value) { Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -22,10 +22,10 @@ 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 19115-3 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. + * The role of this class is to add the {@code <gco:…>} wrapper element required by ISO 19115-3. * * <div class="section">Relationship with {@code GO_Decimal}</div> * This adapter is identical to {@link GO_Decimal} except for the element name, which is {@code "Real"} @@ -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,20 +61,20 @@ public final class GO_Real extends Prope * @return {@code Double.class} */ @Override - protected Class<Double> getBoundType() { + protected final Class<Double> getBoundType() { return Double.class; } /** * Allows JAXB to change the result of the marshalling process, according to the - * ISO-19139 standard and its requirements about primitive types. + * ISO 19115-3 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 - public GO_Real wrap(final Double value) { + protected GO_Real wrap(final Double value) { return new GO_Real(value); } @@ -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. */ + public 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 protected GO_Real wrap(final Double value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -26,19 +26,20 @@ 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() { } /** - * Wraps a {@code RecordType} value with a {@code gco:RecordType} tags at marshalling-time. + * Wraps a {@code RecordType} value with a {@code gco:RecordType} element at marshalling-time. * * @param metadata the metadata value to marshal. */ @@ -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. */ + public 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/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -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. */ + public 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/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -27,6 +27,7 @@ import org.apache.sis.util.iso.DefaultLo import org.apache.sis.util.iso.DefaultTypeName; import org.apache.sis.util.iso.DefaultMemberName; import org.apache.sis.util.resources.Errors; +import org.apache.sis.internal.jaxb.FilterByVersion; /** @@ -44,7 +45,7 @@ import org.apache.sis.util.resources.Err * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) * @author Guilhem Legal (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ @@ -63,18 +64,7 @@ abstract class NameAdapter<ValueType ext } /** - * Ensures that the {@linkplain #name} is not already defined. - * - * @throws IllegalStateException if a name is already defined. - */ - private void ensureUndefined() throws IllegalStateException { - if (name != null) { - throw new IllegalStateException(Errors.format(Errors.Keys.ValueAlreadyDefined_1, "name")); - } - } - - /** - * Returns the {@code LocalName} or {@code ScopedName} to marshall. Returns {@code null} if the name + * Returns the {@code LocalName} or {@code ScopedName} to marshal. Returns {@code null} if the name * is a {@link TypeName} or a {@link MemberName}, in order to use {@link #getName()} instead. * Example: * @@ -93,8 +83,11 @@ abstract class NameAdapter<ValueType ext if (name instanceof LocalName) { if (name instanceof TypeName || name instanceof MemberName) { return null; - } else { + } else if (FilterByVersion.LEGACY_METADATA.accept()) { code = new NameValue.Local(); + } else { + // ISO 19115-3:2016 does not seem to define gco:LocalName anymore. + code = new NameValue.Scoped(); } } else if (name instanceof ScopedName) { code = new NameValue.Scoped(); @@ -106,7 +99,7 @@ abstract class NameAdapter<ValueType ext } /** - * Returns the {@code TypeName} or {@code MemberName} to marshall. Returns {@code null} if the name + * Returns the {@code TypeName} or {@code MemberName} to marshal. Returns {@code null} if the name * is a {@link LocalName} or {@link ScopedName}, in order to use {@link #getValue()} instead. * Example: * @@ -159,4 +152,15 @@ abstract class NameAdapter<ValueType ext ensureUndefined(); name = value; } + + /** + * Ensures that the {@linkplain #name} is not already defined. + * + * @throws IllegalStateException if a name is already defined. + */ + private void ensureUndefined() throws IllegalStateException { + if (name != null) { + throw new IllegalStateException(Errors.format(Errors.Keys.ValueAlreadyDefined_1, "name")); + } + } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html [UTF-8] Mon Feb 26 11:28:17 2018 @@ -49,8 +49,8 @@ for internal cross-references. It is not useful by itself as a persistent unique identifier.</li> <li><code>uuid</code> is an optional attribute available on every object-with-identity, provided in - the <strong>GMD</strong> schemas that implement ISO 19115 in XML. May be used as a persistent - unique identifier, but only available within GMD context.</li> + the <strong>GCO</strong> schemas that implement ISO 19115 in XML. May be used as a persistent + unique identifier, but only available within GCO context.</li> </ul> <p>However according the <a href="http://schemas.opengis.net/iso/19139/20070417/gco/gcoBase.xsd">OGC schema</a>, Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -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; @@ -104,7 +105,8 @@ import org.apache.sis.util.resources.Err * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.7 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @param <ValueType> the adapter subclass. * @param <BoundType> the interface being adapted. @@ -118,13 +120,6 @@ public abstract class PropertyType<Value extends XmlAdapter<ValueType,BoundType> { /** - * {@code true} if marshalling an XML based on ISO 19115:2003 model. A value of {@code false} - * (ISO 19115:2014 model) is not yet supported, so we currently use this variable only as a way - * to identify the code to revisit when we will want to support the new model. - */ - public static final boolean LEGACY_XML = true; - - /** * The wrapped GeoAPI metadata instance, or {@code null} if the metadata shall not be marshalled. * Metadata are not marshalled when replaced by {@code xlink:href} or {@code uuidref} attributes. */ @@ -542,6 +537,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/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -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. */ + public 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/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -19,19 +19,20 @@ package org.apache.sis.internal.jaxb.gco import java.net.URI; import java.net.URISyntaxException; import javax.xml.bind.annotation.adapters.XmlAdapter; +import org.apache.sis.internal.jaxb.FilterByVersion; import org.apache.sis.internal.jaxb.Context; /** - * JAXB adapter wrapping a URI value with a {@code <gmx:FileName>} element, for ISO-19139 compliance. + * JAXB adapter wrapping a URI value with a {@code <gmx:FileName>} element, for ISO 19139:2007 compliance. * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.4 + * @version 1.0 * @since 0.3 * @module */ -public final class URIAdapter extends XmlAdapter<GO_CharacterString, URI> { +public class URIAdapter extends XmlAdapter<GO_CharacterString, URI> { /** * Empty constructor for JAXB. */ @@ -47,7 +48,7 @@ public final class URIAdapter extends Xm * @throws URISyntaxException if the string is not a valid URI. */ @Override - public URI unmarshal(final GO_CharacterString value) throws URISyntaxException { + public final URI unmarshal(final GO_CharacterString value) throws URISyntaxException { final String text = StringAdapter.toString(value); if (text != null) { final Context context = Context.current(); @@ -77,4 +78,26 @@ public final class URIAdapter extends Xm } return null; } + + /** + * Replace {@code <gcx:FileName>} by {@code <gmd:URL>} if marshalling legacy ISO 19139:2007 document. + */ + public static final class AsURL extends URIAdapter { + /** Empty constructor used only by JAXB. */ + public AsURL() { + } + + /** + * Replaces {@code <gcx:FileName>} by {@code <gmd:URL>} if marshalling legacy ISO 19139:2007 document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override public GO_CharacterString marshal(final URI value) { + final GO_CharacterString wrapper = super.marshal(value); + if (wrapper != null && wrapper.type == GO_CharacterString.FILENAME && !FilterByVersion.CURRENT_METADATA.accept()) { + wrapper.type = GO_CharacterString.URL; + } + return wrapper; + } + } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -19,6 +19,7 @@ package org.apache.sis.internal.jaxb.gco import javax.measure.Unit; import javax.xml.bind.annotation.adapters.XmlAdapter; import org.apache.sis.internal.jaxb.Context; +import org.apache.sis.internal.jaxb.FilterByVersion; import org.apache.sis.internal.jaxb.gml.Measure; @@ -27,7 +28,7 @@ import org.apache.sis.internal.jaxb.gml. * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * * @see Measure * @@ -78,4 +79,23 @@ public class UnitAdapter extends XmlAdap return Measure.getUOM(value, false, true); } } + + /** + * 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 UnitAdapter { + /** Empty constructor used only by JAXB. */ + public 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 String marshal(final Unit<?> value) { + return FilterByVersion.CURRENT_METADATA.accept() ? super.marshal(value) : null; + } + } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -30,9 +30,9 @@ * * <ul class="verbose"> * <li><b>JAXB adapters for primitive types.</b><br> - * JAXB can write directly Java primitive type at marshalling time "as is". However ISO-19139 - * requires those values to be surrounded by elements representing the data type. The role of - * these adapters is to add these elements around the value.</li> + * JAXB can write directly Java primitive type at marshalling time "as is". However ISO 19115-3 + * requires those values to be wrapped by elements representing the data type. A role of these + * adapters is to add these elements around the value.</li> * * <li><b>JAXB adapters for <cite>unit of measure</cite></b> as specified in the ISO-19103 specifications.<br> * For example, a measure marshalled with JAXB will be formatted like {@code <gco:Measure uom="m">220.0</gco:Measure>}.</li> @@ -51,13 +51,13 @@ * <ul class="verbose"> * <li><code>org.apache.sis.<b>metadata.iso</b></code> public packages: * <ul> - * <li>Implement the ISO 19139 {@code Foo_Type}, where <var>Foo</var> is the ISO name of a class.</li> + * <li>Implement the ISO 19115-3 {@code Foo_Type}, where <var>Foo</var> is the ISO name of a class.</li> * <li>Contains the {@code gco:ObjectIdentification} group of attributes ({@code id}, {@code uuid}).</li> * <li>Conceptually could have been subclasses of {@code ObjectIdentification} defined in this package.</li> * </ul></li> * <li><code>org.apache.sis.<b>internal.jaxb</b></code> private packages: * <ul> - * <li>Implement the ISO 19139 {@code Foo_PropertyType} as subclasses of the {@link org.apache.sis.internal.jaxb.gco.PropertyType} class.</li> + * <li>Implement the ISO 19115-3 {@code Foo_PropertyType} as subclasses of the {@link org.apache.sis.internal.jaxb.gco.PropertyType} class.</li> * <li>Contains the {@code gco:ObjectReference} group of attributes ({@code xlink}, {@code uuidref}).</li> * <li>Attributes are declared in the {@link org.apache.sis.internal.jaxb.gco.ObjectReference} Java class.</li> * </ul></li> @@ -77,7 +77,8 @@ * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.7 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter * @@ -86,7 +87,7 @@ */ @XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GCO, xmlns = { @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO), - @XmlNs(prefix = "gmx", namespaceURI = Namespaces.GMX) + @XmlNs(prefix = "gcx", namespaceURI = Namespaces.GCX) }) @XmlAccessorType(XmlAccessType.NONE) /* Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -20,12 +20,13 @@ 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; /** - * An adapter for {@link CodeList}, in order to implement the ISO-19139 standard. This object - * wraps a {@link CodeListUID}, which contain {@link CodeListUID#codeList codeList} and - * {@link CodeListUID#codeListValue codeListValue} attributes. The result looks like below: + * An adapter for {@link CodeList}, in order to implement the ISO 19115-3 standard. + * This object wraps a {@link CodeListUID}, which contain {@link CodeListUID#codeList codeList} + * and {@link CodeListUID#codeListValue codeListValue} attributes. The result looks like below: * * {@preformat xml * <dateType> @@ -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. @@ -63,7 +64,7 @@ public abstract class CodeListAdapter<Va } /** - * Creates a wrapper for a {@link CodeList}, in order to handle the format specified in ISO-19139. + * Creates a wrapper for a {@link CodeList}, in order to handle the format specified in ISO 19115-3. * * @param value the value of {@link CodeList} to be marshalled. */ @@ -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. * Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -29,7 +29,7 @@ import org.apache.sis.internal.jaxb.Sche /** - * Stores information about {@link CodeList} in order to marshal in the way defined by ISO-19139. + * Stores information about {@link CodeList} in order to marshal in the way defined by ISO 19115-3. * This class provides the {@link #codeList} and {@link #codeListValue} attributes to be marshalled. * Those attributes should be unique for each code. * @@ -40,7 +40,8 @@ import org.apache.sis.internal.jaxb.Sche * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.7 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see CodeListAdapter * @@ -55,6 +56,7 @@ public final class CodeListUID { * Some examples of strings returned by this method are: * * <ul> + * <li>{@code "http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#LanguageCode"}</li> * <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#LanguageCode"}</li> * <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode"}</li> * <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode"}</li> @@ -63,11 +65,21 @@ public final class CodeListUID { * @param context the current (un)marshalling context, or {@code null} if none. * @param identifier the UML identifier of the code list. * @return the URL to the given code list in the given schema. + * + * @see org.apache.sis.xml.XML#SCHEMAS */ private static String schema(final Context context, final String identifier) { - return Context.schema(context, "gmd", Schemas.METADATA_ROOT) - .append(Schemas.CODELISTS_PATH) // Future SIS version may switch between localized/unlocalized file. - .append('#').append(identifier).toString(); + final String prefix, root, path; + if (Context.isFlagSet(context, Context.LEGACY_METADATA)) { + prefix = "gmd"; + root = Schemas.METADATA_ROOT_LEGACY; + path = Schemas.CODELISTS_PATH_LEGACY; // Future SIS version may switch between localized/unlocalized file. + } else { + prefix = "cat"; + root = Schemas.METADATA_ROOT; + path = Schemas.CODELISTS_PATH; + } + return Context.schema(context, prefix, root).append(path).append('#').append(identifier).toString(); } /** @@ -104,7 +116,7 @@ public final class CodeListUID { /** * Default empty constructor for JAXB. */ - CodeListUID() { + public CodeListUID() { } /** @@ -149,6 +161,9 @@ public final class CodeListUID { try { value = ResourceBundle.getBundle("org.opengis.metadata.CodeLists", locale, CodeList.class.getClassLoader()).getString(key); + if ("Off line access".equals(value)) { + value = "Offline access"; // For having the same value than GeoAPI 3.1. + } } catch (MissingResourceException e) { Context.warningOccured(context, CodeListAdapter.class, "marshal", e, false); } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -21,15 +21,18 @@ import javax.xml.bind.annotation.XmlType import javax.xml.bind.annotation.XmlElement; import org.apache.sis.util.CharSequences; import org.apache.sis.internal.jaxb.Context; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.jaxb.LegacyNamespaces; import org.apache.sis.internal.jaxb.gco.GO_CharacterString; import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter; import org.apache.sis.util.resources.Errors; +import org.apache.sis.xml.Namespaces; /** - * JAXB wrapper for {@link Locale}, in order to integrate the value in an element respecting - * the ISO-19139 standard. See package documentation for more information about the handling - * of {@code CodeList} in ISO-19139. + * JAXB wrapper for {@link Locale} + * in order to wrap the value in an XML element as specified by ISO 19115-3 standard. + * See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3. * * <p>This adapter formats the locale like below:</p> * @@ -43,19 +46,25 @@ import org.apache.sis.util.resources.Err * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.4 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ -@XmlType(name = "Country_PropertyType") +@XmlType(name = "Country_PropertyType", namespace = Namespaces.LAN) public final class Country extends GO_CharacterString { /** * The country using a {@link org.opengis.util.CodeList}-like format. + * This was called "Country" in ISO 19139:2007 and has been renamed "CountryCode" in ISO 19115-3 */ - @XmlElement(name = "Country") private CodeListUID identifier; /** + * {@code true} if marshalling ISO 19139:2007, or {@code false} if marshalling ISO 19115-3. + */ + private boolean isLegacyMetadata; + + /** * Empty constructor for JAXB only. */ private Country() { @@ -67,6 +76,7 @@ public final class Country extends GO_Ch */ private Country(final CharSequence code) { super(code); + detectVersion(); } /** @@ -80,6 +90,46 @@ public final class Country extends GO_Ch */ private Country(final Context context, final String codeListValue, final String codeSpace, final String value) { identifier = new CodeListUID(context, "Country", codeListValue, codeSpace, value); + detectVersion(); + } + + /** + * Determines if we are marshalling ISO 19139:2007 or ISO 19115-3 documents. + */ + private void detectVersion() { + isLegacyMetadata = !FilterByVersion.CURRENT_METADATA.accept(); + } + + /** + * Gets the value of the Country code using ISO 19139:2007 element name. + */ + @XmlElement(name = "Country", namespace = LegacyNamespaces.GMD) + private CodeListUID getCountry() { + return isLegacyMetadata ? identifier : null; + } + + /** + * Sets the value of the Country code in ISO 19139:2007 element name. + */ + @SuppressWarnings("unused") + private void setCountry(CodeListUID newValue) { + identifier = newValue; + } + + /** + * Gets the value of the Country code using ISO 19115-3 element name. + */ + @XmlElement(name = "CountryCode", namespace = Namespaces.LAN) + private CodeListUID getCountryCode() { + return isLegacyMetadata ? null : identifier; + } + + /** + * Sets the value of the Country code in ISO 19115-3 element name. + */ + @SuppressWarnings("unused") + private void setCountryCode(CodeListUID newValue) { + identifier = newValue; } /** Copied: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java (from r1825261, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java?p2=sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java&p1=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java&r1=1825261&r2=1825355&rev=1825355&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -17,8 +17,6 @@ package org.apache.sis.internal.jaxb.gmd; import javax.xml.bind.annotation.adapters.XmlAdapter; -import org.opengis.util.ControlledVocabulary; -import org.apache.sis.util.iso.Types; /** @@ -32,7 +30,7 @@ import org.apache.sis.util.iso.Types; * } * * @author Martin Desruisseaux (Geomatys) - * @version 0.6 + * @version 1.0 * * @param <ValueType> the subclass implementing this adapter. * @param <BoundType> the enum being adapted. @@ -85,7 +83,7 @@ public abstract class EnumAdapter<ValueT * @param e the enumeration constant. * @return the text to write in the XML element. */ - protected static String value(final ControlledVocabulary e) { - return Types.getCodeName(e); + protected static String value(final Enum<?> e) { + return e.name(); } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -17,17 +17,18 @@ package org.apache.sis.internal.jaxb.gmd; import java.util.Locale; -import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; import org.apache.sis.internal.jaxb.Context; import org.apache.sis.internal.jaxb.gco.GO_CharacterString; import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter; +import org.apache.sis.xml.Namespaces; /** - * JAXB wrapper for {@link Locale}, in order to integrate the value in an element respecting - * the ISO-19139 standard. See package documentation for more information about the handling - * of {@code CodeList} in ISO-19139. + * JAXB wrapper for {@link Locale} + * in order to wrap the value in an XML element as specified by ISO 19115-3 standard. + * See package documentation for more information about the handling of {@code CodeList} in ISO 19115-3. * * <p>This adapter formats the locale like below:</p> * @@ -41,16 +42,17 @@ import org.apache.sis.internal.jaxb.gco. * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.4 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ -@XmlType(name = "LanguageCode_PropertyType") +@XmlType(name = "LanguageCode_PropertyType", namespace = Namespaces.LAN) public final class LanguageCode extends GO_CharacterString { /** * The language using a {@link org.opengis.util.CodeList}-like format. */ - @XmlElement(name = "LanguageCode") + @XmlElement(name = "LanguageCode", namespace = Namespaces.LAN) private CodeListUID identifier; /** Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -40,7 +40,7 @@ import org.apache.sis.util.Debug; final class LocalisedCharacterString { /** * A prefix to concatenate with the {@linkplain Locale#getISO3Language() language code}. - * This is a hack for a common pattern found in the way locales are specified in ISO 19139 files. + * This is a hack for a common pattern found in the way locales are specified in ISO 19139:2007 files. * See <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a> for more information. */ private static final String PREFIX = "#locale-"; Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -27,27 +27,28 @@ import org.apache.sis.internal.jaxb.Cont import org.apache.sis.internal.jaxb.gco.GO_CharacterString; import org.apache.sis.util.iso.DefaultInternationalString; import org.apache.sis.util.iso.SimpleInternationalString; +import org.apache.sis.xml.Namespaces; import org.apache.sis.util.ArraysExt; /** - * JAXB wrapper for ISO-19139 {@code <PT_FreeText>} element mapped to {@link InternationalString}. - * It will be used in order to marshal and unmarshal international strings localized in several - * language, using the {@link DefaultInternationalString} implementation class. Example: + * JAXB wrapper for ISO 19115-3 {@code <PT_FreeText>} element mapped to {@link InternationalString}. + * It will be used in order to marshal and unmarshal international strings localized in several language, + * using the {@link DefaultInternationalString} implementation class. Example: * * {@preformat xml - * <gmd:title xsi:type="gmd:PT_FreeText_PropertyType"> + * <cit:title xsi:type="lan:PT_FreeText_PropertyType"> * <gco:CharacterString>Some title in english is present in this node</gco:CharacterString> - * <gmd:PT_FreeText> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-fra">Un titre en français</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * </gmd:PT_FreeText> - * </gmd:title> + * <lan:PT_FreeText> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-fra">Un titre en français</lan:LocalisedCharacterString> + * </lan:textGroup> + * </lan:PT_FreeText> + * </cit:title> * } * - * If there is more than one locale, the whole {@code <gmd:textGroup>} block is repeated for each - * locale, instead than repeating {@code <gmd:LocalisedCharacterString>} inside the same group as + * If there is more than one locale, the whole {@code <lan:textGroup>} block is repeated for each + * locale, instead than repeating {@code <lan:LocalisedCharacterString>} inside the same group as * we could expect. However at unmarshalling time, both forms are accepted. See GEOTK-152 for more * information. * @@ -56,23 +57,24 @@ import org.apache.sis.util.ArraysExt; * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.6 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-152">GEOTK-152</a> * * @since 0.3 * @module */ -@XmlType(name = "PT_FreeText_PropertyType") +@XmlType(name = "PT_FreeText_PropertyType", namespace = Namespaces.LAN) public final class PT_FreeText extends GO_CharacterString { /** - * A set of {@link LocalisedCharacterString}, representing the {@code <gmd:textGroup>} element. + * A set of {@link LocalisedCharacterString}, representing the {@code <lan:textGroup>} element. * The array shall contain one element for each locale. * * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-152">GEOTK-152</a> */ - @XmlElementWrapper(name = "PT_FreeText") - @XmlElement(required = true) + @XmlElementWrapper(name = "PT_FreeText", namespace = Namespaces.LAN) + @XmlElement(namespace = Namespaces.LAN, required = true) private TextGroup[] textGroup; /** @@ -171,11 +173,11 @@ public final class PT_FreeText extends G */ @Override protected CharSequence toCharSequence() { - String defaultValue = toString(); // May be null. + String defaultValue = toString(); // May be null. if (defaultValue != null && contains(defaultValue)) { /* * If the <gco:CharacterString> value is repeated in one of the - * <gmd:LocalisedCharacterString> elements, keep only the localized + * <lan:LocalisedCharacterString> elements, keep only the localized * version (because it specifies the locale, while the unlocalized * string saids nothing on that matter). */ Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -19,12 +19,13 @@ package org.apache.sis.internal.jaxb.gmd import java.util.Locale; import javax.xml.bind.annotation.XmlElement; import org.apache.sis.util.Debug; +import org.apache.sis.xml.Namespaces; /** * A set of strings localized in different languages. This adapter represents the - * {@code <gmd:textGroup>} element defined for embedded translations in ISO-19139 - * standard. See {@link PT_FreeText} class javadoc for an example. + * {@code <lan:textGroup>} element defined in ISO 19139:2007. + * See {@link PT_FreeText} class javadoc for an example. * * <p>If a localized string has a {@code null} locale, then this string will not be * included in this text group because that string should be already included in @@ -35,40 +36,41 @@ import org.apache.sis.util.Debug; * <p>The {@code TextGroup} name suggests that this object can contain many localized strings. * However it appears that despite its name, {@code TextGroup} shall always contains exactly 1 * localized strings and the whole {@code TextGroup} element shall be repeated for each additional - * languages. SIS uses the ISO 19139 compliant form for marshalling, but accepts both forms during - * unmarshalling. More specifically, the name suggests that the format should be:</p> + * languages. SIS uses the ISO 19139:2007 compliant form for marshalling, but accepts both forms + * during unmarshalling. More specifically, the name suggests that the format should be:</p> * * {@preformat xml * <gco:CharacterString>Apache SIS, projet OpenSource</gco:CharacterString> - * <gmd:PT_FreeText> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</gmd:LocalisedCharacterString> - * <gmd:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</gmd:LocalisedCharacterString> - * <gmd:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * </gmd:PT_FreeText> + * <lan:PT_FreeText> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</lan:LocalisedCharacterString> + * <lan:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</lan:LocalisedCharacterString> + * <lan:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</lan:LocalisedCharacterString> + * </lan:textGroup> + * </lan:PT_FreeText> * } * * But the actual official format is: * * {@preformat xml * <gco:CharacterString>Apache SIS, projet OpenSource</gco:CharacterString> - * <gmd:PT_FreeText> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * <gmd:textGroup> - * <gmd:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</gmd:LocalisedCharacterString> - * </gmd:textGroup> - * </gmd:PT_FreeText> + * <lan:PT_FreeText> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-eng">Apache SIS, OpenSource Project</lan:LocalisedCharacterString> + * </lan:textGroup> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-ita">Apache SIS, progetto OpenSource</lan:LocalisedCharacterString> + * </lan:textGroup> + * <lan:textGroup> + * <lan:LocalisedCharacterString locale="#locale-fra">Apache SIS, projet OpenSource</lan:LocalisedCharacterString> + * </lan:textGroup> + * </lan:PT_FreeText> * } * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see LocalisedCharacterString * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-152">GEOTK-152</a> @@ -82,11 +84,11 @@ final class TextGroup { * JAXB uses this field at marshalling-time in order to wrap {@code N} * {@code <LocalisedCharacterString>} elements inside a single {@code <textGroup>} element. * - * <p>In ISO 19139 compliant documents, the length of this array shall be exactly 1, + * <p>In ISO 19139:2007 compliant documents, the length of this array shall be exactly 1, * as in the second example of class javadoc. However SIS allows arbitrary length * (as in the first example of class javadoc) for compatibility and convenience reasons.</p> */ - @XmlElement(name = "LocalisedCharacterString") + @XmlElement(name = "LocalisedCharacterString", namespace = Namespaces.LAN) protected LocalisedCharacterString[] localized; /** @@ -97,9 +99,9 @@ final class TextGroup { /** * Constructs a {@linkplain TextGroup text group} for a single locale. This constructor - * puts exactly one string in the {@code TextGroup}, as required by ISO 19139. However - * it would be possible to declare an other constructor allowing the more compact form - * (the smaller ) if there is a need for that in the future. + * puts exactly one string in the {@code TextGroup}, as required by ISO 19139:2007. + * However it would be possible to declare an other constructor allowing the more compact form + * (the smaller) if there is a need for that in the future. * * @param locale the string language. * @param text the string. Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/package-info.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -21,15 +21,17 @@ * lists (except base classes), which are defined in their own package. * * @author Cédric Briançon (Geomatys) - * @version 0.7 + * @author Martin Desruisseaux (Geomatys) + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter * * @since 0.3 * @module */ -@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GMD, xmlns = { - @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD), +@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.MDB, xmlns = { + @XmlNs(prefix = "mdb", namespaceURI = Namespaces.MDB), @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO) }) @XmlAccessorType(XmlAccessType.NONE) Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -35,11 +35,11 @@ import org.apache.sis.measure.Units; /** * A measurement value together with its unit of measure. - * This is used for marshalling an element defined by ISO-19103. + * This is used for marshalling an element defined by ISO 19103. * * <p>This class duplicates {@code org.apache.sis.measure.Measure}, but we have to do that way * because that {@code Measure} extends {@link Number} and we are not allowed to use the - * {@code @XmlValue} annotation on a class that extends an other class.</p> + * {@code @XmlValue} annotation on a class that extends another class.</p> * * <div class="section">XML marshalling</div> * Measures are used in different ways by the ISO 19115 (Metadata) and GML standards. @@ -48,7 +48,7 @@ import org.apache.sis.measure.Units; * * {@preformat xml * <gmd:distance> - * <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance> + * <gco:Distance uom="http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])">1000.0</gco:Distance> * </gmd:distance> * } * @@ -63,7 +63,7 @@ import org.apache.sis.measure.Units; * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * * @see org.apache.sis.internal.jaxb.gml.MeasureList * @see org.apache.sis.internal.jaxb.gco.UnitAdapter @@ -121,7 +121,7 @@ public final class Measure { } /** - * Constructs a string representation of the units as defined in the ISO-19103 standard. + * Constructs a string representation of the units as defined in the ISO 19103 standard. * This method is invoked during XML marshalling. For example if the units are "metre", * then this method returns one of the following strings, in preference order: * @@ -129,10 +129,11 @@ public final class Measure { * urn:ogc:def:uom:EPSG::9001 * } * - * or + * or one of the following: * * {@preformat text * http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m']) + * http://www.isotc211.org/2005/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m']) * } * * @return the string representation of the unit of measure. @@ -165,14 +166,26 @@ public final class Measure { if (unit == null || unit.equals(Units.UNITY)) { return ""; } - final StringBuilder buffer = Context.schema(Context.current(), "gmd", Schemas.METADATA_ROOT) - .append(Schemas.UOM_PATH).append("#xpointer(//*[@gml:id='"); + final StringBuilder link; + final Context context = Context.current(); + /* + * We have not yet found an ISO 19115-3 URL for units of measurement. + * If we find one, we should use a block like below: + * + * if (Context.isFlagSet(context, Context.LEGACY_METADATA)) { + * link = ... new URL ... + * } else { + * link = current code + * } + */ + link = Context.schema(context, "gmd", Schemas.METADATA_ROOT_LEGACY); + link.append(Schemas.UOM_PATH).append("#xpointer(//*[@gml:id='"); try { - UCUM.format(unit, buffer); + UCUM.format(unit, link); } catch (IOException e) { throw new AssertionError(e); // Should never happen since we wrote to a StringBuilder. } - return buffer.append("'])").toString(); + return link.append("'])").toString(); } /** Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -27,7 +27,7 @@ import org.apache.sis.util.Classes; /** * JAXB adapter for {@link VerticalCRS}, in order to integrate the value in an element * complying with OGC/ISO standard. Note that the CRS is formatted using the GML schema, - * not the ISO 19139 one. + * not the ISO 19139:2007 one. * * <p>This wrapper does not declare directly the XML element, because doing so would require * the implementation classes in the {@code sis-referencing} module. Instead, this wrapper Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -32,15 +32,15 @@ import org.apache.sis.internal.geoapi.te /** * JAXB adapter for {@link TemporalPrimitive}, in order to integrate the value in an element complying - * with OGC/ISO standard. Note that the CRS is formatted using the GML schema, not the ISO 19139 one. + * with OGC/ISO standard. Note that the CRS is formatted using the GML schema, not the ISO 19139:2007 one. * * @author Guilhem Legal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.4 + * @version 1.0 * @since 0.3 * @module */ -public final class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive> { +public class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive> { /** * Empty constructor for JAXB. */ @@ -73,7 +73,7 @@ public final class TM_Primitive extends * @return {@code TemporalPrimitive.class} */ @Override - protected Class<TemporalPrimitive> getBoundType() { + protected final Class<TemporalPrimitive> getBoundType() { return TemporalPrimitive.class; } @@ -84,7 +84,7 @@ public final class TM_Primitive extends * @return the time period, or {@code null}. */ @XmlElement(name = "TimePeriod") - public TimePeriod getTimePeriod() { + public final TimePeriod getTimePeriod() { final TemporalPrimitive metadata = this.metadata; return (metadata instanceof Period) ? new TimePeriod((Period) metadata) : null; } @@ -96,7 +96,7 @@ public final class TM_Primitive extends * @return the time instant, or {@code null}. */ @XmlElement(name = "TimeInstant") - public TimeInstant getTimeInstant() { + public final TimeInstant getTimeInstant() { final TemporalPrimitive metadata = this.metadata; return (metadata instanceof Instant) ? new TimeInstant((Instant) metadata) : null; } @@ -107,7 +107,7 @@ public final class TM_Primitive extends * * @param period the wrapper to set. */ - public void setTimePeriod(final TimePeriod period) { + public final void setTimePeriod(final TimePeriod period) { metadata = null; // Cleaned first in case of failure. if (period != null) { final Context context = Context.current(); @@ -139,7 +139,7 @@ public final class TM_Primitive extends * * @param instant the wrapper to set. */ - public void setTimeInstant(final TimeInstant instant) { + public final void setTimeInstant(final TimeInstant instant) { metadata = null; // Cleaned first in case of failure. if (instant != null) { final Date position = XmlUtilities.toDate(Context.current(), instant.timePosition); @@ -170,4 +170,23 @@ public final class TM_Primitive extends Context.warningOccured(Context.current(), TM_Primitive.class, method, e, true); } } + + /** + * 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 TM_Primitive { + /** Empty constructor used only by JAXB. */ + public 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 protected TM_Primitive wrap(final TemporalPrimitive value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/FileName.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -23,13 +23,13 @@ import javax.xml.bind.annotation.XmlRoot /** - * The {@code <gmx:FileName>} element, which may be used as a substitute of {@code <gco:CharacterString>}. + * The {@code <gcx:FileName>} element, which may be used as a substitute of {@code <gco:CharacterString>}. * This is used for the URI in {@link org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic}. * Example: * * {@preformat xml * <fileName> - * <gmx:FileName src="../path/wkj98723.jpg">Overview</gmx:FileName> + * <gcx:FileName src="../path/wkj98723.jpg">Overview</gcx:FileName> * </fileName> * } * Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileType.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -23,13 +23,13 @@ import javax.xml.bind.annotation.XmlRoot /** - * The {@code <gmx:MimeFileType>} element, which may be used as a substitute of {@code <gco:CharacterString>}. + * The {@code <gcx:MimeFileType>} element, which may be used as a substitute of {@code <gco:CharacterString>}. * This is used in {@link org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic}. * Example: * * {@preformat xml * <fileType> - * <gmx:MimeFileType type="image/tiff">Graphic TIFF</gmx:MimeFileType> + * <gcx:MimeFileType type="image/tiff">Graphic TIFF</gcx:MimeFileType> * </fileType> * } * Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/MimeFileTypeAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -23,7 +23,7 @@ import org.apache.sis.internal.jaxb.gco. /** - * JAXB adapter wrapping a {@code String} value with a {@code <gmx:MimeFileType>} element. + * JAXB adapter wrapping a {@code String} value with a {@code <gcx:MimeFileType>} element. * * @author Martin Desruisseaux (Geomatys) * @version 0.4 Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/package-info.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -16,18 +16,21 @@ */ /** - * Miscellaneous objects and adapters defined in the {@code "gmx"} namespace. + * Miscellaneous objects and adapters defined in the {@code "gcx"} namespace. + * In legacy ISO 19139:2007, this namespace was to {@code "gmx"}. * * @author Guilhem Legal (Geomatys) - * @version 0.4 + * @author Martin Desruisseaux (Geomatys) + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter * * @since 0.3 * @module */ -@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GMX, xmlns = { - @XmlNs(prefix = "gmx", namespaceURI = Namespaces.GMX) +@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GCX, xmlns = { + @XmlNs(prefix = "gcx", namespaceURI = Namespaces.GCX) }) @XmlAccessorType(XmlAccessType.NONE) @XmlJavaTypeAdapter(InternationalStringConverter.class) Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/package-info.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -33,7 +33,8 @@ * This is used for storing the value in a list of identifiers while preserving the original object.</p> * * @author Cédric Briançon (Geomatys) - * @version 0.7 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -41,7 +41,7 @@ import org.opengis.referencing.Reference * implementation is defined here since it is needed by some utility methods. * * @author Martin Desruisseaux (Geomatys) - * @version 0.7 + * @version 1.0 * @since 0.3 * @module */
