sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Consolidation: - Remove CollectionsExt.nonEmptyIterator, replaced by cleaner use of nonNull(Collection). - Remove (text != null && !(text = text.trim()).isEmpty()) statement (they were many), replaced by a call to new internal method Strings.trimOrNull(String). - Add an IdentifiedObjects.getDisplayName method as use it where we intended to have a name for displaying purpose.
Date Mon, 04 Nov 2019 19:58:52 GMT
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 ac48b98  Consolidation: - Remove CollectionsExt.nonEmptyIterator, replaced by cleaner use of nonNull(Collection). - Remove (text != null && !(text = text.trim()).isEmpty()) statement (they were many), replaced by a call to new internal method Strings.trimOrNull(String). - Add an IdentifiedObjects.getDisplayName method as use it where we intended to have a name for displaying purpose.
ac48b98 is described below

commit ac48b98da66b3fa59009ad38bcbd4f31b9342177
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Nov 4 20:56:25 2019 +0100

    Consolidation:
    - Remove CollectionsExt.nonEmptyIterator, replaced by cleaner use of nonNull(Collection).
    - Remove (text != null && !(text = text.trim()).isEmpty()) statement (they were many), replaced by a call to new internal method Strings.trimOrNull(String).
    - Add an IdentifiedObjects.getDisplayName method as use it where we intended to have a name for displaying purpose.
---
 .../org/apache/sis/gui/dataset/ResourceTree.java   |  19 +-
 .../apache/sis/gui/metadata/MetadataSummary.java   |   9 +-
 .../org/apache/sis/gui/metadata/MetadataTree.java  |   8 +-
 .../sis/gui/metadata/RepresentationInfo.java       |   2 +-
 .../java/org/apache/sis/feature/FeatureFormat.java |   5 +-
 .../org/apache/sis/filter/BetweenFunctionTest.java |   2 +-
 .../apache/sis/internal/jaxb/gco/PropertyType.java |   4 +-
 .../apache/sis/internal/metadata/Identifiers.java  |  14 +-
 .../sis/metadata/iso/citation/Citations.java       |  13 +-
 .../apache/sis/metadata/sql/MetadataWriter.java    |  26 +--
 .../org/apache/sis/util/iso/DefaultRecord.java     |   4 +-
 .../sis/referencing/gazetteer/LocationFormat.java  |   2 +-
 .../org/apache/sis/geometry/ArrayEnvelope.java     |   2 +-
 .../internal/referencing/DefinitionVerifier.java   |  10 +-
 .../referencing/GeodeticObjectBuilder.java         |   2 +-
 .../sis/referencing/AbstractIdentifiedObject.java  |   2 +-
 .../apache/sis/referencing/GeodeticCalculator.java |   2 +-
 .../apache/sis/referencing/IdentifiedObjects.java  | 209 +++++++++++++--------
 .../sis/referencing/datum/BursaWolfParameters.java |   3 +-
 .../referencing/factory/sql/EPSGDataAccess.java    |  13 +-
 .../apache/sis/referencing/operation/CRSPair.java  |   2 +-
 .../operation/transform/ConcatenatedTransform.java |   5 +-
 .../apache/sis/internal/util/CollectionsExt.java   |  24 +--
 .../java/org/apache/sis/internal/util/Strings.java |  32 +++-
 .../org/apache/sis/internal/util/package-info.java |   2 +-
 .../java/org/apache/sis/util/CharSequences.java    |   5 +
 .../java/org/apache/sis/internal/netcdf/Node.java  |   7 +-
 .../sis/internal/netcdf/ucar/VariableWrapper.java  |   4 +-
 .../apache/sis/storage/netcdf/MetadataReader.java  |  21 +--
 .../org/apache/sis/storage/netcdf/NetcdfStore.java |   4 +-
 .../org/apache/sis/internal/sql/feature/Table.java |  10 +-
 .../sis/internal/sql/feature/TableReference.java   |  11 +-
 .../java/org/apache/sis/storage/sql/SQLStore.java  |   5 +-
 .../sis/internal/storage/MetadataBuilder.java      |  28 +--
 .../org/apache/sis/internal/storage/wkt/Store.java |   2 +-
 .../storage/xml/stream/StaxStreamReader.java       |  10 +-
 36 files changed, 278 insertions(+), 245 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
index 9aa3290..f3b7593 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
@@ -58,6 +58,7 @@ import org.apache.sis.internal.gui.BackgroundThreads;
 import org.apache.sis.internal.gui.ExceptionReporter;
 import org.apache.sis.internal.gui.Resources;
 import org.apache.sis.internal.gui.Styles;
+import org.apache.sis.internal.util.Strings;
 
 
 /**
@@ -326,10 +327,8 @@ public class ResourceTree extends TreeView<Resource> {
              * the same product, while the display name have better chances to be distinct for each file.
              */
             if (resource instanceof DataStore) {
-                String name = ((DataStore) resource).getDisplayName();
-                if (name != null && !(name = name.trim()).isEmpty()) {
-                    return name;
-                }
+                final String name = Strings.trimOrNull(((DataStore) resource).getDisplayName());
+                if (name != null) return name;
             }
             /*
              * Search for a title in metadata first because it has better chances
@@ -383,13 +382,7 @@ public class ResourceTree extends TreeView<Resource> {
      * Returns the given international string as a non-empty localized string, or {@code null} if none.
      */
     private String string(final InternationalString i18n) {
-        if (i18n != null) {
-            String t = i18n.toString(getLocale());
-            if (t != null && !(t = t.trim()).isEmpty()) {
-                return t;
-            }
-        }
-        return null;
+        return (i18n != null) ? Strings.trimOrNull(i18n.toString(getLocale())) : null;
     }
 
     /**
@@ -397,8 +390,8 @@ public class ResourceTree extends TreeView<Resource> {
      * This method returns the message if one exist, or the exception class name otherwise.
      */
     private String string(final Throwable failure) {
-        String text = Exceptions.getLocalizedMessage(failure, getLocale());
-        if (text == null || (text = text.trim()).isEmpty()) {
+        String text = Strings.trimOrNull(Exceptions.getLocalizedMessage(failure, getLocale()));
+        if (text == null) {
             text = Classes.getShortClassName(failure);
         }
         return text;
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
index beded69..a61b4e2 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
@@ -43,6 +43,7 @@ import org.opengis.util.InternationalString;
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.internal.gui.BackgroundThreads;
 import org.apache.sis.internal.gui.Resources;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.Resource;
 import org.apache.sis.util.iso.Types;
@@ -330,12 +331,6 @@ public class MetadataSummary {
      * Returns the given international string as a non-empty localized string, or {@code null} if none.
      */
     final String string(final InternationalString i18n) {
-        if (i18n != null) {
-            String t = i18n.toString(localized.getLocale());
-            if (t != null && !(t = t.trim()).isEmpty()) {
-                return t;
-            }
-        }
-        return null;
+        return (i18n != null) ? Strings.trimOrNull(i18n.toString(localized.getLocale())) : null;
     }
 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
index eb5f379..19b52e6 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
@@ -282,16 +282,12 @@ public class MetadataTree extends TreeTableView<TreeTable.Node> {
      * This method is invoked by JavaFX when a new cell needs to be rendered.
      */
     private static ObservableValue<Object> getPropertyValue(final CellDataFeatures<TreeTable.Node, Object> cell) {
+        final MetadataTree view = (MetadataTree) cell.getTreeTableView();
         Object value = getValue(cell, TableColumn.VALUE);
         if (value instanceof IdentifiedObject) {
-            String name = IdentifiedObjects.getName((IdentifiedObject) value, null);
-            if (name == null) {
-                name = IdentifiedObjects.getIdentifierOrName((IdentifiedObject) value);
-            }
-            value = name;
+            value = IdentifiedObjects.getDisplayName((IdentifiedObject) value, view.textLocale);
         }
         if (value instanceof InternationalString) {
-            final MetadataTree view = (MetadataTree) cell.getTreeTableView();
             value = ((InternationalString) value).toString(view.textLocale);
         }
         return new ReadOnlyObjectWrapper<>(value);
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java
index 3bb134c..bdf9450 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/RepresentationInfo.java
@@ -82,7 +82,7 @@ final class RepresentationInfo extends Section<SpatialRepresentation> {
         if (info instanceof GridSpatialRepresentation) {
             build((GridSpatialRepresentation) info);
         }
-        addLine(Resources.Keys.ReferenceSystem, IdentifiedObjects.getName(referenceSystem, null));
+        addLine(Resources.Keys.ReferenceSystem, IdentifiedObjects.getDisplayName(referenceSystem, owner.localized.getLocale()));
     }
 
     /**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
index 7bcc201..9edfad4 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
@@ -43,6 +43,7 @@ import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.feature.Geometries;
 import org.apache.sis.internal.system.Modules;
@@ -364,8 +365,8 @@ public class FeatureFormat extends TabularFormat<Object> {
             }
             final InternationalString definition = featureType.getDefinition();
             if (definition != null) {
-                String text = definition.toString(displayLocale);
-                if (text != null && !(text = text.trim()).isEmpty()) {
+                final String text = Strings.trimOrNull(definition.toString(displayLocale));
+                if (text != null) {
                     toAppendTo.append(getLineSeparator()).append(text);
                 }
             }
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/BetweenFunctionTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/BetweenFunctionTest.java
index 1dc4204..e313ae0 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/filter/BetweenFunctionTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/BetweenFunctionTest.java
@@ -47,7 +47,7 @@ public final strictfp class BetweenFunctionTest extends TestCase {
 
     /**
      * Expected name of the filter to be evaluated. The {@link #evaluate(Filter)} method
-     * will compare {@link Filter#getName()} against this value.
+     * will compare {@link Node#getName()} against this value.
      */
     private String expectedName;
 
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
index 61571b8..bb2bcc4 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
@@ -30,6 +30,7 @@ import org.apache.sis.xml.IdentifierMap;
 import org.apache.sis.xml.IdentifierSpace;
 import org.apache.sis.xml.IdentifiedObject;
 import org.apache.sis.xml.ReferenceResolver;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.FilterByVersion;
 import org.apache.sis.internal.jaxb.PrimitiveTypeProperties;
@@ -453,7 +454,8 @@ public abstract class PropertyType<ValueType extends PropertyType<ValueType,Boun
      * @category xlink
      */
     public final void setTitle(String title) {
-        if (title != null && !(title = title.trim()).isEmpty()) {
+        title = Strings.trimOrNull(title);
+        if (title != null) {
             xlink(true).setTitle(new SimpleInternationalString(title));
         }
     }
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
index 1fb8556..0a8ba40 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
@@ -17,7 +17,6 @@
 package org.apache.sis.internal.metadata;
 
 import java.util.Locale;
-import java.util.Iterator;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.util.InternationalString;
@@ -33,8 +32,8 @@ import org.apache.sis.util.Static;
 /**
  * Methods working on {@link Identifier} instances.
  *
- * @author Martin Desruisseaux (Geomatys)
- * @since   1.0
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   1.1
  * @version 1.0
  * @module
  */
@@ -113,9 +112,7 @@ public final class Identifiers extends Static {
             boolean isUnicode = false;      // Whether 'identifier' is a Unicode identifier.
             String identifier = null;       // The best identifier found so far.
             String codeSpace  = null;       // Code space of the identifier, or null if none.
-            final Iterator<? extends Identifier> it = CollectionsExt.nonEmptyIterator(citation.getIdentifiers());
-            if (it != null) while (it.hasNext()) {
-                final Identifier id = it.next();
+            for (final Identifier id : CollectionsExt.nonNull(citation.getIdentifiers())) {
                 if (id != null && !isDeprecated(id)) {
                     final String candidate = CharSequences.trimWhitespaces(id.getCode());
                     if (candidate != null && !candidate.isEmpty()) {
@@ -173,9 +170,8 @@ public final class Identifiers extends Static {
                     }
                 }
                 if (!isUnicode) {
-                    final Iterator<? extends InternationalString> iterator = CollectionsExt.nonEmptyIterator(citation.getAlternateTitles());
-                    if (iterator != null) while (iterator.hasNext()) {
-                        final String candidate = toString(iterator.next());
+                    for (final InternationalString i18n : CollectionsExt.nonNull(citation.getAlternateTitles())) {
+                        final String candidate = toString(i18n);
                         if (candidate != null && !candidate.isEmpty()) {
                             isUnicode = CharSequences.isUnicodeIdentifier(candidate);
                             if (identifier == null || isUnicode) {
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
index e82ca78..8cf4b86 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
@@ -39,8 +39,6 @@ import org.apache.sis.internal.system.Modules;
 import org.apache.sis.internal.system.SystemListener;
 import org.apache.sis.metadata.iso.DefaultIdentifier;           // For javadoc
 
-import static org.apache.sis.internal.util.CollectionsExt.nonEmptyIterator;
-
 
 /**
  * A set of pre-defined constants and static methods working on {@linkplain Citation citations}.
@@ -532,6 +530,17 @@ public final class Citations extends Static {
     }
 
     /**
+     * Returns the collection iterator, or {@code null} if the given collection is null or empty.
+     *
+     * @param  <E>         the type of elements in the collection.
+     * @param  collection  the collection from which to get the iterator, or {@code null}.
+     * @return the iterator over the given collection elements, or {@code null}.
+     */
+    private static <E> Iterator<E> nonEmptyIterator(final Collection<E> collection) {
+        return (collection != null && !collection.isEmpty()) ? collection.iterator() : null;
+    }
+
+    /**
      * Returns {@code true} if at least one {@linkplain DefaultCitation#getTitle() title} or
      * {@linkplain DefaultCitation#getAlternateTitles() alternate title} in {@code c1} is leniently
      * equal to a title or alternate title in {@code c2}. The comparison is case-insensitive
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
index 9cf1602..1c28195 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
@@ -52,6 +52,7 @@ import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.internal.metadata.sql.SQLBuilder;
 import org.apache.sis.internal.metadata.sql.Reflection;
 import org.apache.sis.internal.util.Constants;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.xml.IdentifiedObject;
 
 // Branch-dependent imports
@@ -348,7 +349,7 @@ public class MetadataWriter extends MetadataSource {
          * etc.) is associated only to Responsibility. So it make sense to use the Responsibility ID for
          * the contact info.
          */
-        identifier = nonEmpty(removeReservedChars(suggestIdentifier(metadata, asValueMap), null));
+        identifier = Strings.trimOrNull(removeReservedChars(suggestIdentifier(metadata, asValueMap), null));
         if (identifier == null) {
             identifier = parent;
             if (identifier == null) {
@@ -704,9 +705,9 @@ public class MetadataWriter extends MetadataSource {
             identifiers = Collections.emptySet();
         }
         for (final Identifier id : identifiers) {
-            identifier = nonEmpty(id.getCode());
+            identifier = Strings.trimOrNull(id.getCode());
             if (identifier != null) {
-                final String cs = nonEmpty(id.getCodeSpace());
+                final String cs = Strings.trimOrNull(id.getCodeSpace());
                 if (cs != null) {
                     identifier = cs + Constants.DEFAULT_SEPARATOR + identifier;
                 }
@@ -714,14 +715,14 @@ public class MetadataWriter extends MetadataSource {
             }
         }
         if (identifier == null && metadata instanceof Citation) {
-            identifier = nonEmpty(Citations.toCodeSpace((Citation) metadata));
+            identifier = Strings.trimOrNull(Citations.toCodeSpace((Citation) metadata));
         }
         if (identifier == null) {
             final TitleProperty tp = metadata.getClass().getAnnotation(TitleProperty.class);
             if (tp != null) {
-                final Object value = asValueMap.get(nonEmpty(tp.name()));
+                final Object value = asValueMap.get(Strings.trimOrNull(tp.name()));
                 if (value != null) {
-                    identifier = nonEmpty(value.toString());
+                    identifier = Strings.trimOrNull(value.toString());
                 }
             }
         }
@@ -789,17 +790,4 @@ public class MetadataWriter extends MetadataSource {
     private static boolean isReservedChar(final int c) {
         return (c == TableHierarchy.TYPE_OPEN) || (c == TableHierarchy.TYPE_CLOSE);
     }
-
-    /**
-     * Trims leading and trailing spaces and returns the given value if non-empty, or {@code null} otherwise.
-     */
-    private static String nonEmpty(String value) {
-        if (value != null) {
-            value = value.trim();
-            if (value.isEmpty()) {
-                value = null;
-            }
-        }
-        return value;
-    }
 }
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
index 7cf3c79..a9b0563 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
@@ -33,6 +33,7 @@ import org.opengis.util.RecordType;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.internal.util.AbstractMapEntry;
 import org.apache.sis.internal.metadata.RecordSchemaSIS;
 
@@ -448,7 +449,8 @@ public class DefaultRecord implements Record, Serializable {
      * @see <a href="https://issues.apache.org/jira/browse/SIS-419">SIS-419</a>
      */
     private void setValue(String value) {
-        if (value != null && !(value = value.trim()).isEmpty()) {
+        value = Strings.trimOrNull(value);
+        if (value != null) {
             values = new String[] {value};
         }
     }
diff --git a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java
index 6febadd..39d3b6d 100644
--- a/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java
+++ b/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java
@@ -411,7 +411,7 @@ public class LocationFormat extends TabularFormat<Location> {
             }
         }
         if (crs != null) {
-            append(table, vocabulary, Vocabulary.Keys.CoordinateRefSys, IdentifiedObjects.getName(crs, null));
+            append(table, vocabulary, Vocabulary.Keys.CoordinateRefSys, IdentifiedObjects.getDisplayName(crs, locale));
         }
         /*
          * Organization responsible for defining the characteristics of the location instance.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
index 5dd86cd..6601090 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
@@ -370,7 +370,7 @@ scanNumber: while ((i += Character.charCount(c)) < length) {
     static String illegalRange(final CoordinateReferenceSystem crs,
             final int dimension, final double lower, final double upper)
     {
-        Object name = IdentifiedObjects.getName(getAxis(crs, dimension), null);
+        Object name = IdentifiedObjects.getDisplayName(getAxis(crs, dimension), null);
         if (name == null) {
             name = dimension;       // Paranoiac fallback (name should never be null).
         }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DefinitionVerifier.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DefinitionVerifier.java
index 07cf2cf..04ddd40 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DefinitionVerifier.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/DefinitionVerifier.java
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.referencing;
 
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import org.opengis.util.FactoryException;
@@ -99,6 +100,11 @@ public final class DefinitionVerifier {
     private Object[] arguments;
 
     /**
+     * The locale, fixed for now but may become configurable in a future version.
+     */
+    private static final Locale locale = null;
+
+    /**
      * Creates the result of a call to {@code withAuthority(…)}.
      */
     private DefinitionVerifier(final CoordinateReferenceSystem authoritative) {
@@ -228,7 +234,7 @@ public final class DefinitionVerifier {
             }
         }
         if (verifier.arguments != null) {
-            verifier.arguments[0] = IdentifiedObjects.getName(crs, null);
+            verifier.arguments[0] = IdentifiedObjects.getDisplayName(crs, locale);
             verifier.arguments[1] = IdentifiedObjects.getIdentifierOrName(authoritative);
         }
         return verifier;
@@ -288,7 +294,7 @@ public final class DefinitionVerifier {
     public LogRecord warning(final boolean fine) {
         if (arguments != null) {
             if (resourceKey != 0) {
-                return Resources.forLocale(null).getLogRecord(Level.WARNING, resourceKey, arguments);
+                return Resources.forLocale(locale).getLogRecord(Level.WARNING, resourceKey, arguments);
             } else if (fine) {
                 return new LogRecord(Level.FINE, (String) arguments[0]);
             }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java
index 683a1ca..22ad543 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java
@@ -572,6 +572,6 @@ public final class GeodeticObjectBuilder extends Builder<GeodeticObjectBuilder>
             }
         }
         throw new IllegalArgumentException(Resources.forLocale(locale).getString(
-                Resources.Keys.CanNotSeparateCRS_1, IdentifiedObjects.getName(source, null)));
+                Resources.Keys.CanNotSeparateCRS_1, IdentifiedObjects.getDisplayName(source, locale)));
     }
 }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
index 2823f05..5fd6849 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
@@ -904,7 +904,7 @@ public class AbstractIdentifiedObject extends FormattableObject implements Ident
         if ((flags & FormattableFlags.ALTERNATE) != 0) {
             value = IdentifiedObjects.getIdentifierOrName(this);
         } else {
-            value = IdentifiedObjects.getName(this, null);
+            value = IdentifiedObjects.getDisplayName(this, formatter.locale());
         }
         Strings.formatTo(formatter, flags, width, precision, value);
     }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java
index dcf9399..8ed2c3b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticCalculator.java
@@ -360,7 +360,7 @@ public class GeodeticCalculator {
      */
     private String transformError(final boolean toCRS) {
         return Resources.format(Resources.Keys.CanNotConvertCoordinates_2,
-                toCRS ? 1 : 0, IdentifiedObjects.getName(getPositionCRS(), null));
+                toCRS ? 1 : 0, IdentifiedObjects.getDisplayName(getPositionCRS(), null));
     }
 
     /**
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
index 17b943c..bf616ce 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
@@ -20,12 +20,13 @@ import java.util.Map;
 import java.util.Set;
 import java.util.List;
 import java.util.LinkedHashSet;
-import java.util.Iterator;
 import java.util.Collection;
+import java.util.Locale;
 
 import org.opengis.util.NameSpace;
 import org.opengis.util.GenericName;
 import org.opengis.util.FactoryException;
+import org.opengis.util.InternationalString;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.IdentifiedObject;
@@ -37,6 +38,7 @@ import org.apache.sis.util.Static;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.logging.Logging;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.DefinitionURI;
 import org.apache.sis.internal.system.Modules;
@@ -48,7 +50,7 @@ import org.apache.sis.referencing.factory.IdentifiedObjectFinder;
 import org.apache.sis.referencing.factory.GeodeticAuthorityFactory;
 import org.apache.sis.referencing.factory.NoSuchAuthorityFactoryException;
 
-import static org.apache.sis.internal.util.CollectionsExt.iterator;
+import static org.apache.sis.internal.util.CollectionsExt.nonNull;
 
 
 /**
@@ -154,7 +156,7 @@ public final class IdentifiedObjects extends Static {
      *       compares the {@linkplain GenericName#scope() name scope} against the specified citation
      *       using the {@link Citations#identifierMatches(Citation, String)} method.
      *       If a matching is found, then this method returns the
-     *       {@linkplain GenericName#tip() name tip} of that object.</li>
+     *       {@linkplain GenericName#toString() string representation} of that name.</li>
      * </ul>
      *
      * Note that alias may implement both the {@link Identifier} and {@link GenericName}
@@ -164,8 +166,8 @@ public final class IdentifiedObjects extends Static {
      * @param  object     the object to get the name from, or {@code null}.
      * @param  authority  the authority for the name to return, or {@code null} for any authority.
      * @return the object's name (either an {@linkplain Identifier#getCode() identifier code}
-     *         or a {@linkplain GenericName#tip() name tip}), or {@code null} if no name matching the
-     *         specified authority has been found.
+     *         or a {@linkplain GenericName#toString() generic name}),
+     *         or {@code null} if no name matching the specified authority has been found.
      *
      * @see AbstractIdentifiedObject#getName()
      */
@@ -176,20 +178,20 @@ public final class IdentifiedObjects extends Static {
     /**
      * Returns an object name according the given authority. This method is {@code null}-safe:
      * every properties are checked for null values, even the properties that are supposed to
-     * be mandatory (not all implementation defines all mandatory values).
+     * be mandatory (not all implementations define all mandatory values).
      *
      * @param  object     the object to get the name from, or {@code null}.
      * @param  authority  the authority for the name to return, or {@code null} for any authority.
      * @param  addTo      if non-null, the collection where to add all names found.
      * @return the object's name (either an {@linkplain Identifier#getCode() identifier code}
-     *         or a {@linkplain GenericName#tip() name tip}), or {@code null} if no name matching the
-     *         specified authority has been found.
+     *         or a {@linkplain GenericName#toString() generic name}),
+     *         or {@code null} if no name matching the specified authority has been found.
      */
     private static String getName(final IdentifiedObject object, final Citation authority, final Collection<String> addTo) {
         if (object != null) {
             Identifier identifier = object.getName();
-            if (authority == null) {
-                if (identifier != null) {
+            if (identifier != null) {
+                if (authority == null || Citations.identifierMatches(authority, identifier.getAuthority())) {
                     final String name = identifier.getCode();
                     if (name != null) {
                         if (addTo == null) {
@@ -198,64 +200,35 @@ public final class IdentifiedObjects extends Static {
                         addTo.add(name);
                     }
                 }
-                final Iterator<GenericName> it = iterator(object.getAlias());
-                while (it.hasNext()) {
-                    final GenericName alias = it.next();
-                    if (alias != null) {
-                        final String name = (alias instanceof Identifier) ?
-                                ((Identifier) alias).getCode() : alias.toString();
-                        if (name != null) {
-                            if (addTo == null) {
-                                return name;
-                            }
-                            addTo.add(name);
+            }
+            /*
+             * If we do not found a primary name for the specified authority,
+             * or if the user requested all names, search among aliases.
+             */
+            for (final GenericName alias : nonNull(object.getAlias())) {
+                if (alias != null) {
+                    final String name;
+                    if (alias instanceof Identifier) {
+                        identifier = (Identifier) alias;
+                        if (authority != null && !Citations.identifierMatches(authority, identifier.getAuthority())) {
+                            continue;               // Authority does not match. Search another alias.
                         }
-                    }
-                }
-            } else {
-                if (identifier != null) {
-                    if (Citations.identifierMatches(authority, identifier.getAuthority())) {
-                        final String name = identifier.getCode();
-                        if (name != null) {
-                            if (addTo == null) {
-                                return name;
+                        name = identifier.getCode();
+                    } else {
+                        if (authority != null) {
+                            final NameSpace ns = alias.scope();  if (ns    == null) continue;
+                            final GenericName scope = ns.name(); if (scope == null) continue;
+                            if (!Citations.identifierMatches(authority, scope.toString())) {
+                                continue;           // Authority does not match. Search another alias.
                             }
-                            addTo.add(name);
                         }
+                        name = alias.toString();
                     }
-                }
-                final Iterator<GenericName> it = iterator(object.getAlias());
-                while (it.hasNext()) {
-                    final GenericName alias = it.next();
-                    if (alias != null) {
-                        if (alias instanceof Identifier) {
-                            identifier = (Identifier) alias;
-                            if (Citations.identifierMatches(authority, identifier.getAuthority())) {
-                                final String name = identifier.getCode();
-                                if (name != null) {
-                                    if (addTo == null) {
-                                        return name;
-                                    }
-                                    addTo.add(name);
-                                }
-                            }
-                        } else {
-                            final NameSpace ns = alias.scope();
-                            if (ns != null) {
-                                final GenericName scope = ns.name();
-                                if (scope != null) {
-                                    if (Citations.identifierMatches(authority, scope.toString())) {
-                                        final String name = alias.toString();
-                                        if (name != null) {
-                                            if (addTo == null) {
-                                                return name;
-                                            }
-                                            addTo.add(name);
-                                        }
-                                    }
-                                }
-                            }
+                    if (name != null) {
+                        if (addTo == null) {
+                            return name;
                         }
+                        addTo.add(name);
                     }
                 }
             }
@@ -279,10 +252,8 @@ public final class IdentifiedObjects extends Static {
      */
     public static Identifier getIdentifier(final IdentifiedObject object, final Citation authority) {
         if (object != null) {
-            final Iterator<? extends Identifier> it = iterator(object.getIdentifiers());
-            while (it.hasNext()) {
-                final Identifier identifier = it.next();
-                if (identifier != null) {                           // Paranoiac check.
+            for (final Identifier identifier : nonNull(object.getIdentifiers())) {
+                if (identifier != null) {                       // Paranoiac check.
                     if (authority == null || Citations.identifierMatches(authority, identifier.getAuthority())) {
                         return identifier;
                     }
@@ -315,9 +286,8 @@ public final class IdentifiedObjects extends Static {
      */
     public static String getIdentifierOrName(final IdentifiedObject object) {
         if (object != null) {
-            final Iterator<? extends Identifier> it = iterator(object.getIdentifiers());
-            while (it.hasNext()) {
-                final String code = toString(it.next());
+            for (final Identifier id : nonNull(object.getIdentifiers())) {
+                final String code = toString(id);
                 if (code != null) {                                 // Paranoiac check.
                     return code;
                 }
@@ -341,6 +311,10 @@ public final class IdentifiedObjects extends Static {
      *   <li><code>object.{@linkplain AbstractIdentifiedObject#getIdentifiers() getIdentifiers()}</code> in iteration order</li>
      * </ul>
      *
+     * This method is can be used for fetching a more human-friendly identifier than the numerical values
+     * typically returned by {@link IdentifiedObject#getIdentifiers()}. However the returned value is not
+     * guaranteed to be unique.
+     *
      * @param  object  the identified object, or {@code null}.
      * @return the first name, alias or identifier which is a valid Unicode identifier, or {@code null} if none.
      *
@@ -353,15 +327,13 @@ public final class IdentifiedObjects extends Static {
     public static String getSimpleNameOrIdentifier(final IdentifiedObject object) {
         if (object != null) {
             Identifier identifier = object.getName();
-            if (identifier != null) {                               // Paranoiac check.
+            if (identifier != null) {                                       // Paranoiac check.
                 final String code = identifier.getCode();
                 if (CharSequences.isUnicodeIdentifier(code)) {
                     return code;
                 }
             }
-            final Iterator<GenericName> it = iterator(object.getAlias());
-            while (it.hasNext()) {
-                GenericName alias = it.next();
+            for (GenericName alias : nonNull(object.getAlias())) {
                 if (alias != null && (alias = alias.tip()) != null) {
                     final String code = alias.toString();
                     if (CharSequences.isUnicodeIdentifier(code)) {
@@ -369,11 +341,9 @@ public final class IdentifiedObjects extends Static {
                     }
                 }
             }
-            final Iterator<? extends Identifier> id = iterator(object.getIdentifiers());
-            while (id.hasNext()) {
-                identifier = id.next();
-                if (identifier != null) {                           // Paranoiac check.
-                    final String code = identifier.getCode();
+            for (final Identifier id : nonNull(object.getIdentifiers())) {
+                if (id != null) {                                           // Paranoiac check.
+                    final String code = id.getCode();
                     if (CharSequences.isUnicodeIdentifier(code)) {
                         return code;
                     }
@@ -384,6 +354,44 @@ public final class IdentifiedObjects extends Static {
     }
 
     /**
+     * Returns a name that can be used for display purpose. This method returns the first non-blank
+     * {@linkplain AbstractIdentifiedObject#getName() name},
+     * {@linkplain AbstractIdentifiedObject#getAlias() alias} or
+     * {@linkplain AbstractIdentifiedObject#getIdentifiers() identifier}, in that order.
+     * The name should never be missing, but this method nevertheless fallbacks on aliases and identifiers
+     * as a safety against incomplete implementations. If an identifier implements {@link GenericName}
+     * (as with {@link NamedIdentifier}), its {@link GenericName#toInternationalString() toInternationalString()}
+     * method will be used.
+     *
+     * @param  object  the identified object, or {@code null}.
+     * @param  locale  the locale for the name to return, or {@code null} for the default.
+     * @return a name for human reading, or {@code null} if none were found.
+     *
+     * @since 1.1
+     */
+    public static String getDisplayName(final IdentifiedObject object, final Locale locale) {
+        if (object == null) {
+            return null;
+        }
+        String name = toString(object.getName(), locale);
+alt:    if (name == null) {
+            for (final GenericName c : nonNull(object.getAlias())) {
+                name = toString(c, locale);
+                if (name != null) break alt;
+            }
+            for (final Identifier id : nonNull(object.getIdentifiers())) {
+                name = toString(id, locale);
+                if (name != null) break alt;
+            }
+            return null;
+        }
+        if (name.indexOf(' ') < 0) {
+            name = CharSequences.camelCaseToSentence(name).toString();
+        }
+        return name;
+    }
+
+    /**
      * Looks up a URN, such as {@code "urn:ogc:def:crs:EPSG:9.1:4326"}, of the specified object.
      * This method searches in all {@linkplain org.apache.sis.referencing.factory.GeodeticAuthorityFactory geodetic
      * authority factories} known to SIS for an object {@linkplain org.apache.sis.util.ComparisonMode#APPROXIMATE
@@ -772,4 +780,47 @@ public final class IdentifiedObjects extends Static {
         }
         return code;
     }
+
+    /**
+     * Returns a localized name for the given identifier if possible, or the identifier code otherwise.
+     * This method performs paranoiac checks against null or empty values. We do not provides this method
+     * in public API because those aggressive checks may be unexpected. It is okay when we merely want to
+     * provide a label for human reading.
+     *
+     * @param  identifier  the identifier for which to get a localized string representation.
+     * @param  locale      the desired locale, or {@code null} for the default.
+     * @return string representation, or {@code null} if none.
+     */
+    private static String toString(final Identifier identifier, final Locale locale) {
+        if (identifier == null) return null;
+        if (identifier instanceof GenericName) {
+            final String name = toString(((GenericName) identifier).tip(), locale);
+            if (name != null) return name;
+        }
+        return Strings.trimOrNull(identifier.getCode());
+    }
+
+    /**
+     * Returns a string representation of the given name in the given locale.
+     * This method performs paranoiac checks against null or empty values.
+     * We do not provides this method in public API because those aggressive checks may be unexpected.
+     * It is okay when we merely want to provide a label for human reading.
+     *
+     * @param  name    the name for which to get a localized string representation.
+     * @param  locale  the desired locale, or {@code null} for the default.
+     * @return localized string representation, or {@code null} if none.
+     */
+    private static String toString(final GenericName name, final Locale locale) {
+        if (name == null) {
+            return null;
+        }
+        if (locale != null) {
+            final InternationalString i18n = name.toInternationalString();
+            if (i18n != null) {
+                final String s = Strings.trimOrNull(i18n.toString(locale));
+                if (s != null) return s;
+            }
+        }
+        return Strings.trimOrNull(name.toString());
+    }
 }
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
index 4f5fe29..6d276ad 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
@@ -249,7 +249,8 @@ public class BursaWolfParameters extends FormattableObject implements Cloneable,
             final PrimeMeridian actual = targetDatum.getPrimeMeridian();
             if (actual.getGreenwichLongitude() != 0 && !Utilities.equalsIgnoreMetadata(pm, actual)) {
                 throw new IllegalArgumentException(Resources.format(Resources.Keys.MismatchedPrimeMeridian_2,
-                        IdentifiedObjects.getName(pm, null), IdentifiedObjects.getName(actual, null)));
+                        IdentifiedObjects.getDisplayName(pm, null),
+                        IdentifiedObjects.getDisplayName(actual, null)));
             }
         }
         ensureFinite("tX", tX);
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index 7d6d56e..f26d0d8 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@ -84,6 +84,7 @@ import org.apache.sis.internal.system.Semaphores;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.StandardDateFormat;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.citation.DefaultOnlineResource;
 import org.apache.sis.metadata.iso.extent.DefaultExtent;
@@ -842,8 +843,8 @@ codes:  for (int i=0; i<codes.length; i++) {
      * @throws SQLException if an error occurred while querying the database.
      */
     private static String getOptionalString(final ResultSet result, final int columnIndex) throws SQLException {
-        String value = result.getString(columnIndex);
-        return (value != null) && !(value = value.trim()).isEmpty() && !result.wasNull() ? value : null;
+        final String value = Strings.trimOrNull(result.getString(columnIndex));
+        return (value == null) || result.wasNull() ? null : value;
     }
 
     /**
@@ -903,8 +904,8 @@ codes:  for (int i=0; i<codes.length; i++) {
     private String getString(final String code, final ResultSet result, final int columnIndex, final int columnFault)
             throws SQLException, FactoryDataException
     {
-        String value = result.getString(columnIndex);
-        if (value == null || (value = value.trim()).isEmpty() || result.wasNull()) {
+        final String value = Strings.trimOrNull(result.getString(columnIndex));
+        if (value == null || result.wasNull()) {
             throw new FactoryDataException(nullValue(result, columnFault, code));
         }
         return value;
@@ -924,8 +925,8 @@ codes:  for (int i=0; i<codes.length; i++) {
     private String getString(final Comparable<?> code, final ResultSet result, final int columnIndex)
             throws SQLException, FactoryDataException
     {
-        String value = result.getString(columnIndex);
-        if (value == null || (value = value.trim()).isEmpty() || result.wasNull()) {
+        final String value = Strings.trimOrNull(result.getString(columnIndex));
+        if (value == null || result.wasNull()) {
             throw new FactoryDataException(nullValue(result, columnIndex, code));
         }
         return value;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java
index adc53e9..95f9cbc 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CRSPair.java
@@ -106,7 +106,7 @@ final class CRSPair {
                 label = sb.append(((CoordinateSystem) cs).getDimension()).append('D').toString();
             }
         }
-        String name = IdentifiedObjects.getName(object, null);
+        String name = IdentifiedObjects.getDisplayName(object, null);
         if (name != null) {
             int i = 30;                                         // Arbitrary length threshold.
             if (name.length() >= i) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
index 5c6288d..987429e 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
@@ -37,6 +37,7 @@ import org.apache.sis.internal.referencing.provider.GeocentricAffine;
 import org.apache.sis.internal.referencing.WKTKeywords;
 import org.apache.sis.internal.referencing.Resources;
 import org.apache.sis.internal.system.Semaphores;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.Utilities;
@@ -277,8 +278,8 @@ class ConcatenatedTransform extends AbstractMathTransform implements Serializabl
             params = ((Parameterized) transform).getParameterValues();
         }
         if (params != null) {
-            String name = params.getDescriptor().getName().getCode();
-            if (name != null && !(name = name.trim()).isEmpty()) {
+            final String name = Strings.trimOrNull(params.getDescriptor().getName().getCode());
+            if (name != null) {
                 return name;
             }
         }
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
index 04fc7b2..7a8a982 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
@@ -49,7 +49,7 @@ import static org.apache.sis.util.collection.Containers.hashMapCapacity;
  * bit tedious to explain, which is an other indication that they should not be in public API.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 1.0
+ * @version 1.1
  * @since   0.3
  * @module
  */
@@ -123,28 +123,6 @@ public final class CollectionsExt extends Static {
     }
 
     /**
-     * Returns the collection iterator, or {@code null} if the given collection is null or empty.
-     *
-     * @param  <E>         the type of elements in the collection.
-     * @param  collection  the collection from which to get the iterator, or {@code null}.
-     * @return the iterator over the given collection elements, or {@code null}.
-     */
-    public static <E> Iterator<E> nonEmptyIterator(final Collection<E> collection) {
-        return (collection != null && !collection.isEmpty()) ? collection.iterator() : null;
-    }
-
-    /**
-     * Returns the collection iterator. This is a null-safe method used as a safety against broken implementations.
-     *
-     * @param  <E>         the type of elements in the collection.
-     * @param  collection  the collection from which to get the iterator, or {@code null}.
-     * @return the iterator over the given collection elements, never {@code null}.
-     */
-    public static <E> Iterator<E> iterator(final Collection<E> collection) {
-        return (collection != null) ? collection.iterator() : Collections.emptyIterator();
-    }
-
-    /**
      * Returns the first element of the given iterable, or {@code null} if none.
      * This method does not emit warning if more than one element is found.
      * Consequently, this method should be used only when multi-occurrence is not ambiguous.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Strings.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Strings.java
index 9558156..1167d1f 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Strings.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Strings.java
@@ -30,7 +30,7 @@ import org.apache.sis.util.CharSequences;
  * Most of those methods are for {@link Object#toString()} implementations.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
  * @since   0.3
  * @module
  */
@@ -54,6 +54,36 @@ public final class Strings extends Static {
     }
 
     /**
+     * Trims the leading and trailing spaces of the given string.
+     * If the string is null, empty or contains only spaces, then this method returns {@code null}.
+     *
+     * <p>Note that this method strips white spaces too, including no-break spaces.
+     * In some cases this is not wanted, for example if the text is a programmatic identifier
+     * (maybe the developer really wanted no-break spaces). To preserve no-break spaces, the
+     * following can be used instead:</p>
+     *
+     * {@preformat java
+     *     if (text != null && !(text = text.trim()).isEmpty()) {
+     *         // Use text here.
+     *     }
+     * }
+     *
+     * @param  text  the text to trim, or {@code null}.
+     * @return the trimmed text, or {@code null} if the given text was null or blank.
+     *
+     * @since 1.1
+     */
+    public static String trimOrNull(String text) {
+        if (text != null) {
+            text = CharSequences.trimWhitespaces(text.trim());
+            if (text.isEmpty()) {
+                return null;
+            }
+        }
+        return text;
+    }
+
+    /**
      * Appends to the given buffer only the characters that are valid for a Unicode identifier.
      * The given separator character is append before the given {@code text} only if the buffer
      * is not empty and at least one {@code text} character is valid.
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java
index 8faba8f..54cd1b9 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java
@@ -30,7 +30,7 @@
  * so some serialized classes still exist in this package.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
  * @since   0.3
  * @module
  */
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java b/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
index 7b0d8b5..7448785 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
@@ -542,6 +542,7 @@ search:     for (; fromIndex <= toIndex; fromIndex++) {
      *
      * @see #skipTrailingWhitespaces(CharSequence, int, int)
      * @see #trimWhitespaces(CharSequence)
+     * @see String#stripLeading()
      */
     public static int skipLeadingWhitespaces(final CharSequence text, int fromIndex, final int toIndex) {
         while (fromIndex < toIndex) {
@@ -579,6 +580,7 @@ search:     for (; fromIndex <= toIndex; fromIndex++) {
      *
      * @see #skipLeadingWhitespaces(CharSequence, int, int)
      * @see #trimWhitespaces(CharSequence)
+     * @see String#stripTrailing()
      */
     public static int skipTrailingWhitespaces(final CharSequence text, final int fromIndex, int toIndex) {
         while (toIndex > fromIndex) {
@@ -958,6 +960,8 @@ search:     for (; fromIndex <= toIndex; fromIndex++) {
      * @param  text  the text from which to remove leading and trailing whitespaces, or {@code null}.
      * @return a string with leading and trailing whitespaces removed, or {@code null} is the given
      *         text was null.
+     *
+     * @todo To be replaced by {@link String#strip()} in JDK 11.
      */
     public static String trimWhitespaces(String text) {
         if (text != null) {
@@ -980,6 +984,7 @@ search:     for (; fromIndex <= toIndex; fromIndex++) {
      *
      * @see #skipLeadingWhitespaces(CharSequence, int, int)
      * @see #skipTrailingWhitespaces(CharSequence, int, int)
+     * @see String#strip()
      */
     public static CharSequence trimWhitespaces(CharSequence text) {
         if (text != null) {
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Node.java b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Node.java
index 876920a..ea30af4 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Node.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Node.java
@@ -22,6 +22,7 @@ import org.apache.sis.math.Vector;
 import org.apache.sis.math.DecimalFunctions;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.util.Strings;
 
 
 /**
@@ -160,11 +161,9 @@ public abstract class Node extends NamedElement {
         }
         boolean hasValues = false;
         for (int i=0; i<array.length; i++) {
-            String e = array[i];
+            String e = Strings.trimOrNull(array[i]);
             if (e != null) {
-                e = e.trim();
-                if (e.isEmpty()) e = null;
-                else hasValues = true;
+                hasValues = true;
                 array[i] = e;
             }
         }
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
index 1a892a6..027d811 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/VariableWrapper.java
@@ -43,6 +43,7 @@ import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.internal.netcdf.Grid;
 import org.apache.sis.internal.netcdf.Variable;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.measure.NumberRange;
@@ -142,8 +143,7 @@ final class VariableWrapper extends Variable {
      */
     @Override
     protected String getUnitsString() {
-        String symbol = variable.getUnitsString();
-        return (symbol != null && (symbol = symbol.trim()).isEmpty()) ? null : symbol;
+        return Strings.trimOrNull(variable.getUnitsString());
         // Do not replace "N/A" by null since it is a valid unit symbol.
     }
 
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
index 92c4b8d..dc0504f 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
@@ -66,6 +66,7 @@ import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.storage.wkt.StoreFormat;
 import org.apache.sis.internal.referencing.AxisDirections;
 import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.referencing.CRS;
@@ -251,25 +252,11 @@ split:  while ((start = CharSequences.skipLeadingWhitespaces(value, start, lengt
     }
 
     /**
-     * Trims the leading and trailing spaces of the given string.
-     * If the string is null, empty or contains only spaces, then this method returns {@code null}.
-     */
-    private static String trim(String value) {
-        if (value != null) {
-            value = value.trim();
-            if (value.isEmpty()) {
-                value = null;
-            }
-        }
-        return value;
-    }
-
-    /**
      * Reads the attribute value for the given name, then trims the leading and trailing spaces.
      * If the value is null, empty or contains only spaces, then this method returns {@code null}.
      */
     private String stringValue(final String name) {
-        return trim(decoder.stringValue(name));
+        return Strings.trimOrNull(decoder.stringValue(name));
     }
 
     /**
@@ -944,7 +931,7 @@ split:  while ((start = CharSequences.skipLeadingWhitespaces(value, start, lengt
      */
     private void addSampleDimension(final Variable variable) {
         newSampleDimension();
-        final String name = trim(variable.getName());
+        final String name = Strings.trimOrNull(variable.getName());
         if (name != null) {
             final NameFactory f = decoder.nameFactory;
             final StringBuilder buffer = new StringBuilder(20);
@@ -955,7 +942,7 @@ split:  while ((start = CharSequences.skipLeadingWhitespaces(value, start, lengt
         if (id != null && !id.equals(name)) {
             addBandName(variable.getAttributeAsString(ACDD.standard_name_vocabulary), id);
         }
-        final String description = trim(variable.getDescription());
+        final String description = Strings.trimOrNull(variable.getDescription());
         if (description != null && !description.equals(name) && !description.equals(id)) {
             addBandDescription(description);
         }
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
index afaf805..f5b8db7 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
@@ -112,8 +112,8 @@ public class NetcdfStore extends DataStore implements Aggregate {
                     connector.getStorage(), connector.getOption(OptionKey.OPEN_OPTIONS));
         }
         decoder.location = path;
-        String id = decoder.stringValue(ACDD.id);
-        if (id == null || (id = id.trim()).isEmpty()) {
+        String id = Strings.trimOrNull(decoder.stringValue(ACDD.id));
+        if (id == null) {
             id = decoder.getFilename();
         }
         if (id != null) {
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
index 8c2f35a..7ddff4a 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
@@ -44,6 +44,7 @@ import org.apache.sis.internal.metadata.sql.Reflection;
 import org.apache.sis.internal.metadata.sql.SQLUtilities;
 import org.apache.sis.internal.storage.AbstractFeatureSet;
 import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.util.collection.WeakValueHashMap;
 import org.apache.sis.util.collection.TreeTable;
 import org.apache.sis.util.CharSequences;
@@ -394,13 +395,8 @@ final class Table extends AbstractFeatureSet {
         if (id instanceof Relation) {
             try (ResultSet reflect = analyzer.metadata.getTables(id.catalog, schemaEsc, tableEsc, null)) {
                 while (reflect.next()) {
-                    remarks = analyzer.getUniqueString(reflect, Reflection.REMARKS);
-                    if (remarks != null) {
-                        remarks = remarks.trim();
-                        if (remarks.isEmpty()) {
-                            remarks = null;
-                        } else break;
-                    }
+                    remarks = Strings.trimOrNull(analyzer.getUniqueString(reflect, Reflection.REMARKS));
+                    if (remarks != null) break;
                 }
             }
         }
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/TableReference.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/TableReference.java
index 67d05f6..f2d19a8 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/TableReference.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/TableReference.java
@@ -21,6 +21,7 @@ import java.util.function.Consumer;
 import org.opengis.util.LocalName;
 import org.opengis.util.GenericName;
 import org.apache.sis.storage.sql.SQLStoreProvider;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.util.collection.DefaultTreeTable;
 import org.apache.sis.util.collection.TableColumn;
 import org.apache.sis.util.collection.TreeTable;
@@ -52,17 +53,11 @@ class TableReference {
     /**
      * Creates a new tuple with the give names.
      */
-    TableReference(final String catalog, final String schema, final String table, String freeText) {
-        if (freeText != null) {
-            freeText = freeText.trim();
-            if (freeText.isEmpty()) {
-                freeText = null;
-            }
-        }
+    TableReference(final String catalog, final String schema, final String table, final String freeText) {
         this.catalog  = catalog;
         this.schema   = schema;
         this.table    = table;
-        this.freeText = freeText;
+        this.freeText = Strings.trimOrNull(freeText);
     }
 
     /**
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java
index b22b6d2..7ca22ad 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java
@@ -38,6 +38,7 @@ import org.apache.sis.storage.event.WarningEvent;
 import org.apache.sis.internal.sql.feature.Database;
 import org.apache.sis.internal.sql.feature.Resources;
 import org.apache.sis.internal.storage.MetadataBuilder;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Exceptions;
 
@@ -211,8 +212,8 @@ public class SQLStore extends DataStore implements Aggregate {
                 try {
                     final Method method = source.getClass().getMethod(c);
                     if (method.getReturnType() == String.class) {
-                        String name = (String) method.invoke(source);
-                        if (name != null && !(name = name.trim()).isEmpty()) {
+                        final String name = Strings.trimOrNull((String) method.invoke(source));
+                        if (name != null) {
                             builder.addTitle(name);
                             break;
                         }
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
index 665dfcd..6185215 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
@@ -127,6 +127,7 @@ import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.SampleDimension;
 import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.iso.Names;
@@ -930,7 +931,8 @@ public class MetadataBuilder {
      */
     public final void addIdentifier(final CharSequence authority, String code, final Scope scope) {
         ArgumentChecks.ensureNonNull("scope", scope);
-        if (code != null && !(code = code.trim()).isEmpty()) {
+        code = Strings.trimOrNull(code);
+        if (code != null) {
             final Identifier id = sharedIdentifier(authority, code);
             if (scope != Scope.RESOURCE) metadata().setMetadataIdentifier(id);
             if (scope != Scope.METADATA) addIfNotPresent(citation().getIdentifiers(), id);
@@ -2330,7 +2332,8 @@ parse:      for (int i = 0; i < length;) {
      * @param  name       the band name, or {@code null} for no-operation.
      */
     public final void addBandName(final CharSequence authority, String name) {
-        if (name != null && !(name = name.trim()).isEmpty()) {
+        name = Strings.trimOrNull(name);
+        if (name != null) {
             addIfNotPresent(sampleDimension().getNames(), sharedIdentifier(authority, name));
         }
     }
@@ -2503,11 +2506,9 @@ parse:      for (int i = 0; i < length;) {
      *                          or {@code null} for no-operation.
      */
     public final void setProcessingLevelCode(final CharSequence authority, String processingLevel) {
+        processingLevel = Strings.trimOrNull(processingLevel);
         if (processingLevel != null) {
-            processingLevel = processingLevel.trim();
-            if (!processingLevel.isEmpty()) {
-                coverageDescription().setProcessingLevelCode(sharedIdentifier(authority, processingLevel));
-            }
+            coverageDescription().setProcessingLevelCode(sharedIdentifier(authority, processingLevel));
         }
     }
 
@@ -2587,7 +2588,8 @@ parse:      for (int i = 0; i < length;) {
      * @param  identifier  identifier of the platform to add, or {@code null} for no-operation.
      */
     public final void addPlatform(final CharSequence authority, String identifier) {
-        if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
+        identifier = Strings.trimOrNull(identifier);
+        if (identifier != null) {
             if (platform != null) {
                 final Identifier current = platform.getIdentifier();
                 if (current != null) {
@@ -2614,7 +2616,8 @@ parse:      for (int i = 0; i < length;) {
      * @param  identifier  identifier of the sensor to add, or {@code null} for no-operation.
      */
     public final void addInstrument(final CharSequence authority, String identifier) {
-        if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
+        identifier = Strings.trimOrNull(identifier);
+        if (identifier != null) {
             final DefaultInstrument instrument = new DefaultInstrument();
             instrument.setIdentifier(sharedIdentifier(authority, identifier));
             addIfNotPresent(platform().getInstruments(), instrument);
@@ -2659,7 +2662,8 @@ parse:      for (int i = 0; i < length;) {
      * @param  identifier  unique identification of the operation, or {@code null} for no-operation.
      */
     public final void addAcquisitionOperation(final CharSequence program, String identifier) {
-        if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
+        identifier = Strings.trimOrNull(identifier);
+        if (identifier != null) {
             final DefaultOperation r = new DefaultOperation();
             r.setIdentifier(sharedIdentifier(program, identifier));
             addIfNotPresent(acquisition().getOperations(), r);
@@ -2678,7 +2682,8 @@ parse:      for (int i = 0; i < length;) {
      * @param  identifier  unique name or code for the requirement, or {@code null} for no-operation.
      */
     public final void addAcquisitionRequirement(final CharSequence authority, String identifier) {
-        if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
+        identifier = Strings.trimOrNull(identifier);
+        if (identifier != null) {
             final DefaultRequirement r = new DefaultRequirement();
             r.setIdentifier(sharedIdentifier(authority, identifier));
             addIfNotPresent(acquisition().getAcquisitionRequirements(), r);
@@ -2810,7 +2815,8 @@ parse:      for (int i = 0; i < length;) {
      * @see #addSource(CharSequence, ScopeCode, CharSequence)
      */
     public final void addProcessing(final CharSequence authority, String identifier) {
-        if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
+        identifier = Strings.trimOrNull(identifier);
+        if (identifier != null) {
             if (processing != null) {
                 final Identifier current = processing.getIdentifier();
                 if (current != null) {
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
index af7a0d9..00c9308 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
@@ -162,7 +162,7 @@ final class Store extends URIDataStore {
                 if (object instanceof ReferenceSystem) {
                     final ReferenceSystem rs = (ReferenceSystem) object;
                     builder.addReferenceSystem(rs);
-                    name = IdentifiedObjects.getName(rs, null);
+                    name = IdentifiedObjects.getDisplayName(rs, getLocale());
                     count++;
                     builder.addIdentifier(IdentifiedObjects.getIdentifier(rs, null), MetadataBuilder.Scope.RESOURCE);
                 }
diff --git a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java
index 3f3e32d..c526216 100644
--- a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java
+++ b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java
@@ -39,6 +39,7 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.util.Strings;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.StandardDateFormat;
 import org.apache.sis.internal.storage.io.IOUtilities;
@@ -321,14 +322,7 @@ public abstract class StaxStreamReader extends StaxStreamIO implements XMLStream
      * @throws XMLStreamException if a text element can not be returned.
      */
     protected final String getElementText() throws XMLStreamException {
-        String text = reader.getElementText();
-        if (text != null) {
-            text = text.trim();
-            if (!text.isEmpty()) {
-                return text;
-            }
-        }
-        return null;
+        return Strings.trimOrNull(reader.getElementText());
     }
 
     /**


Mime
View raw message