Author: psteitz
Date: Sun Oct 2 18:10:03 2011
New Revision: 1178211
URL: http://svn.apache.org/viewvc?rev=1178211&view=rev
Log:
Replaced obsolete exceptions.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ResizableDoubleArray.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ResizableDoubleArray.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ResizableDoubleArray.java?rev=1178211&r1=1178210&r2=1178211&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ResizableDoubleArray.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ResizableDoubleArray.java
Sun Oct 2 18:10:03 2011
@@ -19,7 +19,8 @@ package org.apache.commons.math.util;
import java.io.Serializable;
import java.util.Arrays;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.apache.commons.math.exception.MathIllegalStateException;
import org.apache.commons.math.exception.NullArgumentException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -360,15 +361,16 @@ public class ResizableDoubleArray implem
/**
* Substitutes <code>value</code> for the most recently added value.
* Returns the value that has been replaced. If the array is empty (i.e.
- * if {@link #numElements} is zero), a MathRuntimeException is thrown.
+ * if {@link #numElements} is zero), an IllegalStateException is thrown.
*
* @param value new value to substitute for the most recently added value
* @return value that has been replaced in the array
+ * @throws IllegalStateException if the array is empty
* @since 2.0
*/
public synchronized double substituteMostRecentElement(double value) {
if (numElements < 1) {
- throw MathRuntimeException.createArrayIndexOutOfBoundsException(
+ throw new MathIllegalStateException(
LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
}
@@ -393,19 +395,19 @@ public class ResizableDoubleArray implem
protected void checkContractExpand(float contraction, float expansion) {
if (contraction < expansion) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.CONTRACTION_CRITERIA_SMALLER_THAN_EXPANSION_FACTOR,
contraction, expansion);
}
if (contraction <= 1.0) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.CONTRACTION_CRITERIA_SMALLER_THAN_ONE,
contraction);
}
if (expansion <= 1.0) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.EXPANSION_FACTOR_SMALLER_THAN_ONE,
expansion);
}
@@ -492,11 +494,11 @@ public class ResizableDoubleArray implem
*/
private synchronized void discardExtremeElements(int i,boolean front) {
if (i > numElements) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY,
i, numElements);
} else if (i < 0) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS,
i);
} else {
@@ -578,15 +580,11 @@ public class ResizableDoubleArray implem
*/
public synchronized double getElement(int index) {
if (index >= numElements) {
- throw MathRuntimeException.createArrayIndexOutOfBoundsException(
- LocalizedFormats.INDEX_LARGER_THAN_MAX,
- index, numElements - 1);
+ throw new ArrayIndexOutOfBoundsException(index);
} else if (index >= 0) {
return internalArray[startIndex + index];
} else {
- throw MathRuntimeException.createArrayIndexOutOfBoundsException(
- LocalizedFormats.CANNOT_RETRIEVE_AT_NEGATIVE_INDEX,
- index);
+ throw new ArrayIndexOutOfBoundsException(index);
}
}
@@ -696,9 +694,7 @@ public class ResizableDoubleArray implem
*/
public synchronized void setElement(int index, double value) {
if (index < 0) {
- throw MathRuntimeException.createArrayIndexOutOfBoundsException(
- LocalizedFormats.CANNOT_SET_AT_NEGATIVE_INDEX,
- index);
+ throw new ArrayIndexOutOfBoundsException(index);
}
if (index + 1 > numElements) {
numElements = index + 1;
@@ -738,7 +734,7 @@ public class ResizableDoubleArray implem
public void setExpansionMode(int expansionMode) {
if (expansionMode != MULTIPLICATIVE_MODE &&
expansionMode != ADDITIVE_MODE) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.UNSUPPORTED_EXPANSION_MODE,
expansionMode, MULTIPLICATIVE_MODE, "MULTIPLICATIVE_MODE",
ADDITIVE_MODE, "ADDITIVE_MODE");
@@ -761,7 +757,7 @@ public class ResizableDoubleArray implem
this.initialCapacity = initialCapacity;
}
} else {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
initialCapacity);
}
@@ -779,7 +775,7 @@ public class ResizableDoubleArray implem
// If index is negative thrown an error
if (i < 0) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.INDEX_NOT_POSITIVE,
i);
}