From d3b5b119873b9186857a8c324362437ce3828848 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Thu, 19 Nov 2020 10:15:58 +0100 Subject: Improved code quality according to SonarLint --- .../src/main/java/at/asit/pdfover/gui/utils/Messages.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java index 6271656c..c48337e6 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java @@ -38,10 +38,7 @@ public class Messages { private static final String BUNDLE_NAME = "at.asit.pdfover.gui.messages"; //$NON-NLS-1$ - private static HashMap bundles = new HashMap(); - - //private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - // .getBundle(BUNDLE_NAME); + private static HashMap bundles = new HashMap<>(); private static Locale currentLocale = getDefaultLocale(); @@ -71,17 +68,17 @@ public class Messages { private static ResourceBundle getBundle(Locale locale) { if(!bundles.containsKey(locale)) { - log.debug("Loading resource bundle for " + locale); //$NON-NLS-1$ + log.debug("Loading resource bundle for {}", locale); //$NON-NLS-1$ ResourceBundle tmp = null; try { tmp = ResourceBundle.getBundle(BUNDLE_NAME, locale); - log.debug("Received bundle for " + tmp.getLocale()); //$NON-NLS-1$ + log.debug("Received bundle for {}", tmp.getLocale()); //$NON-NLS-1$ } catch(Exception e) { - log.error("NO RESOURCE BUNDLE FOR " + locale.toString(), e); //$NON-NLS-1$ + log.error("NO RESOURCE BUNDLE FOR {} {}", locale, e); //$NON-NLS-1$ tmp = ResourceBundle.getBundle(BUNDLE_NAME); } if(tmp == null) { - log.error("NO RESOURCE BUNDLE FOR " + locale.toString()); //$NON-NLS-1$ + log.error("NO RESOURCE BUNDLE FOR {}", locale); //$NON-NLS-1$ tmp = ResourceBundle.getBundle(BUNDLE_NAME); } bundles.put(locale, tmp); @@ -98,7 +95,6 @@ public class Messages { public static String getString(String key) { try { return getBundle(currentLocale).getString(key); - //return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { return '!' + key + '!'; } @@ -113,7 +109,6 @@ public class Messages { public static String getString(String key, Locale locale) { try { return getBundle(locale).getString(key); - //return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { return '!' + key + '!'; } -- cgit v1.2.3