From 578ad0d6bc408edf9e6c875156054374f5fd8337 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 22 Mar 2021 18:40:26 +0100 Subject: change to EGIZ codestyle --- .../at/gv/egovernment/moaspss/util/Messages.java | 55 +++++++++++----------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java') diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java index 6e324b7..61d9b65 100644 --- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java +++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java @@ -21,47 +21,46 @@ * that you distribute must include a readable copy of the "NOTICE" text file. */ - package at.gv.egovernment.moaspss.util; import java.text.MessageFormat; import java.util.Locale; import java.util.MissingResourceException; -import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; import at.gv.egovernment.moaspss.logging.Logger; /** * Provides access to the system messages resource used for exception handling * and logging messages. - * + * * Messages must be provided as a resource bundle at the path. - * + * * @author Patrick Peck * @version $Id$ */ public class Messages { /** Error message indicating that no messages are avaiable. */ private static final String ERROR_MESSAGES_UNAVAILABLE = - "Fehler in der Server-Konfiguration. " - + "Die Fehlertexte konnten nicht geladen werden."; + "Fehler in der Server-Konfiguration. " + + "Die Fehlertexte konnten nicht geladen werden."; /** Error message indicating that the message is not available. */ private static final String ERROR_NO_MESSAGE = - "No errormesseage for error with number.={0}"; + "No errormesseage for error with number.={0}"; /** The names of the resources containing the messages. */ - private String[] resourceNames; + private final String[] resourceNames; /** The corresponding Locales of the resources. */ - private Locale[] locales; + private final Locale[] locales; /** The ResourceBundles containing the messages. */ private ResourceBundleChain messages; /** - * Create a new Message object containing the messages - * in the given resources. - * + * Create a new Message object containing the messages in the given + * resources. + * * @param resourceNames The names of the resources containing the messages. - * @param locales The corresponding locales. + * @param locales The corresponding locales. */ public Messages(String[] resourceNames, Locale[] locales) { this.resourceNames = resourceNames; @@ -72,9 +71,9 @@ public class Messages { /** * Get the message corresponding to a given message ID. * - * @param messageId The ID of the message. + * @param messageId The ID of the message. * @param parameters The parameters to fill in into the message arguments. - * @return The formatted message. + * @return The formatted message. */ public String getMessage(String messageId, Object[] parameters) { // initialize messages @@ -87,20 +86,20 @@ public class Messages { return ERROR_MESSAGES_UNAVAILABLE; } else { try { - String rawMessage = messages.getString(messageId); + final String rawMessage = messages.getString(messageId); return MessageFormat.format(rawMessage, parameters); - } catch (MissingResourceException e2) { - // couldn't find any message -> set to default error message + } catch (final MissingResourceException e2) { + // couldn't find any message -> set to default error message return MessageFormat.format( - ERROR_NO_MESSAGE, - new Object[] { messageId }); + ERROR_NO_MESSAGE, + new Object[] { messageId }); } } } /** * Return the names of the resources containing the messages. - * + * * @return String[] The names of the resource bundles containing the messages. */ private String[] getResourceNames() { @@ -109,9 +108,9 @@ public class Messages { /** * Return the Locales of the resources containing the messages. - * - * @return Locale[] The Locales of the resource bundles - * containing the messages. + * + * @return Locale[] The Locales of the resource bundles containing + * the messages. */ private Locale[] getLocales() { return locales; @@ -129,10 +128,10 @@ public class Messages { for (i = 0; i < resourceNames.length; i++) { try { messages.addResourceBundle( - PropertyResourceBundle.getBundle( - getResourceNames()[i], - getLocales()[i])); - } catch (MissingResourceException e) { + ResourceBundle.getBundle( + getResourceNames()[i], + getLocales()[i])); + } catch (final MissingResourceException e) { Logger.error(ERROR_MESSAGES_UNAVAILABLE, e); } } -- cgit v1.2.3