You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2012/02/03 19:17:22 UTC
svn commit: r1240279 - in
/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util:
DefaultTransformer.java NumberTransformer.java TransformerMap.java
Author: tn
Date: Fri Feb 3 18:17:21 2012
New Revision: 1240279
URL: http://svn.apache.org/viewvc?rev=1240279&view=rev
Log:
Removed usage of MathException in NumberTransformer and related classes.
JIRA: MATH-488
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/NumberTransformer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/TransformerMap.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java?rev=1240279&r1=1240278&r2=1240279&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java Fri Feb 3 18:17:21 2012
@@ -19,8 +19,8 @@ package org.apache.commons.math.util;
import java.io.Serializable;
-import org.apache.commons.math.MathException;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
import org.apache.commons.math.exception.NullArgumentException;
/**
@@ -39,11 +39,14 @@ public class DefaultTransformer implemen
/**
* @param o the object that gets transformed.
* @return a double primitive representation of the Object o.
- * @throws MathException if it cannot successfully be transformed.
- * @throws NullArgumentException if is {@code null}.
+ * @throws NullArgumentException if Object <code>o</code> is {@code null}.
+ * @throws MathIllegalArgumentException if Object <code>o</code>
+ * cannot successfully be transformed
* @see <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/Transformer.html">Commons Collections Transformer</a>
*/
- public double transform(Object o) throws MathException {
+ public double transform(Object o)
+ throws NullArgumentException, MathIllegalArgumentException {
+
if (o == null) {
throw new NullArgumentException(LocalizedFormats.OBJECT_TRANSFORMATION);
}
@@ -55,8 +58,8 @@ public class DefaultTransformer implemen
try {
return Double.valueOf(o.toString()).doubleValue();
} catch (NumberFormatException e) {
- throw new MathException(e,
- LocalizedFormats.CANNOT_TRANSFORM_TO_DOUBLE, e.getMessage());
+ throw new MathIllegalArgumentException(LocalizedFormats.CANNOT_TRANSFORM_TO_DOUBLE,
+ o.toString());
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/NumberTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/NumberTransformer.java?rev=1240279&r1=1240278&r2=1240279&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/NumberTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/NumberTransformer.java Fri Feb 3 18:17:21 2012
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math.util;
-import org.apache.commons.math.MathException;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
/**
* Subclasses implementing this interface can transform Objects to doubles.
@@ -33,7 +33,7 @@ public interface NumberTransformer {
*
* @param o the Object to be transformed.
* @return the double value of the Object.
- * @throws MathException if the Object can not be transformed into a Double.
+ * @throws MathIllegalArgumentException if the Object can not be transformed into a Double.
*/
- double transform(Object o) throws MathException;
+ double transform(Object o) throws MathIllegalArgumentException;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/TransformerMap.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/TransformerMap.java?rev=1240279&r1=1240278&r2=1240279&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/TransformerMap.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/TransformerMap.java Fri Feb 3 18:17:21 2012
@@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.math.MathException;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
/**
* This TansformerMap automates the transformation of mixed object types.
@@ -134,10 +134,11 @@ public class TransformerMap implements N
*
* @param o the Object to be transformed.
* @return the double value of the Object.
- * @throws MathException if the Object can not be transformed into a Double.
+ * @throws MathIllegalArgumentException if the Object can not be
+ * transformed into a Double.
* @see org.apache.commons.math.util.NumberTransformer#transform(java.lang.Object)
*/
- public double transform(Object o) throws MathException {
+ public double transform(Object o) throws MathIllegalArgumentException {
double value = Double.NaN;
if (o instanceof Number || o instanceof String) {