Author: luc Date: Sun Feb 25 07:48:07 2007 New Revision: 511531 URL: http://svn.apache.org/viewvc?view=rev&rev=511531 Log: make the code java 1.3 compatible
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/MathException.java Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/MathException.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/MathException.java?view=diff&rev=511531&r1=511530&r2=511531 ============================================================================== --- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/MathException.java (original) +++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/MathException.java Sun Feb 25 07:48:07 2007 @@ -102,6 +102,20 @@ } /** + * Builds a message string by from a pattern and its arguments. + * @param pattern format specifier + * @param arguments format arguments + * @param locale Locale in which the message should be translated + * @return a message string + */ + private static String buildMessage(String pattern, Object[] arguments, Locale locale) { + // do it the hard way, for Java 1.3. compatibility + MessageFormat mf = new MessageFormat(translate(pattern, locale)); + mf.setLocale(locale); + return mf.format(arguments); + } + + /** * Constructs a new <code>MathException</code> with no * detail message. */ @@ -134,7 +148,7 @@ * @param arguments format arguments */ public MathException(String pattern, Object[] arguments) { - super(new MessageFormat(pattern, Locale.US).format(arguments)); + super(buildMessage(pattern, arguments, Locale.US)); this.pattern = pattern; this.arguments = arguments; this.rootCause = null; @@ -180,7 +194,7 @@ * to be thrown. */ public MathException(String pattern, Object[] arguments, Throwable rootCause) { - super(new MessageFormat(pattern, Locale.US).format(arguments)); + super(buildMessage(pattern, arguments, Locale.US)); this.pattern = pattern; this.arguments = arguments; this.rootCause = rootCause; @@ -209,10 +223,7 @@ * @return localized message */ public String getMessage(Locale locale) { - if (pattern == null) { - return null; - } - return new MessageFormat(translate(pattern, locale), locale).format(arguments); + return (pattern == null) ? null : buildMessage(pattern, arguments, locale); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]