Author: erans Date: Tue Mar 15 11:42:23 2011 New Revision: 1081741 URL: http://svn.apache.org/viewvc?rev=1081741&view=rev Log: MATH-542 Allow to "addMessage" without arguments (avoiding the need to explicitly pass "null").
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathArithmeticException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathRuntimeException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathThrowable.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUnsupportedOperationException.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUserException.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/MathRuntimeExceptionTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java Tue Mar 15 11:42:23 2011 @@ -133,6 +133,11 @@ public class MathException extends Excep } /** {@inheritDoc} */ + public void addMessage(Localizable pat) { + throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + } + + /** {@inheritDoc} */ public void addMessage(Localizable pat, Object ... args) { throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java Tue Mar 15 11:42:23 2011 @@ -126,6 +126,11 @@ public class MathRuntimeException extend } /** {@inheritDoc} */ + public void addMessage(Localizable pat) { + throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); + } + + /** {@inheritDoc} */ public void addMessage(Localizable pat, Object ... args) { throw new UnsupportedOperationException("This class is deprecated; calling this method is a bug."); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathArithmeticException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathArithmeticException.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathArithmeticException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathArithmeticException.java Tue Mar 15 11:42:23 2011 @@ -36,7 +36,7 @@ public class MathArithmeticException ext * Default constructor. */ public MathArithmeticException() { - addMessage(LocalizedFormats.ARITHMETIC_EXCEPTION, null); + addMessage(LocalizedFormats.ARITHMETIC_EXCEPTION); } /** Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java Tue Mar 15 11:42:23 2011 @@ -59,6 +59,6 @@ public class MathIllegalStateException e * Default constructor. */ public MathIllegalStateException() { - addMessage(LocalizedFormats.ILLEGAL_STATE, null); + addMessage(LocalizedFormats.ILLEGAL_STATE); } } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathRuntimeException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathRuntimeException.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathRuntimeException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathRuntimeException.java Tue Mar 15 11:42:23 2011 @@ -67,6 +67,11 @@ public class MathRuntimeException extend } /** {@inheritDoc} */ + public void addMessage(Localizable pattern) { + messages.add(new SerializablePair<Localizable, Object[]>(pattern, (Object[]) null)); + } + + /** {@inheritDoc} */ public void addMessage(Localizable pattern, Object ... arguments) { messages.add(new SerializablePair<Localizable, Object[]>(pattern, Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathThrowable.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathThrowable.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathThrowable.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathThrowable.java Tue Mar 15 11:42:23 2011 @@ -31,6 +31,13 @@ public interface MathThrowable { /** * Sets a message. * + * @param pattern Message. + */ + void addMessage(Localizable pattern); + + /** + * Sets a message. + * * @param pattern Message pattern. * @param arguments Values for replacing the placeholders in the message * pattern. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUnsupportedOperationException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUnsupportedOperationException.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUnsupportedOperationException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUnsupportedOperationException.java Tue Mar 15 11:42:23 2011 @@ -36,7 +36,7 @@ public class MathUnsupportedOperationExc * Default constructor. */ public MathUnsupportedOperationException() { - this(LocalizedFormats.UNSUPPORTED_OPERATION, null); + this(LocalizedFormats.UNSUPPORTED_OPERATION); } /** * @param pattern Message pattern providing the specific context of Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUserException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUserException.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUserException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathUserException.java Tue Mar 15 11:42:23 2011 @@ -36,7 +36,7 @@ public class MathUserException extends M * Build an exception with a default message. */ public MathUserException() { - addMessage(LocalizedFormats.USER_EXCEPTION, null); + addMessage(LocalizedFormats.USER_EXCEPTION); } /** @@ -45,7 +45,7 @@ public class MathUserException extends M */ public MathUserException(final Throwable cause) { super(cause); - addMessage(LocalizedFormats.USER_EXCEPTION, null); + addMessage(LocalizedFormats.USER_EXCEPTION); } /** Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/MathRuntimeExceptionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/MathRuntimeExceptionTest.java?rev=1081741&r1=1081740&r2=1081741&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/MathRuntimeExceptionTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/MathRuntimeExceptionTest.java Tue Mar 15 11:42:23 2011 @@ -38,7 +38,7 @@ public class MathRuntimeExceptionTest { @Test public void testMessageChain() { final MathRuntimeException mre = new MathRuntimeException(); - final String sep = ": "; + final String sep = " | "; // Non-default separator. final String m1 = "column index (0)"; mre.addMessage(LocalizedFormats.COLUMN_INDEX, 0); final String m2 = "got 1x2 but expected 3x4"; @@ -59,6 +59,13 @@ public class MathRuntimeExceptionTest { } @Test + public void testNoArgAddMessage() { + final MathRuntimeException mre = new MathRuntimeException(); + mre.addMessage(LocalizedFormats.SIMPLE_MESSAGE); + Assert.assertEquals(mre.getMessage(), "{0}"); + } + + @Test public void testContext() { final MathRuntimeException mre = new MathRuntimeException();