sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1551742 [2/3] - in /sis/branches/JDK6: ./ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/ c...
Date Tue, 17 Dec 2013 22:36:51 GMT
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -40,10 +40,11 @@ import org.apache.sis.internal.jdk7.Obje
  */
 final class LocalisedCharacterString {
     /**
-     * A prefix to concatenate with the {@linkplain Locale#getISO3Language() language code}
-     * in order to get the attribute value specified in ISO-19139 for this elements.
+     * A prefix to concatenate with the {@linkplain Locale#getISO3Language() language code}.
+     * This is a hack for a common pattern found in the way locales are specified in ISO 19139 files.
+     * See <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a> for more information.
      */
-    private static final String LOCALE = "#locale-";
+    private static final String PREFIX = "#locale-";
 
     /**
      * The locale value for this string.
@@ -75,10 +76,10 @@ final class LocalisedCharacterString {
     }
 
     /**
-     * Returns the locale language, as specified by ISO-19139 for
-     * {@code <LocalisedCharacterString>} attribute.
+     * Returns the locale language for {@code <LocalisedCharacterString>} attribute.
      *
      * @return The current locale.
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a>
      */
     @XmlAttribute(name = "locale", required = true)
     public String getLocale() {
@@ -86,7 +87,7 @@ final class LocalisedCharacterString {
             return null;
         }
         final Context context = Context.current();
-        return LOCALE.concat(Context.converter(context).toLanguageCode(context, locale));
+        return PREFIX.concat(Context.converter(context).toLanguageCode(context, locale));
     }
 
     /**
@@ -94,6 +95,7 @@ final class LocalisedCharacterString {
      * where {@code xxx} are the two or three letters representing the language.
      *
      * @param localeId The new locale.
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a>
      */
     public void setLocale(final String localeId) {
         if (localeId != null) {

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -104,7 +104,7 @@ public final class CheckedArrayList<E> e
             return false;
         }
         if (element != null) {
-            Context.warningOccured(context, source, source.getClass(), "add",
+            Context.warningOccured(context, source.getClass(), "add",
                     Errors.class, Errors.Keys.IllegalArgumentClass_3, "element", type, element.getClass());
         }
         return true;
@@ -146,8 +146,7 @@ public final class CheckedArrayList<E> e
     private List<E> ensureValidCollection(final Collection<? extends E> collection) throws IllegalArgumentException {
         int count = 0;
         final Object[] array = collection.toArray();
-        for (int i=0; i<array.length; i++) {
-            final Object element = array[i];
+        for (final Object element : array) {
             if (ensureValid((E) element)) {
                 array[count++] = element;
             }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -56,7 +56,7 @@ public final class LocalizedParseExcepti
     /**
      * The resources key as one of the {@code Errors.Keys} constant.
      */
-    private final int key;
+    private final short key;
 
     /**
      * The arguments for the localization message.
@@ -72,7 +72,7 @@ public final class LocalizedParseExcepti
      * @param arguments   The value of {@link #arguments(String, ParsePosition)}.
      * @param errorOffset The position where the error is found while parsing.
      */
-    public LocalizedParseException(final Locale locale, final int key, final Object[] arguments, final int errorOffset) {
+    public LocalizedParseException(final Locale locale, final short key, final Object[] arguments, final int errorOffset) {
         super(Errors.format(key, arguments), errorOffset);
         this.locale    = locale;
         this.arguments = arguments;
@@ -89,7 +89,7 @@ public final class LocalizedParseExcepti
      * @param text        The full text that {@code Format} failed to parse.
      * @param errorOffset The position where the error is found while parsing.
      */
-    public LocalizedParseException(final Locale locale, final int key, final CharSequence text, final int errorOffset) {
+    public LocalizedParseException(final Locale locale, final short key, final CharSequence text, final int errorOffset) {
         this(locale, key, new Object[] {CharSequences.token(text, errorOffset)}, errorOffset);
     }
 
@@ -157,8 +157,8 @@ public final class LocalizedParseExcepti
      * ("Relax constraint on placement of this()/super() call in constructors").
      */
     @Workaround(library="JDK", version="1.7")
-    private static int key(final Object[] arguments) {
-        final int key;
+    private static short key(final Object[] arguments) {
+        final short key;
         switch (arguments.length) {
             case 1: key = Errors.Keys.UnexpectedEndOfString_1;    break;
             case 2: key = Errors.Keys.UnparsableStringForClass_2; break;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/URIParser.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -453,9 +453,7 @@ public final class URIParser {
                  * relative instead than absolute.
                  */
                 int i = url.lastIndexOf('/', f-1) + 1;
-                if (regionMatches(   "gmxUom.xml", url, i, f) ||  // Name used on http://schemas.opengis.net
-                    regionMatches("ML_gmxUom.xml", url, i, f))    // Name used on http://standards.iso.org
-                {
+                if (regionMatches("gmxUom.xml", url, i, f) || regionMatches("ML_gmxUom.xml", url, i, f)) {
                     /*
                      * The fragment should typically be of the form "xpointer(//*[@gml:id='m'])".
                      * However sometime we found no "xpointer", but directly the unit instead.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -682,7 +682,7 @@ public final class MathFunctions extends
         if (ordinal >= MIN_NAN_ORDINAL && ordinal <= MAX_NAN_ORDINAL) {
             return ordinal;
         }
-        final int resourceKey;
+        final short resourceKey;
         final Object obj;
         if (Float.isNaN(value)) {
             resourceKey = Errors.Keys.IllegalBitsPattern_1;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -122,6 +122,8 @@ public class StatisticsFormat extends Ta
 
     /**
      * Returns the kind of objects formatted by this class.
+     *
+     * @return {@code Statistics.class}
      */
     @Override
     public Class<Statistics> getValueType() {
@@ -184,6 +186,9 @@ public class StatisticsFormat extends Ta
 
     /**
      * Not yet implemented.
+     *
+     * @return Currently never return.
+     * @throws ParseException Currently never thrown.
      */
     @Override
     public Statistics parse(CharSequence text, ParsePosition pos) throws ParseException {
@@ -355,7 +360,7 @@ public class StatisticsFormat extends Ta
      * switch statements inside the {@link #format(Statistics[], Appendable)} method
      * (we define this static field close to the format methods for this purpose).
      */
-    private static final int[] KEYS = {
+    private static final short[] KEYS = {
         Vocabulary.Keys.NumberOfValues,
         Vocabulary.Keys.NumberOfNaN,
         Vocabulary.Keys.MinimumValue,

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -129,12 +129,12 @@ public enum About {
     /**
      * The resource key for this section in the {@link Vocabulary} resources bundle.
      */
-    private final int resourceKey;
+    private final short resourceKey;
 
     /**
      * Creates a new section to be formatted using the given resource.
      */
-    private About(final int resourceKey) {
+    private About(final short resourceKey) {
         this.resourceKey = resourceKey;
     }
 
@@ -187,7 +187,7 @@ public enum About {
         TreeTable.Node section = null;
         About newSection = VERSIONS;
 fill:   for (int i=0; ; i++) {
-            int      nameKey  = 0;    // The Vocabulary.Key for 'name', used only if name is null.
+            short    nameKey  = 0;    // The Vocabulary.Key for 'name', used only if name is null.
             String   name     = null; // The value to put in the 'Name' column of the table.
             Object   value    = null; // The value to put in the 'Value' column of the table.
             String[] children = null; // Optional children to write below the node.
@@ -377,7 +377,7 @@ fill:   for (int i=0; ; i++) {
 pathTree:   for (int j=0; ; j++) {
                 TreeTable.Node directory = null;
                 final String home;
-                final int homeKey;
+                final short homeKey;
                 switch (j) {
                     case 0: home = javaHome; homeKey = Vocabulary.Keys.JavaHome; break;
                     case 1: home = userHome; homeKey = Vocabulary.Keys.UserHome; break;
@@ -631,10 +631,12 @@ pathTree:   for (int j=0; ; j++) {
 
     /**
      * Returns the ISO language or country code for the given locale.
+     * Whether we use 2-letters or 3-letters code shall be consistent
+     * with {@link org.apache.sis.xml.ValueConverter}.
      */
     private static String getCode(final Locale locale, final boolean country) {
         try {
-            return country ? locale.getISO3Country() : locale.getISO3Language();
+            return country ? locale.getCountry() : locale.getISO3Language();
         } catch (MissingResourceException e) {
             Logging.recoverableException(About.class, "configuration", e);
             return null;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -182,7 +182,7 @@ public final class ArgumentChecks extend
         if (value != null) {
             final Class<?> valueClass = value.getClass();
             if (!expectedType.isAssignableFrom(valueClass)) {
-                final int key;
+                final short key;
                 final Object[] args;
                 if (name != null) {
                     key = Errors.Keys.IllegalArgumentClass_3;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -20,8 +20,10 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Arrays;
 import java.util.Locale;
+import java.util.TreeMap;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
+import java.util.MissingResourceException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 
@@ -45,7 +47,7 @@ import static org.apache.sis.util.collec
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.4)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final class Locales extends Static {
@@ -66,9 +68,7 @@ public final class Locales extends Stati
          * since we want to give precedence to references to the static constants.
          */
         try {
-            final Field[] fields = Locale.class.getFields();
-            for (int i=0; i<fields.length; i++) {
-                final Field field = fields[i];
+            for (final Field field : Locale.class.getFields()) {
                 if (Modifier.isStatic(field.getModifiers())) {
                     if (Locale.class.isAssignableFrom(field.getType())) {
                         final Locale toAdd = (Locale) field.get(null);
@@ -76,7 +76,7 @@ public final class Locales extends Stati
                     }
                 }
             }
-        } catch (Exception exception) { // Too many exceptions for enumerating them.
+        } catch (IllegalAccessException exception) {
             /*
              * Not a big deal if this operation fails (this is actually just an
              * optimization for reducing memory usage). Log a warning and stop.
@@ -86,6 +86,57 @@ public final class Locales extends Stati
     }
 
     /**
+     * Bit mask for differentiating language codes from country codes in the {@link #ISO2} and {@link #ISO3} arrays.
+     */
+    private static final short LANGUAGE = 0, COUNTRY = Short.MIN_VALUE;
+
+    /**
+     * Mapping from 3-letters codes to 2-letters codes. We use {@code short} type instead of {@link String}
+     * for compactness (conversions is done by {@link #toNumber(String, int)}) and for avoiding references
+     * to {@code String} instances.
+     *
+     * {@note Oracle JDK8 implementation computes the 3-letters codes on-the-fly instead of holding references
+     *        to pre-existing strings. If we were holding string references here, we would prevent the garbage
+     *        collector to collect the strings for all languages and countries. This would probably be a waste
+     *        of resources.}
+     */
+    private static final short[] ISO3, ISO2;
+    static {
+        final Short CONFLICT = (short) 0; // Sentinal value for conflicts (paranoiac safety).
+        final Map<Short,Short> map = new TreeMap<Short,Short>();
+        for (final Locale locale : POOL.values()) {
+            short type = LANGUAGE; // 0 for language, or leftmost bit set for country.
+            do { // Executed exactly twice: once for language, than once for country.
+                final short alpha2 = toNumber((type == LANGUAGE) ? locale.getLanguage() : locale.getCountry(), type);
+                if (alpha2 != 0) {
+                    final short alpha3;
+                    try {
+                        alpha3 = toNumber((type == LANGUAGE) ? locale.getISO3Language() : locale.getISO3Country(), type);
+                    } catch (MissingResourceException e) {
+                        continue; // No 3-letters code to map for this locale.
+                    }
+                    if (alpha3 != 0 && alpha3 != alpha2) {
+                        final Short p = map.put(alpha3, alpha2);
+                        if (p != null && p.shortValue() != alpha2) {
+                            // We do not expect any conflict. But if it happen anyway, conservatively
+                            // remember that we should not perform any substitution for that code.
+                            map.put(alpha3, CONFLICT);
+                        }
+                    }
+                }
+            } while ((type ^= COUNTRY) != LANGUAGE);
+        }
+        while (map.values().remove(CONFLICT)); // Remove all conflicts that we may have found.
+        ISO3 = new short[map.size()];
+        ISO2 = new short[map.size()];
+        int i = 0;
+        for (final Map.Entry<Short,Short> entry : map.entrySet()) {
+            ISO3[i]   = entry.getKey();
+            ISO2[i++] = entry.getValue();
+        }
+    }
+
+    /**
      * All locales available on the JavaVM.
      */
     public static final Locales ALL = new Locales();
@@ -131,13 +182,20 @@ public final class Locales extends Stati
         if (this == ALL) {
             return Locale.getAvailableLocales();
         }
-        final Locale[] languages = getAvailableLanguages();
-        Locale[] locales = Locale.getAvailableLocales();
+        Locale[] locales = getAvailableLanguages();
+        final String[] languages = new String[locales.length];
+        for (int i=0; i<languages.length; i++) {
+            languages[i] = locales[i].getLanguage();
+        }
         int count = 0;
-        for (int i=0; i<locales.length; i++) {
-            final Locale locale = locales[i];
-            if (containsLanguage(languages, locale)) {
-                locales[count++] = unique(locale);
+        locales = Locale.getAvailableLocales();
+filter: for (final Locale locale : locales) {
+            final String code = locale.getLanguage();
+            for (int i=0; i<languages.length; i++) {
+                if (code.equals(languages[i])) {
+                    locales[count++] = unique(locale);
+                    continue filter;
+                }
             }
         }
         locales = ArraysExt.resize(locales, count);
@@ -145,26 +203,15 @@ public final class Locales extends Stati
     }
 
     /**
-     * Returns {@code true} if the specified array of locales contains at least
-     * one element with the specified language.
-     */
-    private static boolean containsLanguage(final Locale[] locales, final Locale language) {
-        final String code = language.getLanguage();
-        for (int i=0; i<locales.length; i++) {
-            if (code.equals(locales[i].getLanguage())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
      * Returns the list of {@linkplain #getAvailableLocales() available locales} formatted
      * as strings in the specified locale.
      *
      * @param  locale The locale to use for formatting the strings to be returned.
      * @return String descriptions of available locales.
+     *
+     * @deprecated Not useful in practice, since we typically also need the original Locale object.
      */
+    @Deprecated // Remove for simplifiying the API.
     public String[] getAvailableLocales(final Locale locale) {
         final Locale[] locales = getAvailableLocales();
         final String[] display = new String[locales.length];
@@ -182,7 +229,10 @@ public final class Locales extends Stati
      *
      * @param  locales The locales from which to get the languages.
      * @return The languages, without country or variant information.
+     *
+     * @deprecated Users can easily perform this operation themselves, thus avoiding this class initialization.
      */
+    @Deprecated // Make this method private for simplifiying the API.
     public static Locale[] getLanguages(final Locale... locales) {
         final Set<String> codes = new LinkedHashSet<String>(hashMapCapacity(locales.length));
         for (final Locale locale : locales) {
@@ -197,37 +247,48 @@ public final class Locales extends Stati
     }
 
     /**
-     * Parses the given locale. The string is the language code either as the 2 letters or the
-     * 3 letters ISO code. It can optionally be followed by the {@code '_'} character and the
-     * country code (again either as 2 or 3 letters), optionally followed by {@code '_'} and
-     * the variant.
-     *
-     * <p>This method can be used when the caller wants the same {@code Locale} constants no
-     * matter if the language and country codes use 2 or 3 letters. Apache SIS usually don't
-     * distinguish those two cases since ISO 19139 documents have to use the 3 letters codes
-     * anyway.</p>
+     * Parses the given language code, optionally followed by country code and variant. The given string can be either
+     * the 2 letters or the 3 letters ISO 639 code. It can optionally be followed by the {@code '_'} character and the
+     * country code (again either as 2 or 3 letters), optionally followed by {@code '_'} and the variant.
+     *
+     * <p>This method can be used when the caller wants the same {@code Locale} constants no matter if the language
+     * and country codes use 2 or 3 letters. This method tries to convert 3-letters codes to 2-letters code on a
+     * <cite>best effort</cite> basis.</p>
      *
-     * @param  code The language code, which may be followed by country code.
+     * @param  code The language code, optionally followed by country code and variant.
      * @return The language for the given code (never {@code null}).
      * @throws IllegalArgumentException If the given code doesn't seem to be a valid locale.
      *
      * @see Locale#forLanguageTag(String)
      */
     public static Locale parse(final String code) throws IllegalArgumentException {
-        ArgumentChecks.ensureNonNull("code", code);
         return parse(code, 0);
     }
 
     /**
-     * Implementation of {@link #parse(String)} which start the parsing process from the given {@code fromIndex}.
+     * Parses the given language code and optional complements (country, variant), starting at the given index.
+     * All characters before {@code fromIndex} are ignored. Characters from {@code fromIndex} to the end of the
+     * string are parsed as documented in the {@link #parse(String)} method. In particular, this method tries to
+     * convert 3-letters codes to 2-letters code on a <cite>best effort</cite> basis.
+     *
+     * {@example This method is useful when language codes are appended to a base property or resource name.
+     *           For example a dictionary may define the <code>"remarks"</code> property by values associated
+     *           to the <code>"remarks_en"</code> and <code>"remarks_fr"</code> keys, for English and French
+     *           locales respectively.}
      *
      * @param  code The language code, which may be followed by country code.
      * @param  fromIndex Index of the first character to parse.
      * @return The language for the given code (never {@code null}).
      * @throws IllegalArgumentException If the given code doesn't seem to be a valid locale.
+     *
+     * @see Locale#forLanguageTag(String)
+     * @see org.apache.sis.util.iso.Types#toInternationalString(Map, String)
      */
-    private static Locale parse(final String code, final int fromIndex) throws IllegalArgumentException {
-        final String language, country, variant;
+    public static Locale parse(final String code, final int fromIndex) throws IllegalArgumentException {
+        ArgumentChecks.ensureNonNull("code", code);
+        ArgumentChecks.ensurePositive("fromIndex", fromIndex);
+        boolean hasMore = false;
+        String language, country, variant;
         int ci = code.indexOf('_', fromIndex);
         if (ci < 0) {
             language = (String) trimWhitespaces(code, fromIndex, code.length());
@@ -242,56 +303,26 @@ public final class Locales extends Stati
             } else {
                 country = (String) trimWhitespaces(code, ci, vi);
                 variant = (String) trimWhitespaces(code, ++vi, code.length());
-                if (code.indexOf('_', vi) >= 0) {
-                    throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalLanguageCode_1,
-                            code.substring(fromIndex)));
-                }
+                hasMore = code.indexOf('_', vi) >= 0;
             }
         }
-        final boolean language3 = isThreeLetters(language);
-        final boolean country3  = isThreeLetters(country);
-        /*
-         * Perform a linear scan only if we need to compare some 3-letters ISO code.
-         * Otherwise (if every code are 2 letters), it will be faster to create a new
-         * locale and check for an existing instance in the hash map.
-         */
-        if (language3 || country3) {
-            String language2 = language;
-            String country2  = country;
-            for (Locale locale : Locale.getAvailableLocales()) {
-                String c = (language3) ? locale.getISO3Language() : locale.getLanguage();
-                if (language.equals(c)) {
-                    if (country2 == country) { // Really identity comparison.
-                        // Remember the 2-letters ISO code in an opportunist way.
-                        // If the 2-letters ISO code has been set for the country
-                        // as well, we will not change the language code because
-                        // it has already been set with the code associated with
-                        // the right country.
-                        language2 = locale.getLanguage();
-                    }
-                    c = (country3) ? locale.getISO3Country() : locale.getCountry();
-                    if (country.equals(c)) {
-                        country2 = locale.getCountry();
-                        if (variant.equals(locale.getVariant())) {
-                            return unique(locale);
-                        }
-                    }
-                }
-            }
-            return unique(new Locale(language2, country2, variant));
+        if (hasMore || language.length() > 3 || country.length() > 3) {
+            throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalLanguageCode_1,
+                    code.substring(fromIndex)));
         }
+        language = toISO2(language, LANGUAGE);
+        country  = toISO2(country,  COUNTRY);
         return unique(new Locale(language, country, variant));
     }
 
     /**
-     * Parses the locale encoded in the suffix of a property key. This convenience method
+     * Parses the language encoded in the suffix of a property key. This convenience method
      * is used when a property in a {@link java.util.Map} may have many localized variants.
      * For example the {@code "remarks"} property may be defined by values associated to the
      * {@code "remarks_en"} and {@code "remarks_fr"} keys, for English and French locales
      * respectively.
      *
-     * <p>This method infers the {@code Locale} from the property {@code key}
-     * with the following steps:</p>
+     * <p>This method infers the {@code Locale} from the property {@code key} with the following steps:</p>
      *
      * <ul>
      *   <li>If the given {@code key} is exactly equals to {@code prefix},
@@ -299,7 +330,7 @@ public final class Locales extends Stati
      *   <li>Otherwise if the given {@code key} does not start with the specified {@code prefix}
      *       followed by the {@code '_'} character, then this method returns {@code null}.</li>
      *   <li>Otherwise, the characters after the {@code '_'} are parsed as an ISO language
-     *       and country code by the {@link #parse(String)} method.</li>
+     *       and country code by the {@link #parse(String, int)} method.</li>
      * </ul>
      *
      * @param  prefix The prefix to skip at the beginning of the {@code key}.
@@ -308,7 +339,10 @@ public final class Locales extends Stati
      * @throws IllegalArgumentException if the locale after the prefix is an illegal code.
      *
      * @see org.apache.sis.util.iso.Types#toInternationalString(Map, String)
+     *
+     * @deprecated Users can easily perform this operation themselves, thus avoiding this class initialization.
      */
+    @Deprecated
     public static Locale parseSuffix(final String prefix, final String key) throws IllegalArgumentException {
         ArgumentChecks.ensureNonNull("prefix", prefix);
         if (key != null) { // Tolerance for Map that accept null keys.
@@ -326,17 +360,57 @@ public final class Locales extends Stati
     }
 
     /**
-     * Returns {@code true} if the following code is 3 letters, or {@code false} if 2 letters.
+     * Converts a 3-letters ISO code to a 2-letters one. If the given code is not recognized,
+     * then this method returns {@code code} unmodified.
+     *
+     * @param  code The 3-letters code.
+     * @param  type Either {@link #LANGUAGE} or {@link #COUNTRY}.
+     * @return The 2-letters code, or {@code null} if none.
+     */
+    private static String toISO2(final String code, final short type) {
+        final short alpha3 = toNumber(code, type);
+        if (alpha3 != 0) {
+            int alpha2 = Arrays.binarySearch(ISO3, alpha3);
+            if (alpha2 >= 0) {
+                alpha2 = ISO2[alpha2];
+                final int base = (alpha2 & COUNTRY) != 0 ? ('A' - 1) : ('a' - 1);
+                alpha2 &= ~COUNTRY;
+                int i = 0;
+                final char[] c = new char[3]; // 2 should be enough, but our impl. actually allows 3-letters codes too.
+                do c[i++] = (char) ((alpha2 & 0x1F) + base);
+                while ((alpha2 >>>= 5) != 0);
+                return String.valueOf(c, 0, i);
+            }
+        }
+        return code;
+    }
+
+    /**
+     * Converts the given 1-, 2- or 3- letters alpha code to a 15 bits numbers. Each letter uses 5 bits.
+     * If an invalid character is found, then this method returns 0.
+     *
+     * <p>This method does not use the sign bit. Callers can use it for differentiating language codes
+     * from country codes, using the {@link #LANGUAGE} or {@link #COUNTRY} bit masks.</p>
+     *
+     * @param  code The 1-, 2- or 3- letters alpha code to convert.
+     * @param  n Initial bit pattern, either {@link #LANGUAGE} or {@link #COUNTRY}.
+     * @return A number for the given code, or 0 if a non alpha characters were found.
      */
-    private static boolean isThreeLetters(final String code) {
-        switch (code.length()) {
-            case 0: // fall through
-            case 2: return false;
-            case 3: return true;
-            default: {
-                throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalLanguageCode_1, code));
+    private static short toNumber(final String code, short n) {
+        final int length = code.length();
+        if (length >= 1 && length <= 3) {
+            int shift = 0;
+            for (int i=0; i<length; i++) {
+                int c = code.charAt(i);
+                if (c < 'A' || (c -= (c >= 'a') ? ('a' - 1) : ('A' - 1)) > 26) {
+                    return 0;
+                }
+                n |= c << shift;
+                shift += 5;
             }
+            return n;
         }
+        return 0;
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -201,7 +201,7 @@ public class TableColumn<V> implements C
         /**
          * The resource key for the column header.
          */
-        private final transient int resourceKey;
+        private final transient short resourceKey;
 
         /**
          * Creates a new instance for a build-in constant.
@@ -210,7 +210,7 @@ public class TableColumn<V> implements C
          * @param type   Base type of all values in the column identified by this instance.
          * @param header The resource key for the column header.
          */
-        Constant(final String field, final Class<V> type, final int header) {
+        Constant(final String field, final Class<V> type, final short header) {
             super(type);
             this.field       = field;
             this.resourceKey = header;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -420,8 +420,7 @@ public class DefaultInternationalString 
             localeMap = Collections.singletonMap(Locales.unique(entry.getKey()), entry.getValue());
         } else {
             localeMap.clear();
-            for (int i=0; i<entries.length; i++) {
-                final Map.Entry<Locale,String> entry = entries[i];
+            for (final Map.Entry<Locale,String> entry : entries) {
                 localeMap.put(Locales.unique(entry.getKey()), entry.getValue());
             }
         }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -571,21 +571,23 @@ public final class Types extends Static 
     }
 
     /**
-     * Returns an international strings for the values in the given properties map, or {@code null} if none.
-     * If the given map is {@code null}, then this method returns {@code null}.
-     * Otherwise this method iterates over the entries having a key that starts with the specified prefix.
-     * For each such key:
+     * Returns an international string for the values in the given properties map, or {@code null} if none.
+     * This method is used when a property in a {@link java.util.Map} may have many localized variants.
+     * For example the given map may contains a {@code "remarks"} property defined by values associated to
+     * the {@code "remarks_en"} and {@code "remarks_fr"} keys, for English and French locales respectively.
+     *
+     * <p>If the given map is {@code null}, then this method returns {@code null}.
+     * Otherwise this method iterates over the entries having a key that starts with the specified prefix,
+     * followed by the {@code '_'} character. For each such key:</p>
      *
      * <ul>
-     *   <li>The part after the prefix is parsed as specified by the {@link Locales#parseSuffix(String, String)}
-     *       method.</li>
-     *   <li>If {@code parseSuffix(…)} returned a non-null locale, then the value for that locale is added in the
-     *       international string to be returned.</li>
+     *   <li>If the key is exactly equals to {@code prefix}, selects {@link Locale#ROOT}.</li>
+     *   <li>Otherwise the characters after {@code '_'} are parsed as an ISO language and country code
+     *       by the {@link Locales#parse(String, int)} method. Note that 3-letters codes are replaced
+     *       by their 2-letters counterparts on a <cite>best effort</cite> basis.</li>
+     *   <li>The value for the decoded locale is added in the international string to be returned.</li>
      * </ul>
      *
-     * For example the given map may contains a {@code "remarks"} property defined by values associated to the
-     * {@code "remarks_en"} and {@code "remarks_fr"} keys, for English and French locales respectively.
-     *
      * @param  properties The map from which to get the string values for an international string, or {@code null}.
      * @param  prefix     The prefix of keys to use for creating the international string.
      * @return The international string, or {@code null} if the given map is null or does not contain values
@@ -596,7 +598,7 @@ public final class Types extends Static 
      *           <li>or the value associated to that key is a not a {@link CharSequence}.</li>
      *         </ul>
      *
-     * @see Locales#parseSuffix(String, String)
+     * @see Locales#parse(String, int)
      * @see DefaultInternationalString#DefaultInternationalString(Map)
      *
      * @since 0.4
@@ -627,39 +629,43 @@ public final class Types extends Static 
         CharSequence i18n = null;
         Locale firstLocale = null;
         DefaultInternationalString dis = null;
-        final int length = prefix.length();
+        final int offset = prefix.length();
         for (final Map.Entry<String,?> entry : properties.entrySet()) {
             final String key = entry.getKey();
-            final Locale locale = Locales.parseSuffix(prefix, key);
-            if (locale == null) {
-                if (isSorted) {
-                    /*
-                     * If the map is sorted using natural ordering, we can stop as soon as we find a key which
-                     * is lexicographically greater than prefix + '_'. We check 'startsWith' last since the other
-                     * tests are cheaper and usually sufficient.
-                     */
-                    if (key.length() <= length || key.charAt(length) > '_' || !key.startsWith(prefix)) {
-                        break;
-                    }
-                }
+            if (key == null) {
+                continue; // Tolerance for Map that accept null keys.
+            }
+            if (!key.startsWith(prefix)) {
+                if (isSorted) break; // If the map is sorted, there is no need to check next entries.
+                continue;
+            }
+            final Locale locale;
+            if (key.length() == offset) {
+                locale = Locale.ROOT;
             } else {
-                final Object value = entry.getValue();
-                if (value != null) {
-                    if (!(value instanceof CharSequence)) {
-                        throw new IllegalArgumentException(Errors.format(
-                                Errors.Keys.IllegalPropertyClass_2, key, value.getClass()));
-                    }
-                    if (i18n == null) {
-                        i18n = (CharSequence) value;
-                        firstLocale = locale;
-                    } else {
-                        if (dis == null) {
-                            dis = new DefaultInternationalString();
-                            dis.add(firstLocale, i18n);
-                            i18n = dis;
-                        }
-                        dis.add(locale, (CharSequence) value);
+                final char c = key.charAt(offset);
+                if (c != '_') {
+                    if (isSorted && c > '_') break;
+                    continue;
+                }
+                locale = Locales.parse(key, offset + 1);
+            }
+            final Object value = entry.getValue();
+            if (value != null) {
+                if (!(value instanceof CharSequence)) {
+                    throw new IllegalArgumentException(Errors.format(
+                            Errors.Keys.IllegalPropertyClass_2, key, value.getClass()));
+                }
+                if (i18n == null) {
+                    i18n = (CharSequence) value;
+                    firstLocale = locale;
+                } else {
+                    if (dis == null) {
+                        dis = new DefaultInternationalString();
+                        dis.add(firstLocale, i18n);
+                        i18n = dis;
                     }
+                    dis.add(locale, (CharSequence) value);
                 }
             }
         }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListener.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListener.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListener.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListener.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -68,7 +68,7 @@ public interface WarningListener<S> exte
      * Applications do not need to log the warning, since logging will be done automatically if the emitter has
      * no registered warning listeners.</p>
      *
-     * @param source  The object that emitted a warning.
+     * @param source  The object that emitted a warning, or {@code null} if not available.
      * @param warning The warning message together with programmatic information.
      */
     void warningOccured(S source, LogRecord warning);

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -35,7 +35,7 @@ import org.opengis.util.InternationalStr
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.2)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final class Errors extends IndexedResourceBundle {
@@ -66,674 +66,674 @@ public final class Errors extends Indexe
          * No element can be added to this set because properties ‘{0}’ and ‘{1}’ are mutually
          * exclusive.
          */
-        public static final int CanNotAddToExclusiveSet_2 = 87;
+        public static final short CanNotAddToExclusiveSet_2 = 0;
 
         /**
          * Can not compute the derivative.
          */
-        public static final int CanNotComputeDerivative = 44;
+        public static final short CanNotComputeDerivative = 1;
 
         /**
          * Can not connect to “{0}”.
          */
-        public static final int CanNotConnectTo_1 = 114;
+        public static final short CanNotConnectTo_1 = 2;
 
         /**
          * Can not convert from type ‘{0}’ to type ‘{1}’.
          */
-        public static final int CanNotConvertFromType_2 = 72;
+        public static final short CanNotConvertFromType_2 = 3;
 
         /**
          * Can not convert value “{0}” to type ‘{1}’.
          */
-        public static final int CanNotConvertValue_2 = 74;
+        public static final short CanNotConvertValue_2 = 4;
 
         /**
          * Can not instantiate an object of type ‘{0}’.
          */
-        public static final int CanNotInstantiate_1 = 81;
+        public static final short CanNotInstantiate_1 = 5;
 
         /**
          * Can not map an axis from “{0}” to direction “{1}”.
          */
-        public static final int CanNotMapAxisToDirection_2 = 123;
+        public static final short CanNotMapAxisToDirection_2 = 6;
 
         /**
          * Can not open “{0}”.
          */
-        public static final int CanNotOpen_1 = 97;
+        public static final short CanNotOpen_1 = 7;
 
         /**
          * Can not parse “{1}” as a file in the {0} format.
          */
-        public static final int CanNotParseFile_2 = 79;
+        public static final short CanNotParseFile_2 = 8;
 
         /**
          * Can not read “{0}”.
          */
-        public static final int CanNotRead_1 = 108;
+        public static final short CanNotRead_1 = 9;
 
         /**
          * Can not represent “{1}” in the {0} format.
          */
-        public static final int CanNotRepresentInFormat_2 = 110;
+        public static final short CanNotRepresentInFormat_2 = 10;
 
         /**
          * Can not set a value for property “{0}”.
          */
-        public static final int CanNotSetPropertyValue_1 = 75;
+        public static final short CanNotSetPropertyValue_1 = 11;
 
         /**
          * Class ‘{0}’ is not final.
          */
-        public static final int ClassNotFinal_1 = 71;
+        public static final short ClassNotFinal_1 = 12;
 
         /**
          * Can not clone an object of type ‘{0}’.
          */
-        public static final int CloneNotSupported_1 = 42;
+        public static final short CloneNotSupported_1 = 13;
 
         /**
          * Axis directions {0} and {1} are colinear.
          */
-        public static final int ColinearAxisDirections_2 = 122;
+        public static final short ColinearAxisDirections_2 = 14;
 
         /**
          * Thread “{0}” is dead.
          */
-        public static final int DeadThread_1 = 43;
+        public static final short DeadThread_1 = 15;
 
         /**
          * Element “{0}” is duplicated.
          */
-        public static final int DuplicatedElement_1 = 116;
+        public static final short DuplicatedElement_1 = 16;
 
         /**
          * Identifier “{0}” is duplicated.
          */
-        public static final int DuplicatedIdentifier_1 = 38;
+        public static final short DuplicatedIdentifier_1 = 17;
 
         /**
          * Option “{0}” is duplicated.
          */
-        public static final int DuplicatedOption_1 = 100;
+        public static final short DuplicatedOption_1 = 18;
 
         /**
          * Element “{0}” is already present.
          */
-        public static final int ElementAlreadyPresent_1 = 36;
+        public static final short ElementAlreadyPresent_1 = 19;
 
         /**
          * Argument ‘{0}’ shall not be empty.
          */
-        public static final int EmptyArgument_1 = 1;
+        public static final short EmptyArgument_1 = 20;
 
         /**
          * The dictionary shall contain at least one entry.
          */
-        public static final int EmptyDictionary = 54;
+        public static final short EmptyDictionary = 21;
 
         /**
          * Envelope must be at least two-dimensional and non-empty.
          */
-        public static final int EmptyEnvelope2D = 88;
+        public static final short EmptyEnvelope2D = 22;
 
         /**
          * Property named “{0}” shall not be empty.
          */
-        public static final int EmptyProperty_1 = 55;
+        public static final short EmptyProperty_1 = 23;
 
         /**
          * Argument ‘{0}’ shall not contain more than {1} elements. A number of {2} is excessive.
          */
-        public static final int ExcessiveArgumentSize_3 = 52;
+        public static final short ExcessiveArgumentSize_3 = 24;
 
         /**
          * A size of {1} elements is excessive for the “{0}” list.
          */
-        public static final int ExcessiveListSize_2 = 94;
+        public static final short ExcessiveListSize_2 = 25;
 
         /**
          * Attribute “{0}” is not allowed for an object of type ‘{1}’.
          */
-        public static final int ForbiddenAttribute_2 = 21;
+        public static final short ForbiddenAttribute_2 = 26;
 
         /**
          * Identifier “{0}” is already associated to another object.
          */
-        public static final int IdentifierAlreadyBound_1 = 50;
+        public static final short IdentifierAlreadyBound_1 = 27;
 
         /**
          * Argument ‘{0}’ can not be an instance of ‘{1}’.
          */
-        public static final int IllegalArgumentClass_2 = 17;
+        public static final short IllegalArgumentClass_2 = 28;
 
         /**
          * Argument ‘{0}’ can not be an instance of ‘{2}’. Expected an instance of ‘{1}’ or derived
          * type.
          */
-        public static final int IllegalArgumentClass_3 = 2;
+        public static final short IllegalArgumentClass_3 = 29;
 
         /**
          * Argument ‘{0}’ can not take the “{1}” value, because the ‘{2}’ field can not take the “{3}”
          * value.
          */
-        public static final int IllegalArgumentField_4 = 15;
+        public static final short IllegalArgumentField_4 = 30;
 
         /**
          * Argument ‘{0}’ can not take the “{1}” value.
          */
-        public static final int IllegalArgumentValue_2 = 14;
+        public static final short IllegalArgumentValue_2 = 31;
 
         /**
          * Coordinate system of class ‘{0}’ can not have axis in the {1} direction.
          */
-        public static final int IllegalAxisDirection_2 = 128;
+        public static final short IllegalAxisDirection_2 = 32;
 
         /**
          * Illegal bits pattern: {0}.
          */
-        public static final int IllegalBitsPattern_1 = 16;
+        public static final short IllegalBitsPattern_1 = 33;
 
         /**
          * Class ‘{1}’ is illegal. It must be ‘{0}’ or a derived class.
          */
-        public static final int IllegalClass_2 = 3;
+        public static final short IllegalClass_2 = 34;
 
         /**
          * The “{1}” pattern can not be applied to formating of objects of type ‘{0}’.
          */
-        public static final int IllegalFormatPatternForClass_2 = 29;
+        public static final short IllegalFormatPatternForClass_2 = 35;
 
         /**
          * The “{0}” language is not recognized.
          */
-        public static final int IllegalLanguageCode_1 = 12;
+        public static final short IllegalLanguageCode_1 = 36;
 
         /**
          * Member “{0}” can not be associated to type “{1}”.
          */
-        public static final int IllegalMemberType_2 = 106;
+        public static final short IllegalMemberType_2 = 37;
 
         /**
          * Option ‘{0}’ can not take the “{1}” value.
          */
-        public static final int IllegalOptionValue_2 = 101;
+        public static final short IllegalOptionValue_2 = 38;
 
         /**
          * The [{0} … {1}] range of ordinate values is not valid for the “{2}” axis.
          */
-        public static final int IllegalOrdinateRange_3 = 5;
+        public static final short IllegalOrdinateRange_3 = 39;
 
         /**
          * Property ‘{0}’ does not accept instances of ‘{1}’.
          */
-        public static final int IllegalPropertyClass_2 = 62;
+        public static final short IllegalPropertyClass_2 = 40;
 
         /**
          * Range [{0} … {1}] is not valid.
          */
-        public static final int IllegalRange_2 = 11;
+        public static final short IllegalRange_2 = 41;
 
         /**
          * Value {1} for “{0}” is not a valid Unicode code point.
          */
-        public static final int IllegalUnicodeCodePoint_2 = 112;
+        public static final short IllegalUnicodeCodePoint_2 = 42;
 
         /**
          * Unit of measurement “{1}” is not valid for “{0}” values.
          */
-        public static final int IllegalUnitFor_2 = 129;
+        public static final short IllegalUnitFor_2 = 43;
 
         /**
          * Incompatible coordinate system types.
          */
-        public static final int IncompatibleCoordinateSystemTypes = 130;
+        public static final short IncompatibleCoordinateSystemTypes = 44;
 
         /**
          * Property “{0}” has an incompatible value.
          */
-        public static final int IncompatiblePropertyValue_1 = 86;
+        public static final short IncompatiblePropertyValue_1 = 45;
 
         /**
          * Units “{0}” and “{1}” are incompatible.
          */
-        public static final int IncompatibleUnits_2 = 67;
+        public static final short IncompatibleUnits_2 = 46;
 
         /**
          * Value “{1}” of attribute ‘{0}’ is inconsistent with other attributes.
          */
-        public static final int InconsistentAttribute_2 = 27;
+        public static final short InconsistentAttribute_2 = 47;
 
         /**
          * Inconsistent table columns.
          */
-        public static final int InconsistentTableColumns = 40;
+        public static final short InconsistentTableColumns = 48;
 
         /**
          * Index {0} is out of bounds.
          */
-        public static final int IndexOutOfBounds_1 = 4;
+        public static final short IndexOutOfBounds_1 = 49;
 
         /**
          * Indices ({0}, {1}) are out of bounds.
          */
-        public static final int IndicesOutOfBounds_2 = 120;
+        public static final short IndicesOutOfBounds_2 = 50;
 
         /**
          * Argument ‘{0}’ can not take an infinite value.
          */
-        public static final int InfiniteArgumentValue_1 = 45;
+        public static final short InfiniteArgumentValue_1 = 51;
 
         /**
          * Infinite recursivity.
          */
-        public static final int InfiniteRecursivity = 51;
+        public static final short InfiniteRecursivity = 52;
 
         /**
          * Argument ‘{0}’ shall contain at least {1} elements. A number of {2} is insufficient.
          */
-        public static final int InsufficientArgumentSize_3 = 53;
+        public static final short InsufficientArgumentSize_3 = 53;
 
         /**
          * A different value is already associated to the “{0}” key.
          */
-        public static final int KeyCollision_1 = 19;
+        public static final short KeyCollision_1 = 54;
 
         /**
          * Attribute “{0}” is mandatory for an object of type ‘{1}’.
          */
-        public static final int MandatoryAttribute_2 = 22;
+        public static final short MandatoryAttribute_2 = 55;
 
         /**
          * Mismatched array lengths.
          */
-        public static final int MismatchedArrayLengths = 111;
+        public static final short MismatchedArrayLengths = 56;
 
         /**
          * The coordinate reference system must be the same for all objects.
          */
-        public static final int MismatchedCRS = 57;
+        public static final short MismatchedCRS = 57;
 
         /**
          * Mismatched object dimensions: {0}D and {1}D.
          */
-        public static final int MismatchedDimension_2 = 60;
+        public static final short MismatchedDimension_2 = 58;
 
         /**
          * Argument ‘{0}’ has {2} dimension{2,choice,1#|2#s}, while {1} was expected.
          */
-        public static final int MismatchedDimension_3 = 58;
+        public static final short MismatchedDimension_3 = 59;
 
         /**
          * Mismatched matrix sizes: expected {0}×{1} but got {2}×{3}.
          */
-        public static final int MismatchedMatrixSize_4 = 118;
+        public static final short MismatchedMatrixSize_4 = 60;
 
         /**
          * This operation requires the “{0}” module.
          */
-        public static final int MissingRequiredModule_1 = 84;
+        public static final short MissingRequiredModule_1 = 61;
 
         /**
          * Missing scheme in URI.
          */
-        public static final int MissingSchemeInURI = 109;
+        public static final short MissingSchemeInURI = 62;
 
         /**
          * Missing value for option “{0}”.
          */
-        public static final int MissingValueForOption_1 = 99;
+        public static final short MissingValueForOption_1 = 63;
 
         /**
          * Missing value for property “{0}”.
          */
-        public static final int MissingValueForProperty_1 = 85;
+        public static final short MissingValueForProperty_1 = 64;
 
         /**
          * Missing value in the “{0}” column.
          */
-        public static final int MissingValueInColumn_1 = 77;
+        public static final short MissingValueInColumn_1 = 65;
 
         /**
          * Options “{0}” and “{1}” are mutually exclusive.
          */
-        public static final int MutuallyExclusiveOptions_2 = 103;
+        public static final short MutuallyExclusiveOptions_2 = 66;
 
         /**
          * Argument ‘{0}’ shall not be negative. The given value was {1}.
          */
-        public static final int NegativeArgument_2 = 8;
+        public static final short NegativeArgument_2 = 67;
 
         /**
          * Can not create a “{0}” array of negative length.
          */
-        public static final int NegativeArrayLength_1 = 78;
+        public static final short NegativeArrayLength_1 = 68;
 
         /**
          * No convergence for points {0} and {1}.
          */
-        public static final int NoConvergenceForPoints_2 = 117;
+        public static final short NoConvergenceForPoints_2 = 69;
 
         /**
          * Element “{0}” has not been found.
          */
-        public static final int NoSuchElement_1 = 96;
+        public static final short NoSuchElement_1 = 70;
 
         /**
          * No property named “{0}” has been found in “{1}”.
          */
-        public static final int NoSuchProperty_2 = 73;
+        public static final short NoSuchProperty_2 = 71;
 
         /**
          * No unit of measurement has been specified.
          */
-        public static final int NoUnit = 68;
+        public static final short NoUnit = 72;
 
         /**
          * Node “{0}” can not be a child of itself.
          */
-        public static final int NodeChildOfItself_1 = 37;
+        public static final short NodeChildOfItself_1 = 73;
 
         /**
          * Node “{0}” already has another parent.
          */
-        public static final int NodeHasAnotherParent_1 = 35;
+        public static final short NodeHasAnotherParent_1 = 74;
 
         /**
          * Node “{0}” has no parent.
          */
-        public static final int NodeHasNoParent_1 = 34;
+        public static final short NodeHasNoParent_1 = 75;
 
         /**
          * Node “{0}” is a leaf.
          */
-        public static final int NodeIsLeaf_1 = 90;
+        public static final short NodeIsLeaf_1 = 76;
 
         /**
          * No “{0}” node found.
          */
-        public static final int NodeNotFound_1 = 39;
+        public static final short NodeNotFound_1 = 77;
 
         /**
          * “{0}” is not an angular unit.
          */
-        public static final int NonAngularUnit_1 = 46;
+        public static final short NonAngularUnit_1 = 78;
 
         /**
          * Missing a ‘{1}’ parenthesis in “{0}”.
          */
-        public static final int NonEquilibratedParenthesis_2 = 59;
+        public static final short NonEquilibratedParenthesis_2 = 79;
 
         /**
          * Conversion is not invertible.
          */
-        public static final int NonInvertibleConversion = 82;
+        public static final short NonInvertibleConversion = 80;
 
         /**
          * Non invertible {0}×{1} matrix.
          */
-        public static final int NonInvertibleMatrix_2 = 124;
+        public static final short NonInvertibleMatrix_2 = 81;
 
         /**
          * Transform is not invertible.
          */
-        public static final int NonInvertibleTransform = 83;
+        public static final short NonInvertibleTransform = 82;
 
         /**
          * Unit conversion from “{0}” to “{1}” is non-linear.
          */
-        public static final int NonLinearUnitConversion_2 = 131;
+        public static final short NonLinearUnitConversion_2 = 83;
 
         /**
          * “{0}” is not a linear unit.
          */
-        public static final int NonLinearUnit_1 = 47;
+        public static final short NonLinearUnit_1 = 84;
 
         /**
          * Axis directions {0} and {1} are not perpendicular.
          */
-        public static final int NonPerpendicularDirections_2 = 132;
+        public static final short NonPerpendicularDirections_2 = 85;
 
         /**
          * “{0}” is not a scale unit.
          */
-        public static final int NonScaleUnit_1 = 48;
+        public static final short NonScaleUnit_1 = 86;
 
         /**
          * “{0}” is not a time unit.
          */
-        public static final int NonTemporalUnit_1 = 49;
+        public static final short NonTemporalUnit_1 = 87;
 
         /**
          * Scale is not uniform.
          */
-        public static final int NonUniformScale = 126;
+        public static final short NonUniformScale = 88;
 
         /**
          * Argument ‘{0}’ shall not be NaN (Not-a-Number).
          */
-        public static final int NotANumber_1 = 9;
+        public static final short NotANumber_1 = 89;
 
         /**
          * Class ‘{0}’ is not a primitive type wrapper.
          */
-        public static final int NotAPrimitiveWrapper_1 = 10;
+        public static final short NotAPrimitiveWrapper_1 = 90;
 
         /**
          * Matrix is not skew-symmetric.
          */
-        public static final int NotASkewSymmetricMatrix = 127;
+        public static final short NotASkewSymmetricMatrix = 91;
 
         /**
          * Text “{0}” is not a Unicode identifier.
          */
-        public static final int NotAUnicodeIdentifier_1 = 113;
+        public static final short NotAUnicodeIdentifier_1 = 92;
 
         /**
          * Transform is not affine.
          */
-        public static final int NotAnAffineTransform = 121;
+        public static final short NotAnAffineTransform = 93;
 
         /**
          * Class ‘{0}’ is not a comparable.
          */
-        public static final int NotComparableClass_1 = 66;
+        public static final short NotComparableClass_1 = 94;
 
         /**
          * Argument ‘{0}’ shall not be null.
          */
-        public static final int NullArgument_1 = 0;
+        public static final short NullArgument_1 = 95;
 
         /**
          * Null key is not allowed in this dictionary.
          */
-        public static final int NullMapKey = 64;
+        public static final short NullMapKey = 96;
 
         /**
          * Null values are not allowed in this dictionary.
          */
-        public static final int NullMapValue = 65;
+        public static final short NullMapValue = 97;
 
         /**
          * Array length is {0}, while we expected an even length.
          */
-        public static final int OddArrayLength_1 = 61;
+        public static final short OddArrayLength_1 = 98;
 
         /**
          * Recursive call while creating an object for the “{0}” key.
          */
-        public static final int RecursiveCreateCallForKey_1 = 18;
+        public static final short RecursiveCreateCallForKey_1 = 99;
 
         /**
          * A decimal separator is required.
          */
-        public static final int RequireDecimalSeparator = 33;
+        public static final short RequireDecimalSeparator = 100;
 
         /**
          * Matrix is singular.
          */
-        public static final int SingularMatrix = 125;
+        public static final short SingularMatrix = 101;
 
         /**
          * Thread “{0}” seems stalled.
          */
-        public static final int StalledThread_1 = 63;
+        public static final short StalledThread_1 = 102;
 
         /**
          * Can not move backward in the “{0}” stream.
          */
-        public static final int StreamIsForwardOnly_1 = 95;
+        public static final short StreamIsForwardOnly_1 = 103;
 
         /**
          * Expected at least {0} argument{0,choice,1#|2#s}, but got {1}.
          */
-        public static final int TooFewArguments_2 = 104;
+        public static final short TooFewArguments_2 = 104;
 
         /**
          * Expected at most {0} argument{0,choice,1#|2#s}, but got {1}.
          */
-        public static final int TooManyArguments_2 = 105;
+        public static final short TooManyArguments_2 = 105;
 
         /**
          * Ordering between “{0}” and “{1}” elements is undefined.
          */
-        public static final int UndefinedOrderingForElements_2 = 70;
+        public static final short UndefinedOrderingForElements_2 = 106;
 
         /**
          * Expected an array of length {0}, but got {1}.
          */
-        public static final int UnexpectedArrayLength_2 = 119;
+        public static final short UnexpectedArrayLength_2 = 107;
 
         /**
          * Unexpected change in ‘{0}’.
          */
-        public static final int UnexpectedChange_1 = 56;
+        public static final short UnexpectedChange_1 = 108;
 
         /**
          * Unexpected end of file while reading “{0}”.
          */
-        public static final int UnexpectedEndOfFile_1 = 91;
+        public static final short UnexpectedEndOfFile_1 = 109;
 
         /**
          * More characters were expected at the end of “{0}”.
          */
-        public static final int UnexpectedEndOfString_1 = 30;
+        public static final short UnexpectedEndOfString_1 = 110;
 
         /**
          * File “{1}” seems to be encoded in an other format than {0}.
          */
-        public static final int UnexpectedFileFormat_2 = 92;
+        public static final short UnexpectedFileFormat_2 = 111;
 
         /**
          * Axis direction “{0}” is unknown.
          */
-        public static final int UnknownAxisDirection_1 = 133;
+        public static final short UnknownAxisDirection_1 = 112;
 
         /**
          * Command “{0}” is not recognized.
          */
-        public static final int UnknownCommand_1 = 102;
+        public static final short UnknownCommand_1 = 113;
 
         /**
          * Unknown enumeration value: {0}.
          */
-        public static final int UnknownEnumValue_1 = 115;
+        public static final short UnknownEnumValue_1 = 114;
 
         /**
          * Format of “{0}” is not recognized.
          */
-        public static final int UnknownFormatFor_1 = 107;
+        public static final short UnknownFormatFor_1 = 115;
 
         /**
          * Option “{0}” is not recognized.
          */
-        public static final int UnknownOption_1 = 98;
+        public static final short UnknownOption_1 = 116;
 
         /**
          * Type of the “{0}” property is unknown.
          */
-        public static final int UnknownTypeForProperty_1 = 80;
+        public static final short UnknownTypeForProperty_1 = 117;
 
         /**
          * Type ‘{0}’ is unknown in this context.
          */
-        public static final int UnknownType_1 = 76;
+        public static final short UnknownType_1 = 118;
 
         /**
          * This affine transform is unmodifiable.
          */
-        public static final int UnmodifiableAffineTransform = 23;
+        public static final short UnmodifiableAffineTransform = 119;
 
         /**
          * The cell at column “{1}” of row “{0}” is unmodifiable.
          */
-        public static final int UnmodifiableCellValue_2 = 89;
+        public static final short UnmodifiableCellValue_2 = 120;
 
         /**
          * This geometry is unmodifiable.
          */
-        public static final int UnmodifiableGeometry = 24;
+        public static final short UnmodifiableGeometry = 121;
 
         /**
          * This metadata is unmodifiable.
          */
-        public static final int UnmodifiableMetadata = 25;
+        public static final short UnmodifiableMetadata = 122;
 
         /**
          * Object ‘{0}’ is unmodifiable.
          */
-        public static final int UnmodifiableObject_1 = 26;
+        public static final short UnmodifiableObject_1 = 123;
 
         /**
          * Text “{1}” can not be parsed as an object of type ‘{0}’.
          */
-        public static final int UnparsableStringForClass_2 = 31;
+        public static final short UnparsableStringForClass_2 = 124;
 
         /**
          * Text “{1}” can not be parsed as an object of type ‘{0}’, because of the “{2}” characters.
          */
-        public static final int UnparsableStringForClass_3 = 32;
+        public static final short UnparsableStringForClass_3 = 125;
 
         /**
          * No format is specified for objects of class ‘{0}’.
          */
-        public static final int UnspecifiedFormatForClass_1 = 41;
+        public static final short UnspecifiedFormatForClass_1 = 126;
 
         /**
          * Can not handle instances of ‘{0}’ because arbitrary implementations are not yet supported.
          */
-        public static final int UnsupportedImplementation_1 = 28;
+        public static final short UnsupportedImplementation_1 = 127;
 
         /**
          * The ‘{0}’ operation is unsupported.
          */
-        public static final int UnsupportedOperation_1 = 20;
+        public static final short UnsupportedOperation_1 = 128;
 
         /**
          * The ‘{0}’ type is unsupported.
          */
-        public static final int UnsupportedType_1 = 69;
+        public static final short UnsupportedType_1 = 129;
 
         /**
          * Version {0} is not supported.
          */
-        public static final int UnsupportedVersion_1 = 93;
+        public static final short UnsupportedVersion_1 = 130;
 
         /**
          * A value is already defined for “{0}”.
          */
-        public static final int ValueAlreadyDefined_1 = 13;
+        public static final short ValueAlreadyDefined_1 = 131;
 
         /**
          * Value ‘{0}’={1} is invalid. Expected a number greater than 0.
          */
-        public static final int ValueNotGreaterThanZero_2 = 7;
+        public static final short ValueNotGreaterThanZero_2 = 132;
 
         /**
          * Value ‘{0}’={3} is invalid. Expected a value in the [{1} … {2}] range.
          */
-        public static final int ValueOutOfRange_4 = 6;
+        public static final short ValueOutOfRange_4 = 133;
     }
 
     /**
@@ -772,7 +772,7 @@ public final class Errors extends Indexe
      * @return The string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public static String format(final int key) throws MissingResourceException {
+    public static String format(final short key) throws MissingResourceException {
         return getResources(null).getString(key);
     }
 
@@ -785,7 +785,7 @@ public final class Errors extends Indexe
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public static String format(final int    key,
+    public static String format(final short  key,
                                 final Object arg0) throws MissingResourceException
     {
         return getResources(null).getString(key, arg0);
@@ -801,7 +801,7 @@ public final class Errors extends Indexe
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public static String format(final int    key,
+    public static String format(final short  key,
                                 final Object arg0,
                                 final Object arg1) throws MissingResourceException
     {
@@ -819,7 +819,7 @@ public final class Errors extends Indexe
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public static String format(final int    key,
+    public static String format(final short  key,
                                 final Object arg0,
                                 final Object arg1,
                                 final Object arg2) throws MissingResourceException
@@ -839,7 +839,7 @@ public final class Errors extends Indexe
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public static String format(final int    key,
+    public static String format(final short  key,
                                 final Object arg0,
                                 final Object arg1,
                                 final Object arg2,
@@ -854,8 +854,8 @@ public final class Errors extends Indexe
     private static final class International extends ResourceInternationalString {
         private static final long serialVersionUID = -5355796215044405012L;
 
-        International(int key)                   {super(key);}
-        International(int key, Object args)      {super(key, args);}
+        International(short key)                 {super(key);}
+        International(short key, Object args)    {super(key, args);}
         @Override KeyConstants getKeyConstants() {return Keys.INSTANCE;}
         @Override IndexedResourceBundle getBundle(final Locale locale) {
             return getResources(locale);
@@ -870,7 +870,7 @@ public final class Errors extends Indexe
      * @param  key The key for the desired string.
      * @return An international string for the given key.
      */
-    public static InternationalString formatInternational(final int key) {
+    public static InternationalString formatInternational(final short key) {
         return new International(key);
     }
 
@@ -887,7 +887,7 @@ public final class Errors extends Indexe
      * @param  arg Values to substitute to "{0}".
      * @return An international string for the given key.
      */
-    public static InternationalString formatInternational(final int key, final Object arg) {
+    public static InternationalString formatInternational(final short key, final Object arg) {
         return new International(key, arg);
     }
 
@@ -900,7 +900,7 @@ public final class Errors extends Indexe
      * @param  args Values to substitute to "{0}", "{1}", <i>etc</i>.
      * @return An international string for the given key.
      */
-    public static InternationalString formatInternational(final int key, final Object... args) {
+    public static InternationalString formatInternational(final short key, final Object... args) {
         return new International(key, args);
     }
 }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -51,8 +51,8 @@ import org.apache.sis.internal.jdk7.JDK7
  * inner classes, with the side-effect of compile-time safety. Because integer constants are
  * inlined right into class files at compile time, the declarative classes is not loaded at run time.
  *
- * <p>Localized resources are fetched by calls to {@link #getString(int)}.
- * Arguments can optionally be provided by calls to {@link #getString(int, Object) getString(int, Object, ...)}.
+ * <p>Localized resources are fetched by calls to {@link #getString(short)}.
+ * Arguments can optionally be provided by calls to {@link #getString(short, Object) getString(short, Object, ...)}.
  * If arguments are present, then the string will be formatted using {@link MessageFormat},
  * completed by some special cases handled by this class. Roughly speaking:</p>
  *
@@ -107,7 +107,7 @@ public class IndexedResourceBundle exten
      * knowing its key allows us to avoid invoking the costly {@link MessageFormat#applyPattern}
      * method.
      */
-    private transient int lastKey;
+    private transient short lastKey;
 
     /**
      * Constructs a new resource bundle loading data from the given UTF file.
@@ -336,9 +336,9 @@ public class IndexedResourceBundle exten
     protected final Object handleGetObject(final String key) {
         // Synchronization performed by 'ensureLoaded'
         final String[] values = ensureLoaded(key);
-        int keyID;
+        short keyID;
         try {
-            keyID = Integer.parseInt(key);
+            keyID = Short.parseShort(key);
         } catch (NumberFormatException exception) {
             /*
              * Maybe the full key name has been specified instead. We do that for localized
@@ -418,7 +418,7 @@ public class IndexedResourceBundle exten
      * @return The string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public final String getMenuLabel(final int key) throws MissingResourceException {
+    public final String getMenuLabel(final short key) throws MissingResourceException {
         return getString(key) + '…';
     }
 
@@ -430,7 +430,7 @@ public class IndexedResourceBundle exten
      * @return The string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public final String getLabel(final int key) throws MissingResourceException {
+    public final String getLabel(final short key) throws MissingResourceException {
         return getString(key) + ": ";
     }
 
@@ -441,7 +441,7 @@ public class IndexedResourceBundle exten
      * @return The string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public final String getString(final int key) throws MissingResourceException {
+    public final String getString(final short key) throws MissingResourceException {
         return getString(String.valueOf(key));
     }
 
@@ -466,11 +466,11 @@ public class IndexedResourceBundle exten
      * @throws MissingResourceException If no object for the given key can be found.
      *
      * @see #getString(String)
-     * @see #getString(int,Object,Object)
-     * @see #getString(int,Object,Object,Object)
+     * @see #getString(short,Object,Object)
+     * @see #getString(short,Object,Object,Object)
      * @see MessageFormat
      */
-    public final String getString(final int key, final Object arg0) throws MissingResourceException {
+    public final String getString(final short key, final Object arg0) throws MissingResourceException {
         final String pattern = getString(key);
         final Object[] arguments = toArray(arg0);
         synchronized (this) {
@@ -510,7 +510,7 @@ public class IndexedResourceBundle exten
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public final String getString(final int    key,
+    public final String getString(final short  key,
                                   final Object arg0,
                                   final Object arg1) throws MissingResourceException
     {
@@ -528,7 +528,7 @@ public class IndexedResourceBundle exten
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public final String getString(final int    key,
+    public final String getString(final short  key,
                                   final Object arg0,
                                   final Object arg1,
                                   final Object arg2) throws MissingResourceException
@@ -548,7 +548,7 @@ public class IndexedResourceBundle exten
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public final String getString(final int    key,
+    public final String getString(final short  key,
                                   final Object arg0,
                                   final Object arg1,
                                   final Object arg2,
@@ -570,7 +570,7 @@ public class IndexedResourceBundle exten
      * @return The formatted string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
-    public final String getString(final int    key,
+    public final String getString(final short  key,
                                   final Object arg0,
                                   final Object arg1,
                                   final Object arg2,
@@ -587,7 +587,7 @@ public class IndexedResourceBundle exten
      * @param  key   The resource key.
      * @return The log record.
      */
-    public final LogRecord getLogRecord(final Level level, final int key) {
+    public final LogRecord getLogRecord(final Level level, final short key) {
         final LogRecord record = new LogRecord(level, getKeyConstants().getKeyName(key));
         record.setResourceBundleName(getClass().getName());
         record.setResourceBundle(this);
@@ -602,7 +602,7 @@ public class IndexedResourceBundle exten
      * @param  arg0  The parameter for the log message, which may be an array.
      * @return The log record.
      */
-    public final LogRecord getLogRecord(final Level level, final int key,
+    public final LogRecord getLogRecord(final Level level, final short key,
                                         final Object arg0)
     {
         final LogRecord record = getLogRecord(level, key);
@@ -619,7 +619,7 @@ public class IndexedResourceBundle exten
      * @param  arg1  The second parameter.
      * @return The log record.
      */
-    public final LogRecord getLogRecord(final Level level, final int key,
+    public final LogRecord getLogRecord(final Level level, final short key,
                                         final Object arg0,
                                         final Object arg1)
     {
@@ -636,7 +636,7 @@ public class IndexedResourceBundle exten
      * @param  arg2  The third parameter.
      * @return The log record.
      */
-    public final LogRecord getLogRecord(final Level level, final int key,
+    public final LogRecord getLogRecord(final Level level, final short key,
                                         final Object arg0,
                                         final Object arg1,
                                         final Object arg2)
@@ -655,7 +655,7 @@ public class IndexedResourceBundle exten
      * @param  arg3  The fourth parameter.
      * @return The log record.
      */
-    public final LogRecord getLogRecord(final Level level, final int key,
+    public final LogRecord getLogRecord(final Level level, final short key,
                                         final Object arg0,
                                         final Object arg1,
                                         final Object arg2,

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java?rev=1551742&r1=1551741&r2=1551742&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java [UTF-8] Tue Dec 17 22:36:49 2013
@@ -30,7 +30,7 @@ import org.apache.sis.util.CharSequences
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.4
  * @module
  */
 class KeyConstants {
@@ -44,7 +44,7 @@ class KeyConstants {
      * inner class in some occasions.
      *
      * @see #getKeyNames()
-     * @see #getKeyName(int)
+     * @see #getKeyName(short)
      */
     private transient String[] keys;
 
@@ -76,8 +76,8 @@ class KeyConstants {
                 final Field[] fields = keysClass.getFields();
                 names = new String[fields.length];
                 for (final Field field : fields) {
-                    if (Modifier.isStatic(field.getModifiers()) && field.getType() == Integer.TYPE) {
-                        final int index = (Integer) field.get(null);
+                    if (Modifier.isStatic(field.getModifiers()) && field.getType() == Short.TYPE) {
+                        final int index = ((Short) field.get(null)) & 0xFFFF;
                         if (index >= length) {
                             length = index + 1;
                             if (length > names.length) {
@@ -88,7 +88,7 @@ class KeyConstants {
                         names[index] = field.getName();
                     }
                 }
-            } catch (Exception e) { // (ReflectiveOperationException) on JDK7
+            } catch (IllegalAccessException e) {
                 names = CharSequences.EMPTY_ARRAY;
             }
             keys = ArraysExt.resize(names, length);
@@ -101,10 +101,11 @@ class KeyConstants {
      * index, format the index as a decimal number. Those decimal numbers are parsed by
      * our {@link IndexedResourceBundle#handleGetObject(String)} implementation.
      */
-    final String getKeyName(final int index) {
+    final String getKeyName(final short index) {
+        final int i = index & 0xFFFF;
         final String[] keys = getKeyNames();
-        if (index < keys.length) {
-            final String key = keys[index];
+        if (i < keys.length) {
+            final String key = keys[i];
             if (key != null) {
                 return key;
             }
@@ -115,7 +116,7 @@ class KeyConstants {
     /**
      * Returns the numerical value for the key of the given name.
      */
-    final int getKeyValue(final String name) throws NoSuchFieldException, IllegalAccessException {
-        return (Integer) keysClass.getField(name).get(null);
+    final short getKeyValue(final String name) throws NoSuchFieldException, IllegalAccessException {
+        return (Short) keysClass.getField(name).get(null);
     }
 }



Mime
View raw message