diff options
author | Thomas <> | 2021-03-24 12:16:25 +0100 |
---|---|---|
committer | Thomas <> | 2021-03-24 12:16:25 +0100 |
commit | 835a395f3ecb7477b5b67e9da9bf3af58c86473a (patch) | |
tree | 916fa7705879063f6b83517d80197c37dc53caf8 /moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java | |
parent | a972fba0402eca3c5fcfcd1eef1979808fd716a1 (diff) | |
parent | 666d8c9f8cec7573e60a14ab039c0874f6a9ec53 (diff) | |
download | moa-sig-835a395f3ecb7477b5b67e9da9bf3af58c86473a.tar.gz moa-sig-835a395f3ecb7477b5b67e9da9bf3af58c86473a.tar.bz2 moa-sig-835a395f3ecb7477b5b67e9da9bf3af58c86473a.zip |
Merge branch 'master' of gitlab.iaik.tugraz.at:egiz/moa-sig
# Conflicts:
# moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/config/ConfigurationPartsBuilder.java
# moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProvider.java
Diffstat (limited to 'moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java')
-rw-r--r-- | moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java | 55 |
1 files changed, 27 insertions, 28 deletions
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 <code>Locale</code>s of the resources. */ - private Locale[] locales; + private final Locale[] locales; /** The <code>ResourceBundle</code>s containing the messages. */ private ResourceBundleChain messages; /** - * Create a new <code>Message</code> object containing the messages - * in the given resources. - * + * Create a new <code>Message</code> 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 <code>Locale</code>s of the resources containing the messages. - * - * @return Locale[] The <code>Locale</code>s of the resource bundles - * containing the messages. + * + * @return Locale[] The <code>Locale</code>s 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); } } |