sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1708129 - /sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
Date Mon, 12 Oct 2015 14:27:45 GMT
Author: desruisseaux
Date: Mon Oct 12 14:27:45 2015
New Revision: 1708129

URL: http://svn.apache.org/viewvc?rev=1708129&view=rev
Log:
Relax the restriction on use of '_' in resource keys.

Modified:
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java

Modified: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java?rev=1708129&r1=1708128&r2=1708129&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
[UTF-8] Mon Oct 12 14:27:45 2015
@@ -143,6 +143,7 @@ class IndexedResourceCompiler implements
      * @throws ResourceCompilerException If an error occurred.
      * @return The number of errors found.
      */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     public int run() throws ResourceCompilerException {
         if (!sourceDirectory.isDirectory()) {
             throw new ResourceCompilerException(sourceDirectory + " not found or is not a
directory.");
@@ -323,18 +324,18 @@ class IndexedResourceCompiler implements
              * Checks if the expected arguments count (according to naming conventions)
              * matches the arguments count found in the MessageFormat pattern.
              */
-            final int argumentCount;
+            int argumentCount = 0;
+            String resource = value;
             final int index = key.lastIndexOf(ARGUMENT_COUNT_PREFIX);
-            if (index < 0) {
-                argumentCount = 0;
-                resources.put(key, value); // Text will not be formatted using MessageFormat.
-            } else try {
+            if (index >= 0) try {
                 String suffix = key.substring(index + ARGUMENT_COUNT_PREFIX.length());
                 argumentCount = Integer.parseInt(suffix);
-                resources.put(key, message.toPattern());
+                resource = message.toPattern();
             } catch (NumberFormatException exception) {
-                warning(file, key, "Bad number in resource key", exception);
-                continue;
+                // No warning - allow use of underscore for other purpose.
+            }
+            if (resources.put(key, resource) != null) {
+                warning(file, key, "Duplicated key", null);
             }
             final int expected = message.getFormatsByArgumentIndex().length;
             if (argumentCount != expected) {
@@ -605,6 +606,7 @@ search: for (int i=0; i<buffer.length();
      *
      * @param message The message to log.
      */
+    @SuppressWarnings("UseOfSystemOutOrSystemErr")
     protected void info(final String message) {
         System.out.println(message);
     }
@@ -615,6 +617,7 @@ search: for (int i=0; i<buffer.length();
      *
      * @param message The message to log.
      */
+    @SuppressWarnings("UseOfSystemOutOrSystemErr")
     protected void warning(final String message) {
         System.out.println(message);
     }



Mime
View raw message