Author: markt Date: Mon Nov 10 15:39:11 2014 New Revision: 1637890 URL: http://svn.apache.org/r1637890 Log: Clean-up - Consistent whitespace - Fix Java8 Javadoc warnings - Remove unnecessary synchronized
Modified: tomcat/trunk/java/org/apache/tomcat/util/res/StringManager.java Modified: tomcat/trunk/java/org/apache/tomcat/util/res/StringManager.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/res/StringManager.java?rev=1637890&r1=1637889&r2=1637890&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/res/StringManager.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/res/StringManager.java Mon Nov 10 15:39:11 2014 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.tomcat.util.res; import java.text.MessageFormat; @@ -40,7 +39,7 @@ import java.util.ResourceBundle; * the package name given plus the suffix of "LocalStrings". In * practice, this means that the localized information will be contained * in a LocalStrings.properties file located in the package - * directory of the classpath. + * directory of the class path. * * <p>Please see the documentation for java.util.ResourceBundle for * more information. @@ -60,6 +59,7 @@ public class StringManager { private final ResourceBundle bundle; private final Locale locale; + /** * Creates a new StringManager for a given package. This is a * private method and all access to it is arbitrated by the @@ -73,15 +73,15 @@ public class StringManager { ResourceBundle bnd = null; try { bnd = ResourceBundle.getBundle(bundleName, locale); - } catch( MissingResourceException ex ) { + } catch (MissingResourceException ex) { // Try from the current loader (that's the case for trusted apps) // Should only be required if using a TC5 style classloader structure // where common != shared != server ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if( cl != null ) { + if (cl != null) { try { bnd = ResourceBundle.getBundle(bundleName, locale, cl); - } catch(MissingResourceException ex2) { + } catch (MissingResourceException ex2) { // Ignore } } @@ -100,19 +100,21 @@ public class StringManager { } } - /** - Get a string from the underlying resource bundle or return - null if the String is not found. - @param key to desired resource String - @return resource String matching <i>key</i> from underlying - bundle or null if not found. - @throws IllegalArgumentException if <i>key</i> is null. + /** + * Get a string from the underlying resource bundle or return null if the + * String is not found. + * + * @param key to desired resource String + * + * @return resource String matching <i>key</i> from underlying bundle or + * null if not found. + * + * @throws IllegalArgumentException if <i>key</i> is null */ public String getString(String key) { - if(key == null){ + if (key == null){ String msg = "key may not have a null value"; - throw new IllegalArgumentException(msg); } @@ -123,7 +125,7 @@ public class StringManager { if (bundle != null) { str = bundle.getString(key); } - } catch(MissingResourceException mre) { + } catch (MissingResourceException mre) { //bad: shouldn't mask an exception the following way: // str = "[cannot find message associated with key '" + key + // "' due to " + mre + "]"; @@ -141,12 +143,13 @@ public class StringManager { return str; } + /** * Get a string from the underlying resource bundle and format * it with the given set of arguments. * - * @param key - * @param args + * @param key The key for the required message + * @param args The values to insert into the message */ public String getString(final String key, final Object... args) { String value = getString(key); @@ -159,6 +162,7 @@ public class StringManager { return mf.format(args, new StringBuffer(), null).toString(); } + /** * Identify the Locale this StringManager is associated with */ @@ -166,6 +170,7 @@ public class StringManager { return locale; } + // -------------------------------------------------------------- // STATIC SUPPORT METHODS // -------------------------------------------------------------- @@ -173,6 +178,7 @@ public class StringManager { private static final Map<String, Map<Locale,StringManager>> managers = new Hashtable<>(); + /** * Get the StringManager for a particular package. If a manager for * a package already exists, it will be reused, else a new @@ -180,11 +186,11 @@ public class StringManager { * * @param packageName The package name */ - public static final synchronized StringManager getManager( - String packageName) { + public static final StringManager getManager(String packageName) { return getManager(packageName, Locale.getDefault()); } + /** * Get the StringManager for a particular package and Locale. If a manager * for a package/Locale combination already exists, it will be reused, else @@ -228,6 +234,7 @@ public class StringManager { return mgr; } + /** * Retrieve the StringManager for a list of Locales. The first StringManager * found will be returned. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org