You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2018/02/24 16:22:51 UTC
svn commit: r1825260 [11/14] - in /sis/branches/JDK9: ./
application/sis-console/src/test/java/org/apache/sis/console/
core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/
core/sis-metadata/ core/sis-metadata/src/main/java/org/apache/...
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -41,35 +41,37 @@ package org.apache.sis.internal.jaxb;
* </ul>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @author Cullen Rombach (Image Matters)
+ * @version 1.0
* @since 0.4
* @module
*/
public final class Schemas {
/**
- * The XSD definition for Geographic Markup Language (GML) objects.
- */
- public static final String GML_XSD = "http://schemas.opengis.net/gml/3.2.1/gml.xsd";
-
- /**
- * The XSD definition for metadata objects.
+ * The root directory of ISO 19115 metadata schemas.
+ * This is the schema used by default in Apache SIS.
*/
- public static final String METADATA_XSD = "http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd";
+ public static final String METADATA_ROOT = "http://standards.iso.org/iso/19115/";
/**
* The root directory of OGC metadata schemas.
* This is the schema used by default in Apache SIS.
+ * Some alternatives to this URL are:
+ *
+ * <ul>
+ * <li>http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/</li>
+ * <li>http://www.isotc211.org/2005/</li>
+ * </ul>
*/
- public static final String METADATA_ROOT = "http://schemas.opengis.net/iso/19139/20070417/";
+ public static final String METADATA_ROOT_LEGACY = "http://schemas.opengis.net/iso/19139/20070417/";
/**
- * The root directory of ISO metadata schemas.
- * This is sometime used as an alternative to {@link #METADATA_ROOT}.
+ * The string to append to {@link #METADATA_ROOT} for obtaining the path to the definitions of code lists.
*/
- public static final String ISO_19139_ROOT = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/";
+ public static final String CODELISTS_PATH = "resources/Codelist/cat/codelists.xml";
/**
- * The string to append to {@link #METADATA_ROOT} or {@link #ISO_19139_ROOT} for obtaining the path
+ * The string to append to {@link #METADATA_ROOT_LEGACY} or one of its alternative for obtaining the path
* to the definitions of code lists.
*
* <p>A localized version of this file exists also with the {@code "ML_gmxCodelists.xml"} filename
@@ -77,10 +79,10 @@ public final class Schemas {
*
* @see <a href="https://issues.apache.org/jira/browse/SIS-154">SIS-154</a>
*/
- public static final String CODELISTS_PATH = "resources/Codelist/gmxCodelists.xml";
+ public static final String CODELISTS_PATH_LEGACY = "resources/Codelist/gmxCodelists.xml";
/**
- * The string to append to {@link #METADATA_ROOT} or {@link #ISO_19139_ROOT} for obtaining the path
+ * The string to append to {@link #METADATA_ROOT} or one of its alternative for obtaining the path
* to the definitions of units of measurement.
*
* <p>A localized version of this file exists also with the {@code "ML_gmxUom.xml"} filename
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/CharSequenceAdapter.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -22,13 +22,14 @@ import org.apache.sis.util.CharSequences
import org.apache.sis.xml.XLink;
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.gmx.Anchor;
import org.apache.sis.internal.jaxb.gmd.PT_FreeText;
/**
- * JAXB adapter in order to wrap the string value with a {@code <gco:CharacterString>} element,
- * for ISO-19139 compliance. A {@link CharSequenceAdapter} can handle the following types:
+ * JAXB adapter wrapping the string value in a {@code <gco:CharacterString>} element, for ISO 19115-3 compliance.
+ * A {@link CharSequenceAdapter} can handle the following types:
*
* <ul>
* <li>{@link InternationalString}, which may be mapped to {@link PT_FreeText} elements.</li>
@@ -40,7 +41,7 @@ import org.apache.sis.internal.jaxb.gmd.
* @author Cédric Briançon (Geomatys)
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.6
+ * @version 1.0
*
* @see StringAdapter
* @see InternationalStringAdapter
@@ -48,11 +49,11 @@ import org.apache.sis.internal.jaxb.gmd.
* @since 0.3
* @module
*/
-public final class CharSequenceAdapter extends XmlAdapter<GO_CharacterString, CharSequence> {
+public class CharSequenceAdapter extends XmlAdapter<GO_CharacterString, CharSequence> {
/**
* Constructor for JAXB only.
*/
- private CharSequenceAdapter() {
+ public CharSequenceAdapter() {
}
/**
@@ -63,7 +64,7 @@ public final class CharSequenceAdapter e
* @return a {@link CharSequence} which represents the metadata value.
*/
@Override
- public CharSequence unmarshal(final GO_CharacterString value) {
+ public final CharSequence unmarshal(final GO_CharacterString value) {
return (value != null) ? value.toCharSequence() : null;
}
@@ -91,12 +92,12 @@ public final class CharSequenceAdapter e
return wrap(Context.current(), value, (String) value); // Slightly more efficient variant of this method.
}
/*
- * <gmd:someElement xsi:type="gmd:PT_FreeText_PropertyType">
+ * <mdb:someElement xsi:type="lan:PT_FreeText_PropertyType">
* <gco:CharacterString>...</gco:CharacterString>
- * <gmd:PT_FreeText>
+ * <lan:PT_FreeText>
* ... see PT_FreeText ...
- * </gmd:PT_FreeText>
- * </gmd:someElement>
+ * </lan:PT_FreeText>
+ * </mdb:someElement>
*/
if (value instanceof InternationalString) {
final PT_FreeText ft = PT_FreeText.create((InternationalString) value);
@@ -135,9 +136,9 @@ public final class CharSequenceAdapter e
* have been replaced by an Anchor. The output will be one of the following:
*
* ┌──────────────────────────────────────────────────┬────────────────────────────────┐
- * │ <gmd:someElement> │ <gmd:someElement> │
+ * │ <mdb:someElement> │ <mdb:someElement> │
* │ <gco:CharacterString>...</gco:CharacterString> │ <gmx:Anchor>...</gmx:Anchor> │
- * │ </gmd:someElement> │ </gmd:someElement> │
+ * │ </mdb:someElement> │ </mdb:someElement> │
* └──────────────────────────────────────────────────┴────────────────────────────────┘
*/
return new GO_CharacterString(value);
@@ -182,4 +183,23 @@ public final class CharSequenceAdapter e
}
return string;
}
+
+ /**
+ * 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 CharSequenceAdapter {
+ /** 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 CharSequence value) {
+ return FilterByVersion.CURRENT_METADATA.accept() ? super.marshal(value) : null;
+ }
+ }
}
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Boolean.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -23,9 +23,9 @@ import javax.xml.bind.annotation.XmlType
/**
* Surrounds boolean value by {@code <gco:Boolean>}.
- * 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)
* @author Martin Desruisseaux (Geomatys)
@@ -63,7 +63,7 @@ public final class GO_Boolean extends Pr
/**
* 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 boolean value we want to surround by an element representing its type.
* @return an adaptation of the boolean value, that is to say a boolean value surrounded
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.w3c.dom.Element;
import org.opengis.util.CodeList;
@@ -33,16 +34,18 @@ import org.apache.sis.internal.jaxb.gmx.
import org.apache.sis.internal.jaxb.gmx.FileName;
import org.apache.sis.internal.jaxb.gmx.MimeFileType;
import org.apache.sis.internal.jaxb.gmd.CodeListUID;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Workaround;
import org.apache.sis.util.iso.Types;
-import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.resources.IndexedResourceBundle;
import org.apache.sis.util.resources.Messages;
+import org.apache.sis.util.resources.Errors;
/**
- * JAXB wrapper for string value in a {@code <gco:CharacterString>}, {@code <gmx:Anchor>},
- * {@code <gmx:FileName>} or {@code <gmx:MimeFileType>} element, for ISO-19139 compliance.
+ * JAXB wrapper for string value in a {@code <gco:CharacterString>}, {@code <gcx:Anchor>},
+ * {@code <gcx:FileName>} or {@code <gcx:MimeFileType>} element, for ISO 19115-3 compliance.
*
* <p>{@code FileName} and {@code MimeFileType} are possible substitutions for {@code CharacterString}.
* They make sense only in {@link org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic} or
@@ -55,7 +58,8 @@ import org.apache.sis.util.resources.Mes
*
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @author Cullen Rombach (Image Matters)
+ * @version 1.0
*
* @see org.apache.sis.internal.jaxb.gmd.PT_FreeText
*
@@ -68,6 +72,7 @@ import org.apache.sis.util.resources.Mes
org.apache.sis.internal.jaxb.gmd.LanguageCode.class,
org.apache.sis.internal.jaxb.gmd.Country.class
})
+@XmlRootElement(name = "CharacterString")
public class GO_CharacterString {
/*
* Numerical values below are ordered: if two or more values are defined (thoerically not legal,
@@ -75,27 +80,33 @@ public class GO_CharacterString {
*/
/**
* Value assigned to {@link #type} if the character string
- * shall be marshalled as a {@code <gmx:MimeFileType>} element.
+ * shall be marshalled as a {@code <gcx:MimeFileType>} element.
*/
public static final byte MIME_TYPE = 1;
/**
* Value assigned to {@link #type} if the character string
- * shall be marshalled as a {@code <gmx:FileName>} element.
+ * shall be marshalled as a {@code <gcx:FileName>} element.
*/
- public static final byte FILENAME = 2;
+ public static final byte FILENAME = 3; // Precedence over legacy <gmd:UML>
+
+ /**
+ * Value assigned to {@link #type} if the character string
+ * shall be marshalled as a legacy {@code <gmd:URL>} element.
+ */
+ public static final byte URL = 2;
/**
* Value assigned to {@link #type} if the current {@link #text}
- * has been found in a {@code <gmx:Anchor>} element.
+ * has been found in a {@code <gcx:Anchor>} element.
*/
- private static final byte ANCHOR = 3;
+ private static final byte ANCHOR = 4;
/**
* Value assigned to {@link #type} if the current {@link #text}
* has been found in an enumeration or code list element.
*/
- private static final byte ENUM = 4;
+ private static final byte ENUM = 5;
/**
* The XML element names for each possible {@link #type} values.
@@ -108,6 +119,7 @@ public class GO_CharacterString {
case FILENAME: return "FileName";
case ANCHOR: return "Anchor";
case ENUM: return "ControlledVocabulary";
+ case URL: return "URL"; // In legacy XML only.
default: throw new AssertionError(type);
}
}
@@ -157,7 +169,7 @@ public class GO_CharacterString {
* If the given value overwrites a previous one, a warning is emitted.
*
* @param value the value to set.
- * @param property 0 or one of the {@link #MIME_TYPE}, {@link #FILENAME} or {@link #ANCHOR} constants.
+ * @param property 0 or one of the {@link #MIME_TYPE}, {@link #FILENAME}, {@link #URL} or {@link #ANCHOR} constants.
*/
private void setText(CharSequence value, byte property) {
value = CharSequences.trimWhitespaces(value);
@@ -186,7 +198,7 @@ public class GO_CharacterString {
}
/**
- * Returns the text in a {@code <gco:CharacterString>}, {@code <gmx:FileName>} or {@code <gmx:MimeFileType>}
+ * Returns the text in a {@code <gco:CharacterString>}, {@code <gcx:FileName>} or {@code <gcx:MimeFileType>}
* element, or {@code null} if none. This method does not return anything for {@code Enum} or {@code CodeList}
* instances, as the later are handled by {@link #getCodeList()}.
*
@@ -194,13 +206,15 @@ public class GO_CharacterString {
*/
@XmlElements({
@XmlElement(type = String.class, name = "CharacterString"),
- @XmlElement(type = Anchor.class, name = "Anchor", namespace = Namespaces.GMX),
- @XmlElement(type = FileName.class, name = "FileName", namespace = Namespaces.GMX),
- @XmlElement(type = MimeFileType.class, name = "MimeFileType", namespace = Namespaces.GMX)
+ @XmlElement(type = Anchor.class, name = "Anchor", namespace = Namespaces.GCX),
+ @XmlElement(type = FileName.class, name = "FileName", namespace = Namespaces.GCX),
+ @XmlElement(type = MimeFileType.class, name = "MimeFileType", namespace = Namespaces.GCX),
+ @XmlElement(type = GO_URL.class, name = "URL", namespace = LegacyNamespaces.GMD)
})
private Object getValue() {
switch (type) {
case 0: return StringAdapter.toString(text);
+ case URL: return new GO_URL(text.toString());
case FILENAME: return new FileName(text.toString());
case MIME_TYPE: return new MimeFileType(text.toString());
case ANCHOR: return text; // Shall be an instance of Anchor.
@@ -209,10 +223,11 @@ public class GO_CharacterString {
}
/**
- * Sets the {@code <gco:CharacterString>}, {@code <gmx:FileName>} or {@code <gmx:MimeFileType>} value.
+ * Sets the {@code <gco:CharacterString>}, {@code <gcx:FileName>} or {@code <gcx:MimeFileType>} value.
*
* <p>This method is invoked by JAXB at unmarshalling time and should not need to be invoked directly.</p>
*/
+ @SuppressWarnings("unused")
private void setValue(final Object value) {
if (value instanceof Anchor) {
setText((Anchor) value, ANCHOR);
@@ -220,6 +235,8 @@ public class GO_CharacterString {
setText(value.toString(), FILENAME);
} else if (value instanceof MimeFileType) {
setText(value.toString(), MIME_TYPE);
+ } else if (value instanceof GO_URL) { // Legacy ISO 19139:2007
+ setText(value.toString(), URL);
} else {
setText((CharSequence) value, (byte) 0);
}
@@ -231,7 +248,7 @@ public class GO_CharacterString {
*
* <div class="note"><b>Note:</b>
* we have to rely on a somewhat complicated mechanism because the code lists implementations in GeoAPI
- * do not hae JAXB annotations. If those annotations are added in a future GeoAPI implementation, then
+ * do not have JAXB annotations. If those annotations are added in a future GeoAPI implementation, then
* we could replace this mechanism by a simple property annotated with {@code XmlElementRef}.</div>
*
* @since 0.7
@@ -244,23 +261,15 @@ public class GO_CharacterString {
}
final ControlledVocabulary code = Types.forCodeTitle(text);
final String name = Types.getListName(code);
- final String namespace;
/*
- * The namespace is usually GMD, but we also have some other namespaces link GMI.
+ * The namespace has have various value like CIT, SRV, MDQ, MRI, MSR, LAN, etc.
* The real namespace is declared in the @XmlElement annotation of the getElement
* method in the JAXB adapter. We could use reflection, but we do not in order to
* avoid potential class loading issue and also because not all CodeList are in the
* same package.
*/
- if (name.startsWith("MD_") || name.startsWith("CI_") || name.startsWith("DS_")) {
- namespace = Namespaces.GMD;
- } else if (name.startsWith("MI_")) {
- namespace = Namespaces.GMI;
- } else if (name.startsWith("SV_") || name.equals("DCPList")) {
- namespace = Namespaces.SRV;
- } else if (name.startsWith("CS_") || name.startsWith("CD_") || name.startsWith("SC_")) {
- namespace = Namespaces.GML;
- } else {
+ String namespace = Namespaces.guessForType(name);
+ if (namespace == null) {
namespace = XMLConstants.NULL_NS_URI;
}
return new JAXBElement<>(new QName(namespace, name), CodeListUID.class,
@@ -268,25 +277,37 @@ public class GO_CharacterString {
}
/**
- * Invoked by JAXB for any XML element which is not a {@code <gco:CharacterString>}, {@code <gmx:FileName>}
- * or {@code <gmx:MimeFileType>}. This method presumes that the element name is the CodeList standard name.
+ * Invoked by JAXB for any XML element which is not a {@code <gco:CharacterString>}, {@code <gcx:FileName>}
+ * or {@code <gcx:MimeFileType>}. This method presumes that the element name is the CodeList standard name.
* If not, the element will be ignored.
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "unused"})
private void setCodeList(final Object value) {
final Element e = (Element) value;
if (e.getNodeType() == Element.ELEMENT_NODE) {
final Class<?> ct = Types.forStandardName(e.getLocalName());
+ final Class<? extends IndexedResourceBundle> resources;
+ final short errorKey;
+ final Object[] args;
if (ct != null && CodeList.class.isAssignableFrom(ct)) {
- final String attribute = e.getAttribute("codeListValue");
+ final String attribute = e.getAttribute("codeListValue").trim();
if (!attribute.isEmpty()) {
text = Types.getCodeTitle(Types.forCodeName((Class) ct, attribute, true));
type = ENUM;
return;
+ } else {
+ resources = Errors.class;
+ errorKey = Errors.Keys.MissingOrEmptyAttribute_2;
+ args = new Object[2];
+ args[1] = "codeListValue";
}
+ } else {
+ resources = Messages.class;
+ errorKey = Messages.Keys.UnknownCodeList_1;
+ args = new Object[1];
}
- Context.warningOccured(Context.current(), GO_CharacterString.class, "setCodeList",
- Errors.class, Errors.Keys.UnknownType_1, e.getNodeName());
+ args[0] = e.getNodeName();
+ Context.warningOccured(Context.current(), GO_CharacterString.class, "setCodeList", resources, errorKey, args);
}
}
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -29,7 +29,7 @@ import org.apache.sis.internal.jaxb.XmlU
/**
* JAXB adapter wrapping the date value in a {@code <gco:Date>} or {@code <gco:DateTime>} element,
- * for ISO-19139 compliance. Only one of {@code Date} or {@code DateTime} field shall be non-null.
+ * for ISO 19115-3 compliance. Only one of {@code Date} or {@code DateTime} field shall be non-null.
* At marshalling time, the choice is performed depending on whatever the given date contains
* hour, minute or seconds information different than zero.
*
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Decimal.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Decimal.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Decimal.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Decimal.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -23,9 +23,9 @@ import javax.xml.bind.annotation.XmlType
/**
* Surrounds double values by {@code <gco:Decimal>}.
- * 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.
*
* <div class="section">Relationship with {@code GO_Real}</div>
* This adapter is identical to {@link GO_Real} except for the element name, which is {@code "Decimal"} instead
@@ -38,7 +38,6 @@ import javax.xml.bind.annotation.XmlType
* @version 0.3
*
* @see GO_Real
- * @see GO_Decimal32
*
* @since 0.3
* @module
@@ -72,7 +71,7 @@ public final class GO_Decimal extends Pr
/**
* 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
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Distance.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Integer64.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Measure.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_Real.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_RecordType.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/InternationalStringAdapter.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectIdentification.html [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/StringAdapter.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/URIAdapter.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/package-info.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListAdapter.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -30,7 +30,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.
*
@@ -41,7 +41,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
*
@@ -56,6 +57,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>
@@ -64,11 +66,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();
}
/**
@@ -105,7 +117,7 @@ public final class CodeListUID {
/**
* Default empty constructor for JAXB.
*/
- private CodeListUID() {
+ public CodeListUID() {
}
/**
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java [UTF-8] Sat Feb 24 16:22:48 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;
}
/**
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/EnumAdapter.java [UTF-8] Sat Feb 24 16:22:48 2018
@@ -22,7 +22,7 @@ import org.apache.sis.util.iso.Types;
/**
- * An adapter for {@link Enum}, in order to implement the ISO-19139 standard.
+ * An adapter for {@link Enum}, in order to implement the ISO 19115-3 standard.
* Example:
*
* {@preformat xml
Modified: sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] Sat Feb 24 16:22:48 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/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java?rev=1825260&r1=1825259&r2=1825260&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/PT_FreeText.java [UTF-8] Sat Feb 24 16:22:48 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).
*/