sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1730357 - /sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
Date Sun, 14 Feb 2016 16:43:58 GMT
Author: desruisseaux
Date: Sun Feb 14 16:43:58 2016
New Revision: 1730357

URL: http://svn.apache.org/viewvc?rev=1730357&view=rev
Log:
Avoid throwin an exception when formatting a message with non-formattable units.

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1730357&r1=1730356&r2=1730357&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] Sun Feb 14 16:43:58 2016
@@ -30,6 +30,7 @@ import java.util.ResourceBundle;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.lang.reflect.Modifier;
+import javax.measure.unit.Unit;
 import org.opengis.util.CodeList;
 import org.opengis.util.ControlledVocabulary;
 import org.opengis.util.InternationalString;
@@ -41,6 +42,7 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.internal.util.PatchedUnitFormat;
 
 
 /**
@@ -70,7 +72,7 @@ import org.apache.sis.internal.system.Lo
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public class IndexedResourceBundle extends ResourceBundle implements Localized {
@@ -411,12 +413,14 @@ public class IndexedResourceBundle exten
                 replacement = Classes.getShortName(getPublicType((Class<?>) element));
             } else if (element instanceof ControlledVocabulary) {
                 replacement = Types.getCodeTitle((ControlledVocabulary) element).toString(getLocale());
+            } else if (element instanceof Unit<?>) {
+                replacement = PatchedUnitFormat.toString((Unit<?>) element);
             }
             // No need to check for Numbers or Dates instances, since they are
             // properly formatted in the ResourceBundle locale by MessageFormat.
             if (replacement != element) {
                 if (array == arguments) {
-                    array = array.clone(); // Protect the user-provided array from change.
+                    array = array.clone();                  // Protect the user-provided
array from change.
                 }
                 array[i] = replacement;
             }



Mime
View raw message