This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new b522442 Call to DefaultMetadata.serLanguage(Locale) should preserve
the Charset.
b522442 is described below
commit b52244226f374e8f74e0279e87b0c9e390a69434
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue May 7 17:11:24 2019 +0200
Call to DefaultMetadata.serLanguage(Locale) should preserve the Charset.
---
.../sis/internal/jaxb/lan/LocaleAdapter.java | 2 +-
.../apache/sis/internal/jaxb/lan/OtherLocales.java | 3 +++
.../apache/sis/internal/jaxb/lan/PT_Locale.java | 23 ++++++++++++++--------
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
index 651f797..71b5b84 100644
---
a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
+++
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocaleAdapter.java
@@ -121,7 +121,7 @@ public final class LocaleAdapter extends
XmlAdapter<LanguageCode, Locale> {
return null;
}
PT_Locale p = new PT_Locale(value);
- p.setCharacterSet(null); // For forcing creating of
child element.
+ p.setCharacterSet(null); // For forcing creation of
child `element`.
return p;
}
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/OtherLocales.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/OtherLocales.java
index 1624b2e..815385b 100644
---
a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/OtherLocales.java
+++
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/OtherLocales.java
@@ -137,6 +137,9 @@ public final class OtherLocales extends
AbstractSet<PT_Locale> {
keys = addTo.keySet().toArray();
values = addTo.values().toArray();
addTo.clear();
+ if (newValue.getCharacterSet() == null) {
+ newValue.setCharacterSet((Charset) values[0]);
+ }
}
newValue.addInto(addTo);
if (keys != null) {
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
index d714ff6..b1f234b 100644
---
a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
+++
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/PT_Locale.java
@@ -237,13 +237,6 @@ public final class PT_Locale {
}
/**
- * Sets the character set to the given value.
- */
- final void setCharacterSet(final Charset encoding) {
- element = new Wrapper(locale, encoding);
- }
-
- /**
* Returns the Java locale wrapped by this {@link PT_Locale} instance.
* This method returns a cached instance if possible.
*
@@ -257,6 +250,20 @@ public final class PT_Locale {
}
/**
+ * Returns the character set, or {@code null} if none.
+ */
+ final Charset getCharacterSet() {
+ return (element != null) ? element.characterEncoding : null;
+ }
+
+ /**
+ * Sets the character set to the given value.
+ */
+ final void setCharacterSet(final Charset encoding) {
+ element = new Wrapper(locale, encoding);
+ }
+
+ /**
* Infers a locale and character set from this wrapper and adds them as an
entry in the given map.
*
* @param addTo the map where to add an entry for the locale and
character set.
@@ -264,7 +271,7 @@ public final class PT_Locale {
*/
final boolean addInto(final Map<Locale,Charset> addTo) {
final Locale locale = getLocale();
- final Charset encoding = (element != null) ? element.characterEncoding
: null;
+ final Charset encoding = getCharacterSet();
if (locale != null || encoding != null) {
// We need a special check if (encoding == null) since put(…) !=
encoding will not work in that case.
final boolean wasAbsent = (encoding == null) &&
!addTo.containsKey(locale);