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 2019/05/05 21:57:47 UTC
[sis] branch geoapi-3.1 updated (8164ff4 -> 0018ef8)
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a change to branch geoapi-3.1
in repository https://gitbox.apache.org/repos/asf/sis.git.
from 8164ff4 Merge branch 'geoapi-4.0' into geoapi-3.1, but replacing method renaming by a comment about future evolution.
add 6640cc3 Update for GeoAPI change: Medium.name property type changed from MediumName to Citation. https://issues.apache.org/jira/browse/SIS-389
new dc69af0 Merge branch 'geoapi-4.0' into geoapi-3.1 but without changing the Medium.name property type for compatibility reason.
add f15686f In Metadata, java.nio.charset.Charset should be associated to java.util.Locale. This issue is described at https://github.com/opengeospatial/geoapi/issues/28 and is required for https://issues.apache.org/jira/browse/SIS-402 resolution. This work required improvement in many SIS internal classes (ModifiableMetadata, PropertyAccessor, Merger, TreeFormat, PT_Locale, etc…) for allowing the use of java.util.Map in addition of java.util.Collection in metadata properties.
add f8f18f1 Fix the unmarshalling of <gmd:characterSet> attribute from legacy XML documents. https://issues.apache.org/jira/browse/SIS-402
add 50b074f Remove LegacyPropertyAdapter.asCollection(…) method since it duplicates CollectionsExt.singletonOrEmpty(…).
new 0018ef8 Merge branch 'geoapi-4.0' into geoapi-3.1.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/sis/internal/jaxb/cat/CodeListUID.java | 3 +-
.../internal/jaxb/code/MD_CharacterSetLegacy.java | 84 -----
.../sis/internal/jaxb/code/MD_MediumNameCode.java | 2 +-
.../sis/internal/jaxb/lan/LocaleAdapter.java | 62 ++++
.../sis/internal/jaxb/lan/LocaleAndCharset.java | 400 +++++++++++++++++++++
.../apache/sis/internal/jaxb/lan/OtherLocales.java | 150 ++++++++
.../apache/sis/internal/jaxb/lan/PT_Locale.java | 216 ++++++++---
.../internal/metadata/LegacyPropertyAdapter.java | 37 +-
.../org/apache/sis/internal/metadata/Merger.java | 83 ++++-
.../sis/internal/metadata/MetadataUtilities.java | 42 +++
.../apache/sis/internal/metadata/OtherLocales.java | 189 ----------
.../internal/metadata/legacy}/package-info.java | 9 +-
.../apache/sis/internal/simple/SimpleMetadata.java | 21 +-
.../apache/sis/metadata/ModifiableMetadata.java | 170 +++++++--
.../org/apache/sis/metadata/PropertyAccessor.java | 48 ++-
.../java/org/apache/sis/metadata/SpecialCases.java | 30 +-
.../java/org/apache/sis/metadata/TreeNode.java | 61 +++-
.../org/apache/sis/metadata/TreeNodeChildren.java | 51 +--
.../iso/DefaultExtendedElementInformation.java | 7 +-
.../apache/sis/metadata/iso/DefaultMetadata.java | 265 ++++++++------
.../sis/metadata/iso/citation/DefaultContact.java | 7 +-
.../iso/content/DefaultCoverageDescription.java | 9 +-
.../DefaultFeatureCatalogueDescription.java | 76 ++--
.../sis/metadata/iso/content/package-info.java | 4 +-
.../DefaultDigitalTransferOptions.java | 2 +-
.../metadata/iso/distribution/DefaultFormat.java | 3 +-
.../metadata/iso/distribution/DefaultMedium.java | 59 ++-
.../identification/DefaultDataIdentification.java | 126 ++++---
.../metadata/iso/identification/package-info.java | 7 +-
.../maintenance/DefaultMaintenanceInformation.java | 5 +-
.../org/apache/sis/metadata/iso/package-info.java | 8 +-
.../sis/metadata/iso/quality/DefaultScope.java | 3 +-
.../main/java/org/apache/sis/util/iso/Types.java | 6 +-
.../java/org/apache/sis/xml/ValueConverter.java | 2 +-
.../org/apache/sis/xml/RenameOnExport.lst | 2 +-
.../org/apache/sis/xml/RenameOnImport.lst | 2 +-
.../sis/internal/jaxb/lan/LanguageCodeTest.java | 6 +-
.../sis/internal/jaxb/lan/OtherLocalesTest.java | 112 ++++++
.../sis/internal/jaxb/lan/PT_LocaleTest.java | 12 +-
.../apache/sis/internal/metadata/MergerTest.java | 13 +-
.../internal/metadata/MetadataUtilitiesTest.java | 32 +-
.../sis/internal/metadata/OtherLocalesTest.java | 129 -------
.../apache/sis/metadata/PropertyAccessorTest.java | 8 +-
.../sis/metadata/PropertyConsistencyCheck.java | 23 +-
.../sis/metadata/iso/CustomMetadataTest.java | 2 +
.../sis/metadata/iso/DefaultMetadataTest.java | 20 +-
.../DefaultDataIdentificationTest.java | 44 ++-
.../org/apache/sis/test/mock/MetadataMock.java | 15 +-
.../apache/sis/test/suite/MetadataTestSuite.java | 2 +-
.../sis/test/xml/AnnotationConsistencyCheck.java | 17 +-
.../apache/sis/test/integration/MetadataTest.java | 18 +-
.../apache/sis/internal/util/CollectionsExt.java | 21 ++
.../sis/internal/util/TreeFormatCustomization.java | 8 +
.../sis/util/collection/TreeTableFormat.java | 32 +-
.../earthobservation/LandsatReaderTest.java | 2 +-
.../apache/sis/internal/storage/xml/StoreTest.java | 6 +-
56 files changed, 1886 insertions(+), 887 deletions(-)
delete mode 100644 core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_CharacterSetLegacy.java
create mode 100644 core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAndCharset.java
create mode 100644 core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/OtherLocales.java
delete mode 100644 core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java
copy {storage/sis-xmlstore/src/main/java/org/apache/sis/storage/gps => core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/legacy}/package-info.java (87%)
create mode 100644 core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/lan/OtherLocalesTest.java
delete mode 100644 core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/OtherLocalesTest.java
[sis] 01/02: Merge branch 'geoapi-4.0' into geoapi-3.1 but without
changing the Medium.name property type for compatibility reason.
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-3.1
in repository https://gitbox.apache.org/repos/asf/sis.git
commit dc69af044f679a4a8cda3a85ddcb4687c18b45c5
Merge: 8164ff4 6640cc3
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu May 2 11:45:25 2019 +0200
Merge branch 'geoapi-4.0' into geoapi-3.1 but without changing the Medium.name property type for compatibility reason.
.../sis/internal/jaxb/code/MD_MediumNameCode.java | 2 +-
.../sis/internal/metadata/legacy/package-info.java | 26 ++++++++++
.../metadata/iso/distribution/DefaultMedium.java | 56 ++++++++++++++++++++--
3 files changed, 78 insertions(+), 6 deletions(-)
diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
index b301b20,fdcbfc4..d3abded
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
@@@ -26,18 -26,19 +26,21 @@@ import javax.xml.bind.annotation.XmlRoo
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opengis.util.InternationalString;
import org.opengis.metadata.Identifier;
+ import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.distribution.Medium;
+import org.opengis.metadata.distribution.MediumName;
import org.opengis.metadata.distribution.MediumFormat;
import org.apache.sis.measure.ValueRange;
- import org.apache.sis.metadata.TitleProperty;
import org.apache.sis.metadata.iso.ISOMetadata;
++import org.apache.sis.metadata.iso.citation.DefaultCitation;
import org.apache.sis.internal.jaxb.gco.GO_Real;
import org.apache.sis.internal.jaxb.FilterByVersion;
- import org.apache.sis.internal.xml.LegacyNamespaces;
+ import org.apache.sis.internal.jaxb.metadata.CI_Citation;
import org.apache.sis.internal.jaxb.metadata.MD_Identifier;
-import org.apache.sis.internal.metadata.legacy.MediumName;
+ import org.apache.sis.internal.xml.LegacyNamespaces;
import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
++import org.apache.sis.internal.util.CodeLists;
import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
@@@ -70,7 -71,7 +73,7 @@@
@XmlType(name = "MD_Medium_Type", propOrder = {
"identifier", // New in ISO 19115-3
"name",
- "legacyName", // From ISO 19115:2003
++ "newName", // From ISO 19115:2014
"density",
"densities",
"densityUnits",
@@@ -179,23 -180,21 +182,31 @@@ public class DefaultMedium extends ISOM
/**
* Returns the name of the medium on which the resource can be received.
*
++ * <div class="warning"><b>Upcoming API change</b><br>
++ * {@link MediumName} may be replaced by {@link Citation} in GeoAPI 4.0.
++ * </div>
++ *
* @return name of the medium, or {@code null}.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-389">SIS-389</a>
+ *
*/
@Override
-- @XmlElement(name = "name")
- @XmlJavaTypeAdapter(CI_Citation.Since2014.class)
- public Citation getName() {
- return name;
++ @XmlElement(name = "name", namespace = LegacyNamespaces.GMD)
+ public MediumName getName() {
- return name;
++ return FilterByVersion.LEGACY_METADATA.accept() ? name : null;
}
/**
* Sets the name of the medium on which the resource can be received.
*
++ * <div class="warning"><b>Upcoming API change</b><br>
++ * {@link MediumName} may be replaced by {@link Citation} in GeoAPI 4.0.
++ * </div>
++ *
* @param newValue the new name.
*/
- public void setName(final Citation newValue) {
+ public void setName(final MediumName newValue) {
checkWritePermission(name);
name = newValue;
}
@@@ -389,4 -388,33 +400,39 @@@
public void setIdentifier(final Identifier newValue) {
super.setIdentifier(newValue);
}
+
+
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////
+ //////// ////////
+ //////// XML support with JAXB ////////
+ //////// ////////
+ //////// The following methods are invoked by JAXB using reflection (even if ////////
+ //////// they are private) or are helpers for other methods invoked by JAXB. ////////
+ //////// Those methods can be safely removed if Geographic Markup Language ////////
+ //////// (GML) support is not needed. ////////
+ //////// ////////
+ //////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Returns the medium name as a code list.
+ */
- @XmlElement(name = "name", namespace = LegacyNamespaces.GMD)
- private MediumName getLegacyName() {
- return FilterByVersion.LEGACY_METADATA.accept() ? MediumName.castOrWrap(name) : null;
++ @XmlElement(name = "name")
++ @XmlJavaTypeAdapter(CI_Citation.Since2014.class)
++ private Citation getNewName() {
++ return (name != null) ? new DefaultCitation(name.name()) : null;
+ }
+
+ /**
+ * Sets the name of the medium on which the resource can be received.
+ */
- private void setLegacyName(final MediumName newValue) {
- name = newValue;
++ private void setNewName(final Citation newValue) {
++ if (newValue != null) {
++ final InternationalString title = newValue.getTitle();
++ if (title != null) {
++ name = CodeLists.forName(MediumName.class, title.toString(), false);
++ }
++ }
+ }
}
[sis] 02/02: Merge branch 'geoapi-4.0' into geoapi-3.1.
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-3.1
in repository https://gitbox.apache.org/repos/asf/sis.git
commit 0018ef82310b7413dfc88ccfca67ed262ae2a8dc
Merge: dc69af0 50b074f
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun May 5 23:56:44 2019 +0200
Merge branch 'geoapi-4.0' into geoapi-3.1.
.../apache/sis/internal/jaxb/cat/CodeListUID.java | 3 +-
.../internal/jaxb/code/MD_CharacterSetLegacy.java | 84 -----
.../sis/internal/jaxb/lan/LocaleAdapter.java | 62 ++++
.../sis/internal/jaxb/lan/LocaleAndCharset.java | 400 +++++++++++++++++++++
.../apache/sis/internal/jaxb/lan/OtherLocales.java | 150 ++++++++
.../apache/sis/internal/jaxb/lan/PT_Locale.java | 216 ++++++++---
.../internal/metadata/LegacyPropertyAdapter.java | 37 +-
.../org/apache/sis/internal/metadata/Merger.java | 83 ++++-
.../sis/internal/metadata/MetadataUtilities.java | 42 +++
.../apache/sis/internal/metadata/OtherLocales.java | 189 ----------
.../apache/sis/internal/simple/SimpleMetadata.java | 21 +-
.../apache/sis/metadata/ModifiableMetadata.java | 170 +++++++--
.../org/apache/sis/metadata/PropertyAccessor.java | 48 ++-
.../java/org/apache/sis/metadata/SpecialCases.java | 30 +-
.../java/org/apache/sis/metadata/TreeNode.java | 61 +++-
.../org/apache/sis/metadata/TreeNodeChildren.java | 51 +--
.../iso/DefaultExtendedElementInformation.java | 7 +-
.../apache/sis/metadata/iso/DefaultMetadata.java | 265 ++++++++------
.../sis/metadata/iso/citation/DefaultContact.java | 7 +-
.../iso/content/DefaultCoverageDescription.java | 9 +-
.../DefaultFeatureCatalogueDescription.java | 76 ++--
.../sis/metadata/iso/content/package-info.java | 4 +-
.../DefaultDigitalTransferOptions.java | 2 +-
.../metadata/iso/distribution/DefaultFormat.java | 3 +-
.../metadata/iso/distribution/DefaultMedium.java | 5 +-
.../identification/DefaultDataIdentification.java | 126 ++++---
.../metadata/iso/identification/package-info.java | 7 +-
.../maintenance/DefaultMaintenanceInformation.java | 5 +-
.../org/apache/sis/metadata/iso/package-info.java | 8 +-
.../sis/metadata/iso/quality/DefaultScope.java | 3 +-
.../main/java/org/apache/sis/util/iso/Types.java | 6 +-
.../java/org/apache/sis/xml/ValueConverter.java | 2 +-
.../org/apache/sis/xml/RenameOnExport.lst | 2 +-
.../org/apache/sis/xml/RenameOnImport.lst | 2 +-
.../sis/internal/jaxb/lan/LanguageCodeTest.java | 6 +-
.../sis/internal/jaxb/lan/OtherLocalesTest.java | 112 ++++++
.../sis/internal/jaxb/lan/PT_LocaleTest.java | 12 +-
.../apache/sis/internal/metadata/MergerTest.java | 13 +-
.../internal/metadata/MetadataUtilitiesTest.java | 32 +-
.../sis/internal/metadata/OtherLocalesTest.java | 129 -------
.../apache/sis/metadata/PropertyAccessorTest.java | 8 +-
.../sis/metadata/PropertyConsistencyCheck.java | 23 +-
.../sis/metadata/iso/CustomMetadataTest.java | 2 +
.../sis/metadata/iso/DefaultMetadataTest.java | 20 +-
.../DefaultDataIdentificationTest.java | 44 ++-
.../org/apache/sis/test/mock/MetadataMock.java | 15 +-
.../apache/sis/test/suite/MetadataTestSuite.java | 2 +-
.../sis/test/xml/AnnotationConsistencyCheck.java | 17 +-
.../apache/sis/test/integration/MetadataTest.java | 18 +-
.../apache/sis/internal/util/CollectionsExt.java | 21 ++
.../sis/internal/util/TreeFormatCustomization.java | 8 +
.../sis/util/collection/TreeTableFormat.java | 32 +-
.../earthobservation/LandsatReaderTest.java | 2 +-
.../apache/sis/internal/storage/xml/StoreTest.java | 6 +-
54 files changed, 1831 insertions(+), 877 deletions(-)
diff --cc core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java
index bada66b,5454a81..68ca3de
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java
@@@ -135,11 -146,11 +146,11 @@@ public class SimpleMetadata implements
}
/**
- * The character coding standard used for the metadata set.
- * Also the character coding standard(s) used for the dataset.
+ * @deprecated As of SIS 1.0, replaced by {@link #getLocalesAndCharsets()}.
*/
@Override
+ @Deprecated
- public Collection<Charset> getCharacterSets() {
+ public final Collection getCharacterSets() {
return Collections.emptySet(); // We use 'Set' because we handle 'Charset' like a CodeList.
}
diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
index d4470ce,a6e3c3a..aab0ae8
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
@@@ -557,7 -557,8 +558,7 @@@ public class DefaultExtendedElementInfo
* @since 0.5
*/
public void setRationale(final InternationalString newValue) {
- rationales = writeCollection(LegacyPropertyAdapter.asCollection(newValue), rationales, InternationalString.class);
- checkWritePermission(rationale);
- rationale = newValue;
++ rationales = writeCollection(CollectionsExt.singletonOrEmpty(newValue), rationales, InternationalString.class);
}
/**
diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
index a28bfaf,d67d579..f1f2012
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
@@@ -189,17 -197,12 +197,12 @@@ public class DefaultMetadata extends IS
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 7337533776231004504L;
-
- /**
- * Language(s) used for documenting metadata.
- */
- private Collection<Locale> languages;
- private static final long serialVersionUID = -1128741312274891545L;
++ private static final long serialVersionUID = -76483485174667242L;
/**
- * Full name of the character coding standard used for the metadata set.
+ * Language(s) and character set(s) used within the dataset.
*/
- private Collection<Charset> characterSets;
+ private Map<Locale,Charset> locales;
/**
* Identification of the parent metadata record.
@@@ -345,10 -348,9 +348,9 @@@
if (object != null) {
identifiers = singleton(object.getMetadataIdentifier(), Identifier.class);
parentMetadata = object.getParentMetadata();
- languages = copyCollection(object.getLanguages(), Locale.class);
- characterSets = copyCollection(object.getCharacterSets(), Charset.class);
+ locales = copyMap (object.getLocalesAndCharsets(), Locale.class);
metadataScopes = copyCollection(object.getMetadataScopes(), MetadataScope.class);
- contacts = copyCollection(object.getContacts(), Responsibility.class);
+ contacts = copyCollection(object.getContacts(), ResponsibleParty.class);
dateInfo = copyCollection(object.getDateInfo(), CitationDate.class);
metadataStandards = copyCollection(object.getMetadataStandards(), Citation.class);
metadataProfiles = copyCollection(object.getMetadataProfiles(), Citation.class);
@@@ -630,25 -678,23 +678,11 @@@
*/
@Override
@Deprecated
- @Dependencies("getCharacterSets")
- @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD)
+ @Dependencies("getLocalesAndCharsets")
+ // @XmlElement at the end of this class.
public CharacterSet getCharacterSet() {
- if (FilterByVersion.LEGACY_METADATA.accept()) {
- final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(),
- Charset.class, null, DefaultMetadata.class, "getCharacterSet");
- if (cs != null) {
- final String name = cs.name();
- for (final CharacterSet candidate : CharacterSet.values()) {
- for (final String n : candidate.names()) {
- if (name.equals(n)) {
- return candidate;
- }
- final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(),
- Charset.class, null, DefaultMetadata.class, "getCharacterSet");
- if (cs != null) {
- final String name = cs.name();
- for (final CharacterSet candidate : CharacterSet.values()) {
- for (final String n : candidate.names()) {
- if (name.equals(n)) {
- return candidate;
-- }
-- }
- return CharacterSet.valueOf(name);
-- }
- return CharacterSet.valueOf(name);
-- }
-- return null;
++ return CharacterSet.fromCharset(LegacyPropertyAdapter.getSingleton(getCharacterSets(),
++ Charset.class, null, DefaultMetadata.class, "getCharacterSet"));
}
/**
diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
index d3abded,c262b5c..8d8166c
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
@@@ -37,10 -35,11 +37,11 @@@ import org.apache.sis.internal.jaxb.gco
import org.apache.sis.internal.jaxb.FilterByVersion;
import org.apache.sis.internal.jaxb.metadata.CI_Citation;
import org.apache.sis.internal.jaxb.metadata.MD_Identifier;
- import org.apache.sis.internal.xml.LegacyNamespaces;
-import org.apache.sis.internal.metadata.legacy.MediumName;
import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
+ import org.apache.sis.internal.xml.LegacyNamespaces;
+ import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.util.CodeLists;
import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
index 53e9d92,f7bb052..4dedc6c
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
@@@ -16,23 -16,24 +16,26 @@@
*/
package org.apache.sis.metadata.iso.identification;
+ import java.util.Map;
import java.util.Collection;
+ import java.util.Collections;
import java.util.Locale;
import java.nio.charset.Charset;
++import java.util.stream.Collectors;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
- import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opengis.util.InternationalString;
import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.identification.CharacterSet;
import org.opengis.metadata.identification.TopicCategory;
import org.opengis.metadata.identification.DataIdentification;
- import org.apache.sis.internal.metadata.OtherLocales;
- import org.apache.sis.internal.jaxb.lan.LocaleAdapter;
+ import org.apache.sis.internal.jaxb.lan.LocaleAndCharset;
+ import org.apache.sis.internal.jaxb.lan.OtherLocales;
+ import org.apache.sis.internal.jaxb.lan.PT_Locale;
import org.apache.sis.internal.xml.LegacyNamespaces;
import org.apache.sis.internal.jaxb.FilterByVersion;
- import org.apache.sis.internal.util.CollectionsExt;
+ import org.apache.sis.internal.metadata.Dependencies;
/**
@@@ -72,8 -73,8 +75,8 @@@
* @module
*/
@XmlType(name = "MD_DataIdentification_Type", propOrder = {
- "language", // Legacy ISO 19115:2003
- "characterSets", // Legacy ISO 19115:2003
+ "languages", // Legacy ISO 19115:2003
- "characterSets", // Legacy ISO 19115:2003
++ "characterSet", // Legacy ISO 19115:2003
"defaultLocale", // New in ISO 19115:2014
"otherLocales", // New in ISO 19115:2014
"environmentDescription",
@@@ -214,29 -245,29 +247,41 @@@ public class DefaultDataIdentification
/**
* Returns the character coding standard used for the dataset.
*
+ * <div class="warning"><b>Upcoming API change — JDK integration</b><br>
+ * The element type may change to the {@link Charset} class in GeoAPI 4.0.
+ * </div>
+ *
* @return character coding standard(s) used.
+ *
+ * @deprecated Replaced by {@code getLocalesAndCharsets().values()}.
*/
@Override
- @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD)
+ @Deprecated
+ @Dependencies("getLocalesAndCharsets")
- @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD)
- public Collection<Charset> getCharacterSets() {
- return FilterByVersion.LEGACY_METADATA.accept() ? LocaleAndCharset.getCharacterSets(getLocalesAndCharsets()) : null;
++ // @XmlElement at the end of this class.
+ public Collection<CharacterSet> getCharacterSets() {
- return characterSets = nonNullCollection(characterSets, CharacterSet.class);
++ return getLocalesAndCharsets().values().stream().map(CharacterSet::fromCharset).collect(Collectors.toSet());
}
/**
* Sets the character coding standard used for the dataset.
*
+ * <div class="warning"><b>Upcoming API change — JDK integration</b><br>
+ * The element type may change to the {@link Charset} class in GeoAPI 4.0.
+ * </div>
+ *
* @param newValues the new character sets.
+ *
+ * @deprecated Replaced by putting values in {@link #getLocalesAndCharsets()} map.
*/
+ @Deprecated
- public void setCharacterSets(final Collection<? extends Charset> newValues) {
+ public void setCharacterSets(final Collection<? extends CharacterSet> newValues) {
- characterSets = writeCollection(newValues, characterSets, CharacterSet.class);
+ // TODO: delete after SIS 1.0 release (method not needed by JAXB).
- setLocalesAndCharsets(LocaleAndCharset.setCharacterSets(getLocalesAndCharsets(), newValues));
++ Collection<Charset> c = null;
++ if (newValues != null) {
++ c = newValues.stream().map(CharacterSet::toCharset).collect(Collectors.toSet());
++ }
++ setLocalesAndCharsets(LocaleAndCharset.setCharacterSets(getLocalesAndCharsets(), c));
}
/**
@@@ -316,17 -347,7 +361,18 @@@
* Gets the other locales for this record (used in ISO 19115-3 format).
*/
@XmlElement(name = "otherLocale")
- private Collection<Locale> getOtherLocales() {
- return FilterByVersion.CURRENT_METADATA.accept() ? OtherLocales.filter(getLanguages()) : null;
+ private Collection<PT_Locale> getOtherLocales() {
+ return FilterByVersion.CURRENT_METADATA.accept() ? OtherLocales.filter(getLocalesAndCharsets()) : null;
}
+
+ /**
- * Returns the locale to marshal if the XML document is to be written
- * according the legacy ISO 19115:2003 model.
++ * Returns the character coding for the metadata set (used in legacy ISO 19157 format).
++ *
++ * @see #getCharacterSets()
+ */
- @XmlElement(name = "language", namespace = LegacyNamespaces.GMD)
- @XmlJavaTypeAdapter(LocaleAdapter.class)
- private Collection<Locale> getLanguage() {
- return FilterByVersion.LEGACY_METADATA.accept() ? getLanguages() : null;
++ @Dependencies("getLocalesAndCharsets")
++ @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD)
++ private Collection<Charset> getCharacterSet() {
++ return FilterByVersion.LEGACY_METADATA.accept() ? LocaleAndCharset.getCharacterSets(getLocalesAndCharsets()) : null;
+ }
}
diff --cc core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
index 4ce4f45,5dc44ac..5a41a2b
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
@@@ -20,6 -20,6 +20,7 @@@ import java.util.Map
import java.util.HashMap;
import java.util.Collection;
import java.util.Locale;
++import java.nio.charset.Charset;
import java.lang.reflect.Proxy;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationHandler;