Author: painter
Date: Tue Dec 18 13:47:22 2018
New Revision: 1849175
URL: http://svn.apache.org/viewvc?rev=1849175&view=rev
Log:
Code cleanup from PMD/FindBugs reports
Modified:
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
Modified:
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java?rev=1849175&r1=1849174&r2=1849175&view=diff
==============================================================================
---
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
(original)
+++
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
Tue Dec 18 13:47:22 2018
@@ -168,10 +168,21 @@ public class LocaleTokenizer
* <code>1.0</code>, they indicate increased user preference).
*/
Float quality = DEFAULT_QUALITY;
-
- public final int compareTo(Object acceptLang)
+
+ @Override
+ public int compareTo(Object acceptLang)
{
- return quality.compareTo( ((AcceptLanguage) acceptLang).quality );
+ if ( acceptLang == null )
+ throw new NullPointerException("AcceptLanguage
not found");
+
+ if ( acceptLang instanceof AcceptLanguage )
+ {
+ Float q2 = ((AcceptLanguage)
acceptLang).quality;
+ return quality.compareTo( q2 );
+ } else {
+ throw new NullPointerException("The object to
compare is not the correct type");
+ }
+
}
}
}
Modified:
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java?rev=1849175&r1=1849174&r2=1849175&view=diff
==============================================================================
---
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
(original)
+++
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
Tue Dec 18 13:47:22 2018
@@ -74,31 +74,33 @@ public class SimpleLocalizationServiceIm
{
/** Key Prefix for our bundles */
private static final String BUNDLES = "bundles";
+
/**
* The value to pass to <code>MessageFormat</code> if a
* <code>null</code> reference is passed to <code>format()</code>.
*/
private static final Object[] NO_ARGS = new Object[0];
+
/**
* Bundle name keys a HashMap of the ResourceBundles in this
* service (which is in turn keyed by Locale).
*/
private HashMap<String, HashMap<Locale, ResourceBundle>> bundles = null;
+
/**
* The list of default bundles to search.
*/
private String[] bundleNames = null;
- /**
- * The default bundle name to use if not specified.
- */
- private String defaultBundleName = null;
+
/**
* The name of the default locale to use (includes language and
* country).
*/
private Locale defaultLocale = null;
+
/** The name of the default language to use. */
- private String defaultLanguage;
+ private String defaultLanguage = null;
+
/** The name of the default country to use. */
private String defaultCountry = null;
@@ -176,33 +178,10 @@ public class SimpleLocalizationServiceIm
*/
protected void initBundleNames(String[] intBundleNames)
{
- //System.err.println("cfg=" + getConfiguration());
- if (defaultBundleName != null && defaultBundleName.length() > 0)
- {
- // Using old-style single bundle name property.
- if (intBundleNames == null || intBundleNames.length <= 0)
- {
- bundleNames = new String[] { defaultBundleName };
- }
- else
- {
- // Prepend "default" bundle name.
- String[] array = new String[intBundleNames.length + 1];
- array[0] = defaultBundleName;
- System.arraycopy(
- intBundleNames,
- 0,
- array,
- 1,
- intBundleNames.length);
- bundleNames = array;
- }
- }
if (intBundleNames == null)
- {
bundleNames = new String[0];
- }
- bundleNames = intBundleNames;
+ else
+ bundleNames = intBundleNames;
}
/**