From 2431890261cbfe3cf0b5ba85e3037426c646adcf Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Sun, 1 Aug 2010 15:16:54 +0000 Subject: [PATCH] deprecated an old style exception that was forgotten git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@981243 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/math/linear/AbstractFieldMatrix.java | 4 ++-- .../commons/math/linear/AbstractRealVector.java | 5 ++--- .../apache/commons/math/linear/ArrayFieldVector.java | 5 ++--- .../commons/math/linear/MatrixIndexException.java | 2 ++ .../org/apache/commons/math/linear/MatrixUtils.java | 4 ++-- .../apache/commons/math/linear/SparseFieldVector.java | 5 ++--- .../commons/math/linear/MatrixIndexExceptionTest.java | 11 +++++++---- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java b/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java index 89f25f612..a412b4b3a 100644 --- a/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java +++ b/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java @@ -1020,7 +1020,7 @@ public abstract class AbstractFieldMatrix> implements */ protected void checkRowIndex(final int row) { if (row < 0 || row >= getRowDimension()) { - throw new MatrixIndexException("row index {0} out of allowed range [{1}, {2}]", + throw new MatrixIndexException(LocalizedFormats.ROW_INDEX_OUT_OF_RANGE, row, 0, getRowDimension() - 1); } } @@ -1033,7 +1033,7 @@ public abstract class AbstractFieldMatrix> implements protected void checkColumnIndex(final int column) throws MatrixIndexException { if (column < 0 || column >= getColumnDimension()) { - throw new MatrixIndexException("column index {0} out of allowed range [{1}, {2}]", + throw new MatrixIndexException(LocalizedFormats.COLUMN_INDEX_OUT_OF_RANGE, column, 0, getColumnDimension() - 1); } } diff --git a/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java b/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java index 4333f87f6..0c7443c4e 100644 --- a/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java +++ b/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java @@ -69,9 +69,8 @@ public abstract class AbstractRealVector implements RealVector { protected void checkIndex(final int index) throws MatrixIndexException { if (index < 0 || index >= getDimension()) { - throw new MatrixIndexException( - "index {0} out of allowed range [{1}, {2}]", - index, 0, getDimension() - 1); + throw new MatrixIndexException(LocalizedFormats.INDEX_OUT_OF_RANGE, + index, 0, getDimension() - 1); } } diff --git a/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java b/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java index 99f4edc09..9b7dbae79 100644 --- a/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java +++ b/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java @@ -794,9 +794,8 @@ public class ArrayFieldVector> implements FieldVector< private void checkIndex(final int index) throws MatrixIndexException { if (index < 0 || index >= getDimension()) { - throw new MatrixIndexException( - "index {0} out of allowed range [{1}, {2}]", - index, 0, getDimension() - 1); + throw new MatrixIndexException(LocalizedFormats.INDEX_OUT_OF_RANGE, + index, 0, getDimension() - 1); } } diff --git a/src/main/java/org/apache/commons/math/linear/MatrixIndexException.java b/src/main/java/org/apache/commons/math/linear/MatrixIndexException.java index 27adacad0..d9cb11d35 100644 --- a/src/main/java/org/apache/commons/math/linear/MatrixIndexException.java +++ b/src/main/java/org/apache/commons/math/linear/MatrixIndexException.java @@ -35,7 +35,9 @@ public class MatrixIndexException extends MathRuntimeException { * Constructs a new instance with specified formatted detail message. * @param pattern format specifier * @param arguments format arguments + * @deprecated as of 2.2 replaced by {@link #MatrixIndexException(Localizable, Object...)} */ + @Deprecated public MatrixIndexException(final String pattern, final Object ... arguments) { this(new DummyLocalizable(pattern), arguments); } diff --git a/src/main/java/org/apache/commons/math/linear/MatrixUtils.java b/src/main/java/org/apache/commons/math/linear/MatrixUtils.java index 387848020..875675223 100644 --- a/src/main/java/org/apache/commons/math/linear/MatrixUtils.java +++ b/src/main/java/org/apache/commons/math/linear/MatrixUtils.java @@ -529,7 +529,7 @@ public class MatrixUtils { */ public static void checkRowIndex(final AnyMatrix m, final int row) { if (row < 0 || row >= m.getRowDimension()) { - throw new MatrixIndexException("row index {0} out of allowed range [{1}, {2}]", + throw new MatrixIndexException(LocalizedFormats.ROW_INDEX_OUT_OF_RANGE, row, 0, m.getRowDimension() - 1); } } @@ -543,7 +543,7 @@ public class MatrixUtils { public static void checkColumnIndex(final AnyMatrix m, final int column) throws MatrixIndexException { if (column < 0 || column >= m.getColumnDimension()) { - throw new MatrixIndexException("column index {0} out of allowed range [{1}, {2}]", + throw new MatrixIndexException(LocalizedFormats.COLUMN_INDEX_OUT_OF_RANGE, column, 0, m.getColumnDimension() - 1); } } diff --git a/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java b/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java index 2c000f57a..8a087a9a2 100644 --- a/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java +++ b/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java @@ -549,9 +549,8 @@ public class SparseFieldVector> implements FieldVector */ private void checkIndex(final int index) throws MatrixIndexException { if (index < 0 || index >= getDimension()) { - throw new MatrixIndexException( - "index {0} out of allowed range [{1}, {2}]", - index, 0, getDimension() - 1); + throw new MatrixIndexException(LocalizedFormats.INDEX_OUT_OF_RANGE, + index, 0, getDimension() - 1); } } diff --git a/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java b/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java index 37e5fd485..0a52f609a 100644 --- a/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java +++ b/src/test/java/org/apache/commons/math/linear/MatrixIndexExceptionTest.java @@ -17,6 +17,8 @@ package org.apache.commons.math.linear; +import org.apache.commons.math.util.LocalizedFormats; + import junit.framework.TestCase; /** @@ -27,9 +29,10 @@ public class MatrixIndexExceptionTest extends TestCase { /** * */ - public void testConstructorMessage(){ - String msg = "message"; - MatrixIndexException ex = new MatrixIndexException(msg); - assertEquals(msg, ex.getMessage()); + public void testParameter(){ + MatrixIndexException ex = new MatrixIndexException(LocalizedFormats.INDEX_OUT_OF_RANGE, 12, 0, 5); + assertEquals(12, ex.getArguments()[0]); + assertEquals(0, ex.getArguments()[1]); + assertEquals(5, ex.getArguments()[2]); } }