From 59a4edb84d8cb85ac38e4d32251d71970bed177e Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Sun, 1 Aug 2010 15:35:33 +0000 Subject: [PATCH] added a getMessage(final Locale locale) to class MathIllegalArgumentException similar to the ones from MathException and MathRuntimeException git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@981247 13f79535-47bb-0310-9956-ffa450edef68 --- .../MathIllegalArgumentException.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java b/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java index 796e23c5b..632d8f6ac 100644 --- a/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java +++ b/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java @@ -71,32 +71,35 @@ public class MathIllegalArgumentException extends IllegalArgumentException { this(null, general, args); } - /** {@inheritDoc} */ + /** Gets the message in a specified locale. + * + * @param locale Locale in which the message should be translated + * + * @return localized message + * @since 2.2 + */ + public String getMessage(final Locale locale) { + final StringBuilder sb = new StringBuilder(); + + if (specific != null) { + sb.append(MessageFactory.buildMessage(locale, specific, arguments)); + sb.append(": "); + } + sb.append(MessageFactory.buildMessage(locale, general, arguments)); + + return sb.toString(); + } + + /** {@inheritDoc} */ @Override public String getMessage() { - final StringBuilder sb = new StringBuilder(); - - if (specific != null) { - sb.append(MessageFactory.buildMessage(Locale.US, specific, arguments)); - sb.append(": "); - } - sb.append(MessageFactory.buildMessage(Locale.US, general, arguments)); - - return sb.toString(); + return getMessage(Locale.US); } /** {@inheritDoc} */ @Override public String getLocalizedMessage() { - final StringBuilder sb = new StringBuilder(); - - if (specific != null) { - sb.append(MessageFactory.buildMessage(Locale.getDefault(), specific, arguments)); - sb.append(": "); - } - sb.append(MessageFactory.buildMessage(Locale.getDefault(), general, arguments)); - - return sb.toString(); + return getMessage(Locale.getDefault()); } /**