Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java Tue Feb 12 16:36:05 2013 @@ -16,11 +16,10 @@ */ package org.apache.sis.util.resources; +import java.net.URL; import java.io.BufferedInputStream; import java.io.DataInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; import java.text.MessageFormat; import java.util.Enumeration; import java.util.Locale; @@ -35,6 +34,7 @@ import org.opengis.util.InternationalStr import org.apache.sis.util.Debug; import org.apache.sis.util.Classes; +import org.apache.sis.util.Localized; import org.apache.sis.util.Exceptions; import org.apache.sis.util.CharSequences; import org.apache.sis.util.logging.Logging; @@ -60,7 +60,7 @@ import org.apache.sis.internal.util.JDK7 * @module */ @ThreadSafe -public class IndexedResourceBundle extends ResourceBundle { +public class IndexedResourceBundle extends ResourceBundle implements Localized { /** * Maximum string length for text inserted into another text. This parameter is used by * {@link #summarize}. Resource strings are never cut to this length. However, text replacing @@ -69,33 +69,23 @@ public class IndexedResourceBundle exten private static final int MAX_STRING_LENGTH = 200; /** - * The resource name of the binary file containing resources. It may be a file name or an - * entry in a JAR file. The path must be relative to the package containing the subclass - * of {@code IndexedResourceBundle}. + * The path of the binary file containing resources, or {@code null} if there is no resources + * of if the resources have already been loaded. The resources may be a file or an entry in a + * JAR file. */ - private final String filename; + private URL resources; /** * The array of resources. Keys are an array index. For example, the value for key "14" is * {@code values[14]}. This array will be loaded only when first needed. We should not load * it at construction time, because some {@code ResourceBundle} objects will never ask for - * values. This is particularly the case for ancestor classes of {@code Resources_fr_CA}, + * values. This is particularly the case for parent resources of {@code Resources_fr_CA}, * {@code Resources_en}, {@code Resources_de}, etc., which will only be used if a key has - * not been found in the subclass. + * not been found in the child resources. * * @see #ensureLoaded(String) */ - private String[] values; - - /** - * The locale for formatting objects like number, date, etc. There are two possible Locales - * we could use: default locale or resource bundle locale. If the default locale uses the same - * language as this ResourceBundle's locale, then we will use the default locale. This allows - * dates and numbers to be formatted according to user conventions (e.g. French Canada) even - * if the ResourceBundle locale is different (e.g. standard French). However, if languages - * don't match, then we will use ResourceBundle locale for better coherence. - */ - private transient Locale formatLocale; + private volatile String[] values; /** * The object to use for formatting messages. This object @@ -113,11 +103,11 @@ public class IndexedResourceBundle exten /** * Constructs a new resource bundle loading data from the given UTF file. * - * @param filename The file or the JAR entry containing resources. The path must be relative - * to the package of the {@code IndexedResourceBundle} subclass being constructed. + * @param resources The path of the binary file containing resources, or {@code null} if + * there is no resources. The resources may be a file or an entry in a JAR file. */ - protected IndexedResourceBundle(final String filename) { - this.filename = filename; + protected IndexedResourceBundle(final URL resources) { + this.resources = resources; } /** @@ -143,24 +133,6 @@ public class IndexedResourceBundle exten } /** - * Returns the locale to use for formatters. It is often the same than {@link #getLocale()}, - * except if the later has the same language than the default locale, in which case this - * method returns the default locale. For example if this {@code IndexResourceBundle} is - * for the French locale but the user is French Canadian, we will format the dates using - * Canada French conventions rather than France conventions. - */ - private Locale getFormatLocale() { - if (formatLocale == null) { - formatLocale = Locale.getDefault(); - final Locale rl = getLocale(); // Sometime null with IBM's JDK. - if (rl != null && !formatLocale.getLanguage().equalsIgnoreCase(rl.getLanguage())) { - formatLocale = rl; - } - } - return formatLocale; - } - - /** * Returns a handler for the constants declared in the inner {@code Keys} class. * Subclasses defined in the {@code org.apache.sis.util.resources} package * override this method for efficiency. However the default implementation @@ -271,78 +243,75 @@ public class IndexedResourceBundle exten * @throws MissingResourceException if this method failed to load resources. */ private String[] ensureLoaded(final String key) throws MissingResourceException { - final String methodName = (key != null) ? "getObject" : "getKeys"; - LogRecord record = null; - try { - String[] values; - synchronized (this) { - values = this.values; - if (values != null) { - return values; - } + String[] values = this.values; + if (values == null) synchronized (this) { + values = this.values; + if (values == null) { /* - * Prepares a log record. We will wait for successful loading before - * posting this record. If loading fails, the record will be changed - * into an error record. Note that the message must be logged outside - * the synchronized block, otherwise there is dead locks! + * If there is no explicit resources for this instance, inherit the resources + * from the parent. Note that this IndexedResourceBundle instance may still + * differ from its parent in the way date and numbers are formatted. */ - record = new LogRecord(Level.FINER, "Loaded resources for {0} from bundle \"{1}\"."); - /* - * Loads resources from the UTF file. - */ - InputStream in; - String name = filename; - while ((in = getClass().getResourceAsStream(name)) == null) { // NOSONAR - final int ext = name.lastIndexOf('.'); - final int lang = name.lastIndexOf('_', ext-1); - if (lang <= 0) { - throw new FileNotFoundException(filename); - } - final int length = name.length(); - name = new StringBuilder(lang + (length-ext)) - .append(name, 0, lang).append(name, ext, length).toString(); - } - final DataInputStream input = new DataInputStream(new BufferedInputStream(in)); - try { - this.values = values = new String[input.readInt()]; - for (int i=0; i<values.length; i++) { - values[i] = input.readUTF(); - if (values[i].isEmpty()) { - values[i] = null; + if (resources == null) { + // If we get a NullPointerException or ClassCastException here, + // it would be a bug in the way we create the chain of parents. + values = ((IndexedResourceBundle) parent).ensureLoaded(key); + } else { + /* + * Prepares a log record. We will wait for successful loading before + * posting this record. If loading fails, the record will be changed + * into an error record. Note that the message must be logged outside + * the synchronized block, otherwise there is dead locks! + */ + final Locale locale = getLocale(); // Sometime null with IBM's JDK. + final String baseName = getClass().getCanonicalName(); + final String methodName = (key != null) ? "getObject" : "getKeys"; + final LogRecord record = new LogRecord(Level.FINER, "Loaded resources for {0} from bundle \"{1}\"."); + /* + * Loads resources from the UTF file. + */ + try { + DataInputStream input = new DataInputStream(new BufferedInputStream(resources.openStream())); + values = new String[input.readInt()]; + for (int i=0; i<values.length; i++) { + values[i] = input.readUTF(); + if (values[i].isEmpty()) { + values[i] = null; + } } + input.close(); + } catch (IOException exception) { + record.setLevel (Level.WARNING); + record.setMessage(exception.getMessage()); // For administrator, use system locale. + record.setThrown (exception); + Logging.log(IndexedResourceBundle.class, methodName, record); + final MissingResourceException error = new MissingResourceException( + Exceptions.getLocalizedMessage(exception, locale), // For users, use requested locale. + baseName, key); + error.initCause(exception); + throw error; } - } finally { - input.close(); - } - /* - * Now, logs the message. This message is not localized. Note that - * Locale.getDisplayName() may return different string on different - * Java implementation, but it doesn't matter here since we use the - * result only for logging purpose. - */ - String language = null; - final Locale rl = getLocale(); // Sometime null with IBM's JDK. - if (rl != null) { - language = rl.getDisplayName(Locale.US); - } - if (language == null || language.isEmpty()) { - language = "<default>"; + /* + * Now, logs the message. This message is provided only in English. + * Note that Locale.getDisplayName() may return different string on + * different Java implementation, but it doesn't matter here since + * we use the result only for logging purpose. + */ + String language = null; + if (locale != null) { + language = locale.getDisplayName(Locale.US); + } + if (language == null || language.isEmpty()) { + language = "<root>"; + } + record.setParameters(new String[] {language, baseName}); + Logging.log(IndexedResourceBundle.class, methodName, record); + resources = null; // Not needed anymore, let GC do its job. } - record.setParameters(new String[] {language, getClass().getCanonicalName()}); + this.values = values; } - Logging.log(IndexedResourceBundle.class, methodName, record); - return values; - } catch (IOException exception) { - record.setLevel (Level.WARNING); - record.setMessage(exception.getMessage()); // For administrator, use system locale. - record.setThrown (exception); - Logging.log(IndexedResourceBundle.class, methodName, record); - final MissingResourceException error = new MissingResourceException( - Exceptions.getLocalizedMessage(exception, getLocale()), // For users, use requested locale. - getClass().getCanonicalName(), key); - error.initCause(exception); - throw error; } + return values; } /** @@ -404,11 +373,11 @@ public class IndexedResourceBundle exten if (element instanceof CharSequence) { CharSequence text = (CharSequence) element; if (text instanceof InternationalString) { - text = ((InternationalString) element).toString(getFormatLocale()); + text = ((InternationalString) element).toString(getLocale()); } replacement = CharSequences.shortSentence(text, MAX_STRING_LENGTH); } else if (element instanceof Throwable) { - String message = Exceptions.getLocalizedMessage((Throwable) element, getFormatLocale()); + String message = Exceptions.getLocalizedMessage((Throwable) element, getLocale()); if (message == null) { message = Classes.getShortClassName(element); } @@ -496,7 +465,7 @@ public class IndexedResourceBundle exten /* * Constructs a new MessageFormat for formatting the arguments. */ - format = new MessageFormat(pattern, getFormatLocale()); + format = new MessageFormat(pattern, getLocale()); lastKey = key; } else if (key != lastKey) { /*
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java Tue Feb 12 16:36:05 2013 @@ -16,6 +16,7 @@ */ package org.apache.sis.util.resources; +import java.net.URL; import java.util.List; import java.util.Locale; import java.util.Collections; @@ -105,25 +106,16 @@ final class Loader extends ResourceBundl * bundle only if the file is found. */ final String classname = classe.getSimpleName(); - String filename = toResourceName(toBundleName(classname, locale), EXTENSION); - if (classe.getResource(filename) == null) { - if (!Locale.ENGLISH.equals(locale)) { - return null; - } - // We have no explicit resources for English. We use the default one for that. - filename = toResourceName(classname, EXTENSION); - if (classe.getResource(filename) == null) { - return null; - } - } + final URL resources = classe.getResource(toResourceName(toBundleName(classname, locale), EXTENSION)); /* - * If the file exists, instantiate now the resource bundle. Note that the constructor - * will not loads the data immediately, which is why we don't pass it the above URL. + * Instantiate now the resource bundle. The resources URL may be null, in which case the + * bundle will inherit the strings from the parent bundle. In every cases, the strings + * will be loaded only when first needed. * * Note: Do not call Constructor.setAccessible(true) - this is not allowed in Applet. */ try { - return (ResourceBundle) classe.getDeclaredConstructor(String.class).newInstance(filename); + return (ResourceBundle) classe.getDeclaredConstructor(URL.class).newInstance(resources); } catch (Exception e) { // The JDK7 branch uses multi-catches here. InstantiationException exception = new InstantiationException(Exceptions.getLocalizedMessage(e, locale)); exception.initCause(e); Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java Tue Feb 12 16:36:05 2013 @@ -16,6 +16,7 @@ */ package org.apache.sis.util.resources; +import java.net.URL; import java.util.Locale; import java.util.MissingResourceException; import org.opengis.util.InternationalString; @@ -67,10 +68,11 @@ public final class Messages extends Inde /** * Constructs a new resource bundle loading data from the given UTF file. * - * @param filename The file or the JAR entry containing resources. + * @param resources The path of the binary file containing resources, or {@code null} if + * there is no resources. The resources may be a file or an entry in a JAR file. */ - Messages(final String filename) { - super(filename); + Messages(final URL resources) { + super(resources); } /** Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java Tue Feb 12 16:36:05 2013 @@ -106,23 +106,15 @@ abstract class ResourceInternationalStri /** * Returns a string in the specified locale. * - * @param locale The locale to look for, or {@code null} for an unlocalized version. - * @return The string in the specified locale, or in a default locale. + * @param locale The desired locale for the string to be returned. + * @return The string in the specified locale, or in a fallback locale. * @throws MissingResourceException is the key given to the constructor is invalid. */ @Override - public String toString(Locale locale) throws MissingResourceException { - if (locale == null) { - // The English locale (NOT the system default) is often used - // as the real identifier in OGC IdentifiedObject naming. If - // a user wants a string in the system default locale, he - // should invokes the 'toString()' method instead. - locale = Locale.ENGLISH; - } + public String toString(final Locale locale) throws MissingResourceException { final IndexedResourceBundle resources = getBundle(locale); - return (key < 0) - ? resources.getString(~key) - : resources.getString(key, arguments); + return (key < 0) ? resources.getString(~key) + : resources.getString(key, arguments); } /** Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java Tue Feb 12 16:36:05 2013 @@ -16,6 +16,7 @@ */ package org.apache.sis.util.resources; +import java.net.URL; import java.util.Locale; import java.util.MissingResourceException; import org.opengis.util.InternationalString; @@ -247,10 +248,11 @@ public final class Vocabulary extends In /** * Constructs a new resource bundle loading data from the given UTF file. * - * @param filename The file or the JAR entry containing resources. + * @param resources The path of the binary file containing resources, or {@code null} if + * there is no resources. The resources may be a file or an entry in a JAR file. */ - Vocabulary(final String filename) { - super(filename); + Vocabulary(final URL resources) { + super(resources); } /** Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java Tue Feb 12 16:36:05 2013 @@ -60,35 +60,34 @@ public abstract class MarshalContext { * Returns the locale to use for (un)marshalling, or {@code null} if no locale were explicitly * specified. The locale returned by this method can be used for choosing a language in an * {@link org.opengis.util.InternationalString}. - * This locale may vary in different fragments of the same XML document. + * + * <p>This locale may vary in different fragments of the same XML document. * In particular children of {@link org.opengis.metadata.Metadata} inherit the locale - * specified by the {@link org.opengis.metadata.Metadata#getLanguage()} attribute. + * specified by the {@link org.opengis.metadata.Metadata#getLanguage()} attribute.</p> + * + * {@section Handling of <code>Locale.ROOT</code>} + * {@link Locale#ROOT} is interpreted as a request for locale-neutral strings. + * The meaning of "locale-neutral" is implementation specific - this is usually + * very close to the English locale, but not necessarily. For examples dates are + * formatted according ISO standard instead than the rules of the English locale. * - * {@section Null locale} - * Null locales are typically interpreted as a request for locale-independent strings in SIS. - * The meaning of "locale-independent" is implementation specific - - * this is usually very close to the English locale, but not necessarily - * (e.g. dates formatted according ISO standard instead then English locale). - * If the locale is {@code null}, then callers shall select a default locale as documented - * in the {@link org.apache.sis.util.iso.DefaultInternationalString#toString(Locale)} javadoc. - * As a matter of rule: - * - * <ul> - * <li>If the locale is given to an {@code InternationalString.toString(Locale)} method, - * keep the {@code null} value since the international string is already expected to - * returns a "unlocalized" string in such case.</li> - * <li>Otherwise, if a {@code Locale} instance is really needed, use {@link Locale#US} - * as an approximation of "unlocalized" string.</li> - * </ul> + * {@section Handling of <code>null</code> locale} + * A {@code null} value means that the locale is unspecified. Callers are encouraged + * to use the root locale as the default value, but some flexibility is allowed. * * @return The locale for the XML fragment being (un)marshalled, or {@code null} is unspecified. + * + * @see org.apache.sis.util.iso.DefaultInternationalString#toString(Locale) */ public abstract Locale getLocale(); /** * Returns the timezone to use for (un)marshalling, or {@code null} if none were explicitely - * specified. If {@code null}, then an implementation-default (typically UTC) timezone is - * assumed. + * specified. + * + * {@section Handling of <code>null</code> timezone} + * A {@code null} value means that the timezone is unspecified. Callers are encouraged + * to use the UTC timezone as the default value, but some flexibility is allowed. * * @return The timezone for the XML fragment being (un)marshalled, or {@code null} if unspecified. */ Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java Tue Feb 12 16:36:05 2013 @@ -184,7 +184,7 @@ public final class Namespaces extends St if (prefix != null) { return prefix; } - namespace = namespace.toLowerCase(Locale.US); + namespace = namespace.toLowerCase(Locale.ROOT); for (final String baseURL : GENERIC_URLS) { if (namespace.startsWith(baseURL)) { final int startAt = baseURL.length(); Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java Tue Feb 12 16:36:05 2013 @@ -74,7 +74,6 @@ package org.apache.sis.xml; * @module * * @see NilReason#createNilObject(Class) - * @see ReferenceResolver#resolve(MarshalContext, Class, NilReason) * @see org.apache.sis.util.Numbers#valueOfNil(Class) */ public interface NilObject { Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java Tue Feb 12 16:36:05 2013 @@ -97,7 +97,7 @@ public class ValueConverter { * @param value The value that can't be converted. * @param sourceType The base type of the value to convert. This is determined by the argument * type of the method that caught the exception. For example the source type is always - * {@code URI.class} if the exception has been caught by the {@link #toURL(URI)} method. + * {@code URI.class} if the exception has been caught by the {@link #toURL(MarshalContext, URI)} method. * @param targetType The expected type of the converted object. * @param exception The exception that occurred during the conversion attempt. * @return {@code true} if the (un)marshalling process should continue despite this error, Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/xml/XLink.java Tue Feb 12 16:36:05 2013 @@ -301,7 +301,7 @@ public class XLink implements Serializab * Returns the attribute name for this type. */ final String identifier() { - return name().toLowerCase(Locale.US); + return name().toLowerCase(Locale.ROOT); } } Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Tue Feb 12 16:36:05 2013 @@ -39,9 +39,11 @@ import org.junit.runners.Suite; org.apache.sis.util.CharSequencesTest.class, org.apache.sis.util.StringBuildersTest.class, org.apache.sis.util.UtilitiesTest.class, + org.apache.sis.util.NumbersTest.class, org.apache.sis.util.ClassesTest.class, org.apache.sis.util.VersionTest.class, org.apache.sis.util.LocalesTest.class, + org.apache.sis.util.resources.LoaderTest.class, org.apache.sis.util.resources.IndexedResourceBundleTest.class, org.apache.sis.util.logging.PerformanceLevelTest.class, org.apache.sis.math.MathFunctionsTest.class, @@ -69,7 +71,12 @@ import org.junit.runners.Suite; // Measurements and formatting. org.apache.sis.measure.UnitsTest.class, + org.apache.sis.measure.RangeTest.class, + org.apache.sis.measure.DateRangeTest.class, + org.apache.sis.measure.NumberRangeTest.class, + org.apache.sis.measure.MeasurementRangeTest.class, org.apache.sis.measure.FormattedCharacterIteratorTest.class, + org.apache.sis.measure.RangeFormatTest.class, org.apache.sis.measure.AngleFormatTest.class, org.apache.sis.measure.AngleTest.class, org.apache.sis.internal.util.X364Test.class, Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java Tue Feb 12 16:36:05 2013 @@ -76,8 +76,8 @@ public final strictfp class CharSequence } /** - * Tests the {@link CharSequences#indexOf(CharSequence, CharSequence, int)} method. - * We test four time with different kind of character sequences. + * Tests the {@link CharSequences#indexOf(CharSequence, CharSequence, int, int)} method. + * We test four times with different kind of character sequences. */ @Test public void testIndexOf() { @@ -100,9 +100,9 @@ public final strictfp class CharSequence } /** - * Tests the {@link CharSequences#indexOf(CharSequence, int, int)} and - * {@link CharSequences#lastIndexOf(CharSequence, int, int)} methods. - * We test two time with different kind of character sequences, in order + * Tests the {@link CharSequences#indexOf(CharSequence, int, int, int)} and + * {@link CharSequences#lastIndexOf(CharSequence, int, int, int)} methods. + * We test two times with different kind of character sequences, in order * to test the {@link String} optimization case. */ @Test @@ -359,7 +359,7 @@ public final strictfp class CharSequence } /** - * Tests the {@link CharSequences#isUpperCase(CharSequence)} method. + * Tests the {@link CharSequences#isUpperCase(CharSequence, int, int)} method. */ @Test public void testIsUpperCase() { Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java Tue Feb 12 16:36:05 2013 @@ -94,7 +94,7 @@ public final strictfp class CharactersTe } /** - * Tests the pre-defined {@link Characters.Filter} constants. + * Tests the pre-defined {@link org.apache.sis.util.Characters.Filter} constants. */ @Test public void testPredefinedFilters() { @@ -107,7 +107,7 @@ public final strictfp class CharactersTe } /** - * Tests the {@link Characters.Filter#forTypes(byte[])} method. + * Tests the {@link org.apache.sis.util.Characters.Filter#forTypes(byte[])} method. */ @Test public void testFilterForTypes() { @@ -118,7 +118,8 @@ public final strictfp class CharactersTe } /** - * Scans the full {@code char} range in order to check for {@link Character.Filter} consistency. + * Scans the full {@code char} range in order to check for + * {@link org.apache.sis.util.Characters.Filter} consistency. */ @Test public void scanCharacterRange() { Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java Tue Feb 12 16:36:05 2013 @@ -16,6 +16,7 @@ */ package org.apache.sis.util; +import java.lang.reflect.Field; import org.junit.Test; import org.apache.sis.test.TestCase; @@ -184,7 +185,7 @@ public final strictfp class ClassesTest } /** - * Tests the {@link #boundOfParameterizedAttribute} method. + * Tests the {@link Classes#boundOfParameterizedAttribute(Field)} method. * * @throws NoSuchFieldException Should never occur. * @throws NoSuchMethodException Should never occur. Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedMapTest.java Tue Feb 12 16:36:05 2013 @@ -45,7 +45,7 @@ public final strictfp class DerivedMapTe /** * The value to replace by {@code null}. */ - private static final int EXCLUDED = 17; + protected static final int EXCLUDED = 17; // non-private for javadoc purpose. /** * Fills test values in the given maps. @@ -117,7 +117,7 @@ public final strictfp class DerivedMapTe @Override public Class<Integer> getTargetClass() {return Integer.class;} /** - * Multiply the given value by 10, except value {@value #EXCLUDED}. + * Multiplies the given value by 10, except value {@value #EXCLUDED}. * * @param value The value to multiply. * @return The multiplied value, or {@code null}. Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/DerivedSetTest.java Tue Feb 12 16:36:05 2013 @@ -43,7 +43,7 @@ public final strictfp class DerivedSetTe /** * The value to replace by {@code null}. */ - private static final int EXCLUDED = 19; + protected static final int EXCLUDED = 19; // non-private for javadoc purpose. /** * Tests {@link DerivedSet} without excluded value. Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TableColumnTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TableColumnTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TableColumnTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/TableColumnTest.java Tue Feb 12 16:36:05 2013 @@ -41,11 +41,13 @@ public final strictfp class TableColumnT @Test public void testConstantHeader() { InternationalString i18n = NAME.getHeader(); + assertEquals("Name", i18n.toString(Locale.ROOT)); assertEquals("Name", i18n.toString(Locale.ENGLISH)); assertEquals("Nom", i18n.toString(Locale.FRENCH)); assertSame("Test caching", i18n, NAME.getHeader()); i18n = TYPE.getHeader(); + assertEquals("Type", i18n.toString(Locale.ROOT)); assertEquals("Type", i18n.toString(Locale.ENGLISH)); assertEquals("Type", i18n.toString(Locale.FRENCH)); assertSame("Test caching", i18n, TYPE.getHeader()); Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java Tue Feb 12 16:36:05 2013 @@ -29,7 +29,7 @@ import static org.apache.sis.util.iso.De /** * Tests the {@link DefaultLocalName} and {@link DefaultScopedName} implementations. * This test suite instantiate the objects directly, without using {@link DefaultNameFactory}. - * For tests using the name factory, see {@link NameFactoryTest}. + * For tests using the name factory, see {@link DefaultNameFactoryTest}. * * @author Martin Desruisseaux (Geomatys) * @since 0.3 (derived from goetk-3.00) Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultInternationalStringTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultInternationalStringTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultInternationalStringTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/DefaultInternationalStringTest.java Tue Feb 12 16:36:05 2013 @@ -49,6 +49,7 @@ public final strictfp class DefaultInter toTest.add(Locale.ENGLISH, MESSAGE); assertSame(MESSAGE, toTest.toString()); assertSame(MESSAGE, toTest.toString(null)); + assertSame(MESSAGE, toTest.toString(Locale.ROOT)); validate(toTest); } @@ -85,6 +86,7 @@ public final strictfp class DefaultInter */ private static void assertLocalized(final InternationalString toTest, final String quebecker) { assertEquals ("Unlocalized message:", MESSAGE, toTest.toString(null)); + assertEquals ("Unlocalized message:", MESSAGE, toTest.toString(Locale.ROOT)); assertEquals ("English message:", MESSAGE_en, toTest.toString(Locale.ENGLISH)); assertEquals ("French message:", MESSAGE_fr, toTest.toString(Locale.FRENCH)); assertEquals ("Quebecker message:", quebecker, toTest.toString(Locale.CANADA_FRENCH)); @@ -102,12 +104,14 @@ public final strictfp class DefaultInter toTest.add(Locale.FRENCH, MESSAGE_fr); toTest.add(Locale.CANADA_FRENCH, MESSAGE_fr_CA); - assertEquals("Unlocalized message:", MESSAGE, String.format((Locale) null, "%s", toTest)); + assertEquals("Unlocalized message:", MESSAGE, String.format(Locale.ROOT, "%s", toTest)); assertEquals("English message:", MESSAGE_en, String.format(Locale.ENGLISH, "%s", toTest)); assertEquals("French message:", MESSAGE_fr, String.format(Locale.FRENCH, "%s", toTest)); + assertEquals(" This", String.format(Locale.ROOT, "%6.4s", toTest)); assertEquals(" This", String.format(Locale.ENGLISH, "%6.4s", toTest)); assertEquals(" Voici", String.format(Locale.FRENCH, "%6.5s", toTest)); + assertEquals("THIS ", String.format(Locale.ROOT, "%-6.5S", toTest)); assertEquals("THIS ", String.format(Locale.ENGLISH, "%-6.5S", toTest)); assertEquals("VOICI ", String.format(Locale.FRENCH, "%-6.5S", toTest)); } Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/SimpleInternationalStringTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/SimpleInternationalStringTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/SimpleInternationalStringTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/SimpleInternationalStringTest.java Tue Feb 12 16:36:05 2013 @@ -16,6 +16,7 @@ */ package org.apache.sis.util.iso; +import java.util.Locale; import org.apache.sis.test.TestCase; import org.junit.Test; @@ -41,6 +42,8 @@ public final strictfp class SimpleIntern final SimpleInternationalString toTest = new SimpleInternationalString(MESSAGE); assertSame(MESSAGE, toTest.toString()); assertSame(MESSAGE, toTest.toString(null)); + assertSame(MESSAGE, toTest.toString(Locale.ROOT)); + assertSame(MESSAGE, toTest.toString(Locale.JAPANESE)); validate(toTest); } @@ -53,6 +56,8 @@ public final strictfp class SimpleIntern final SimpleInternationalString after = assertSerializedEquals(before); assertEquals(MESSAGE, after.toString()); assertEquals(MESSAGE, after.toString(null)); + assertEquals(MESSAGE, after.toString(Locale.ROOT)); + assertEquals(MESSAGE, after.toString(Locale.JAPANESE)); validate(after); } } Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java Tue Feb 12 16:36:05 2013 @@ -81,6 +81,8 @@ public final strictfp class TypesTest ex @Test public void testGetDescription() { assertEquals("Name of the character coding standard used in the resource.", + Types.getDescription(CharacterSet.class, Locale.ROOT)); + assertEquals("Name of the character coding standard used in the resource.", Types.getDescription(CharacterSet.class, Locale.ENGLISH)); assertEquals("Jeu de caractères.", Types.getDescription(CharacterSet.class, Locale.FRENCH)); @@ -92,6 +94,8 @@ public final strictfp class TypesTest ex @Test public void testGetCodeDescription() { assertEquals("ISO/IEC 8859-1, Information technology - 8-bit single byte coded graphic character sets - Part 1 : Latin alphabet No.1.", + Types.getDescription(CharacterSet.ISO_8859_1, Locale.ROOT)); + assertEquals("ISO/IEC 8859-1, Information technology - 8-bit single byte coded graphic character sets - Part 1 : Latin alphabet No.1.", Types.getDescription(CharacterSet.ISO_8859_1, Locale.ENGLISH)); assertEquals("ISO/IEC 8859-1, alphabet latin 1.", Types.getDescription(CharacterSet.ISO_8859_1, Locale.FRENCH)); @@ -132,6 +136,7 @@ public final strictfp class TypesTest ex */ @Test public void testGetLocalizedCodeTitle() { + assertEquals("Download", Types.getCodeTitle(OnLineFunction.DOWNLOAD, Locale.ROOT)); assertEquals("Download", Types.getCodeTitle(OnLineFunction.DOWNLOAD, Locale.ENGLISH)); assertEquals("Téléchargement", Types.getCodeTitle(OnLineFunction.DOWNLOAD, Locale.FRENCH)); } Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java (original) +++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java Tue Feb 12 16:36:05 2013 @@ -40,7 +40,7 @@ import static org.apache.sis.test.Assert * @since 0.3 (derived from geotk-2.2) * @version 0.3 */ -@DependsOn(org.apache.sis.util.ArraysExtTest.class) +@DependsOn(LoaderTest.class) public final strictfp class IndexedResourceBundleTest extends TestCase { /** * The resource bundle in process of being tested. Shall be reset to {@code null} after every @@ -56,14 +56,18 @@ public final strictfp class IndexedResou public void testGetResources() { final Errors english = Errors.getResources(Locale.ENGLISH); final Errors french = Errors.getResources(Locale.FRENCH); + final Errors canada = Errors.getResources(Locale.CANADA); + final Errors quebec = Errors.getResources(Locale.CANADA_FRENCH); + assertNotSame(english, Errors.getResources(Locale.US)); + assertNotSame(english, Errors.getResources(Locale.UK)); assertNotSame(english, french); + assertNotSame(english, canada); + assertNotSame(french, quebec); assertSame(english, Errors.getResources(Locale.ENGLISH)); - assertSame(english, Errors.getResources(Locale.US)); - assertSame(english, Errors.getResources(Locale.UK)); - assertSame(english, Errors.getResources(Locale.CANADA)); + assertSame(canada, Errors.getResources(Locale.CANADA)); assertSame(french, Errors.getResources(Locale.FRENCH)); - assertSame(french, Errors.getResources(Locale.CANADA_FRENCH)); + assertSame(quebec, Errors.getResources(Locale.CANADA_FRENCH)); } /** @@ -153,11 +157,13 @@ public final strictfp class IndexedResou @DependsOnMethod("testGetResources") public void testFormatInternational() { InternationalString i18n = Errors.formatInternational(Errors.Keys.NullArgument_1); + assertEquals("Argument â{0}â shall not be null.", i18n.toString(Locale.ROOT)); assertEquals("Argument â{0}â shall not be null.", i18n.toString(Locale.ENGLISH)); assertEquals("Lâargument â{0}â ne doit pas être nul.", i18n.toString(Locale.FRENCH)); assertNotSame(i18n, assertSerializedEquals(i18n)); i18n = Errors.formatInternational(Errors.Keys.NullArgument_1, "CRS"); + assertEquals("Argument âCRSâ shall not be null.", i18n.toString(Locale.ROOT)); assertEquals("Argument âCRSâ shall not be null.", i18n.toString(Locale.ENGLISH)); assertEquals("Lâargument âCRSâ ne doit pas être nul.", i18n.toString(Locale.FRENCH)); assertNotSame(i18n, assertSerializedEquals(i18n)); Modified: sis/trunk/src/main/docbook/fr/utility.xml URL: http://svn.apache.org/viewvc/sis/trunk/src/main/docbook/fr/utility.xml?rev=1445247&r1=1445246&r2=1445247&view=diff ============================================================================== --- sis/trunk/src/main/docbook/fr/utility.xml (original) +++ sis/trunk/src/main/docbook/fr/utility.xml Tue Feb 12 16:36:05 2013 @@ -173,10 +173,10 @@ </section> <section> - <title>Convention locale nulle</title> + <title>Convention <constant>Locale.ROOT</constant></title> <para> - La plupart des méthodes <acronym>SIS</acronym> recevant ou retournant une valeur de type <classname>Locale</classname> - acceptent la valeur <constant>null</constant>. Cette valeur est interprétée comme signifiant de ne pas localiser le texte. + Toutes les méthodes <acronym>SIS</acronym> recevant ou retournant une valeur de type <classname>Locale</classname> + acceptent la valeur <constant>Locale.ROOT</constant>. Cette valeur est interprétée comme signifiant de ne pas localiser le texte. La notion de <quote>texte non-localisé</quote> est un peu fausse, puisquâil faut bien choisir une convention de format. Mais cette convention, bien que très proche de lâanglais, sera généralement légèrement différente. Par exemple:
