Major code cleanup, formatting and styling, warnings removed
git-svn-id: https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/localization@670330 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java b/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
index 2a15865..a2ec875 100644
--- a/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
+++ b/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
@@ -53,7 +53,7 @@
* The default quality value for an <code>AcceptLanguage</code>
* object.
*/
- private static final Float DEFAULT_QUALITY = new Float(1.0f);
+ protected static final Float DEFAULT_QUALITY = new Float(1.0f);
/**
* The parsed locales.
@@ -90,6 +90,7 @@
}
catch (NumberFormatException useDefault)
{
+ // ignore
}
}
}
@@ -153,7 +154,7 @@
* Struct representing an element of the HTTP
* <code>Accept-Language</code> header.
*/
- private class AcceptLanguage implements Comparable
+ protected static class AcceptLanguage implements Comparable
{
/**
* The language and country.
diff --git a/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java b/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
index 978c920..18609f6 100644
--- a/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
+++ b/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
@@ -509,6 +509,7 @@
}
catch (MissingResourceException ignored)
{
+ // ignore
}
}
return null;
@@ -554,24 +555,14 @@
String key,
Object[] args)
{
- if (locale == null)
- {
- // When formatting Date objects and such, MessageFormat
- // cannot have a null Locale.
- locale = getDefaultLocale();
- }
+ // When formatting Date objects and such, MessageFormat
+ // cannot have a null Locale.
+ Locale formatLocale = (locale == null) ? getDefaultLocale() : locale;
String value = getString(bundleName, locale, key);
- if (args == null)
- {
- args = NO_ARGS;
- }
- // FIXME: after switching to JDK 1.4, it will be possible to clean
- // this up by providing the Locale along with the string in the
- // constructor to MessageFormat. Until 1.4, the following workaround
- // is required for constructing the format with the appropriate locale:
- MessageFormat messageFormat = new MessageFormat("");
- messageFormat.setLocale(locale);
- messageFormat.applyPattern(value);
- return messageFormat.format(args);
+
+ Object[] formatArgs = (args == null) ? NO_ARGS : args;
+
+ MessageFormat messageFormat = new MessageFormat(value, formatLocale);
+ return messageFormat.format(formatArgs);
}
}