You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2010/06/11 13:34:39 UTC
svn commit: r953668 [1/2] - in /commons/sandbox/commons-math_l10n/trunk: ./
src/main/java/org/apache/commons/math/
src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/analysis/interpolation/
src/main/java/o...
Author: erans
Date: Fri Jun 11 11:34:36 2010
New Revision: 953668
URL: http://svn.apache.org/viewvc?rev=953668&view=rev
Log:
Show-case of the proposal described in MATH-361.
Added:
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ArrayTooShortException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/CannotNormalizeException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativeException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativePowerOfIntegerException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NoDataException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotDecreasingException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotIncreasingException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyDecreasingException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyIncreasingException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ZeroOrNegativeException.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Cal10nAdapter.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Framework.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageBuilder.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageKey.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/resources/math_messages_en.properties (with props)
commons/sandbox/commons-math_l10n/trunk/src/main/resources/math_messages_fr.properties (with props)
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/l10n/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/l10n/ExceptionMessageTest.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/l10n/MessageKeyTest.java (with props)
commons/sandbox/commons-math_l10n/trunk/src/test/resources/math_messages_en.properties (with props)
commons/sandbox/commons-math_l10n/trunk/src/test/resources/math_messages_fr.properties (with props)
Removed:
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/integration/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/solvers/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/complex/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/distribution/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/estimation/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/fraction/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/genetics/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/geometry/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/linear/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/ode/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/optimization/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/random/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/special/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/stat/
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/transform/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/MathExceptionTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/TestUtils.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/integration/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/SplineInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtilsTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/solvers/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/complex/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/distribution/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/estimation/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/fraction/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/genetics/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/geometry/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/linear/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/ode/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/optimization/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/random/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/special/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/stat/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/transform/
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/BigRealFieldTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/BigRealTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/ContinuedFractionTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/DefaultTransformerTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/DoubleArrayAbstractTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/OpenIntToDoubleHashMapTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/OpenIntToFieldTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/ResizableDoubleArrayTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/TestBean.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/TransformerMapTest.java
Modified:
commons/sandbox/commons-math_l10n/trunk/pom.xml
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunction.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolator.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java
commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/FunctionEvaluationExceptionTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunctionTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatorTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunctionTest.java
commons/sandbox/commons-math_l10n/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java
Modified: commons/sandbox/commons-math_l10n/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/pom.xml?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/pom.xml (original)
+++ commons/sandbox/commons-math_l10n/trunk/pom.xml Fri Jun 11 11:34:36 2010
@@ -18,19 +18,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-parent</artifactId>
- <version>15</version>
+ <artifactId>commons-sandbox-parent</artifactId>
+ <version>9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-math</artifactId>
+ <artifactId>commons-math_l10n</artifactId>
<version>2.2-SNAPSHOT</version>
<name>Commons Math</name>
<inceptionYear>2003</inceptionYear>
<description>The Math project is a library of lightweight, self-contained mathematics and statistics components addressing the most common practical problems not immediately available in the Java programming language or commons-lang.</description>
- <url>http://commons.apache.org/math/</url>
+ <url>http://svn.apache.org/repos/asf/commons/sandbox/commons-math_l10n</url>
<issueManagement>
<system>jira</system>
@@ -38,9 +38,9 @@
</issueManagement>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/commons/proper/math/trunk</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/proper/math/trunk</developerConnection>
- <url>http://svn.apache.org/viewvc/commons/proper/math/trunk</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/commons/sandbox/commons-math_l10n/trunk</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/sandbox/commons-math_l10n/trunk</developerConnection>
+ <url>http://svn.apache.org/repos/asf/commons/sandbox/commons-math_l10n/trunk</url>
</scm>
<distributionManagement>
@@ -229,6 +229,11 @@
<version>4.4</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>ch.qos.cal10n</groupId>
+ <artifactId>cal10n-api</artifactId>
+ <version>0.7.2</version>
+ </dependency>
</dependencies>
<properties>
@@ -281,6 +286,11 @@
</executions>
</plugin>
</plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
</build>
<reporting>
<plugins>
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java Fri Jun 11 11:34:36 2010
@@ -16,8 +16,6 @@
*/
package org.apache.commons.math;
-import org.apache.commons.math.linear.ArrayRealVector;
-
/**
* Exception thrown when an error occurs evaluating a function.
* <p>
@@ -57,7 +55,7 @@ public class FunctionEvaluationException
* @since 2.0
*/
public FunctionEvaluationException(double[] argument) {
- super(FAILED_EVALUATION_MESSAGE, new ArrayRealVector(argument));
+ super(FAILED_EVALUATION_MESSAGE, argument);
this.argument = argument.clone();
}
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java Fri Jun 11 11:34:36 2010
@@ -17,9 +17,10 @@
package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.util.MathUtils;
-import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.FunctionEvaluationException;
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NoDataException;
+import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math.analysis.BivariateRealFunction;
/**
@@ -84,8 +85,8 @@ public class BicubicSplineInterpolatingF
* every grid point.
* @throws DimensionMismatchException if the various arrays do not contain
* the expected number of elements.
- * @throws IllegalArgumentException if {@code x} or {@code y} are not strictly
- * increasing.
+ * @throws NotStrictlyIncreasingException if {@code x} or {@code y} are
+ * not strictly increasing.
*/
public BicubicSplineInterpolatingFunction(double[] x,
double[] y,
@@ -98,7 +99,7 @@ public class BicubicSplineInterpolatingF
final int yLen = y.length;
if (xLen == 0 || yLen == 0 || f.length == 0 || f[0].length == 0) {
- throw MathRuntimeException.createIllegalArgumentException("no data");
+ throw new NoDataException();
}
if (xLen != f.length) {
throw new DimensionMismatchException(xLen, f.length);
@@ -157,13 +158,11 @@ public class BicubicSplineInterpolatingF
public double value(double x, double y) {
final int i = searchIndex(x, xval);
if (i == -1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- x, xval[0], xval[xval.length - 1]);
+ throw new OutOfRangeException(x, xval[0], xval[xval.length - 1]);
}
final int j = searchIndex(y, yval);
if (j == -1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- y, yval[0], yval[yval.length - 1]);
+ throw new OutOfRangeException(y, yval[0], yval[yval.length - 1]);
}
final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
@@ -230,13 +229,11 @@ public class BicubicSplineInterpolatingF
final int i = searchIndex(x, xval);
if (i == -1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- x, xval[0], xval[xval.length - 1]);
+ throw new OutOfRangeException(x, xval[0], xval[xval.length - 1]);
}
final int j = searchIndex(y, yval);
if (j == -1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- y, yval[0], yval[yval.length - 1]);
+ throw new OutOfRangeException(y, yval[0], yval[yval.length - 1]);
}
final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
@@ -373,12 +370,10 @@ class BicubicSplineFunction
*/
public double value(double x, double y) {
if (x < 0 || x > 1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- x, 0, 1);
+ throw new OutOfRangeException(x, 0, 1);
}
if (y < 0 || y > 1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- y, 0, 1);
+ throw new OutOfRangeException(y, 0, 1);
}
final double x2 = x * x;
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java Fri Jun 11 11:34:36 2010
@@ -16,8 +16,8 @@
*/
package org.apache.commons.math.analysis.interpolation;
-import org.apache.commons.math.DimensionMismatchException;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NoDataException;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.analysis.UnivariateRealFunction;
@@ -39,7 +39,7 @@ public class BicubicSplineInterpolator
final double[][] fval)
throws MathException, IllegalArgumentException {
if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
- throw MathRuntimeException.createIllegalArgumentException("no data");
+ throw new NoDataException();
}
if (xval.length != fval.length) {
throw new DimensionMismatchException(xval.length, fval.length);
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java Fri Jun 11 11:34:36 2010
@@ -16,7 +16,9 @@
*/
package org.apache.commons.math.analysis.interpolation;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NotStrictlyIncreasingException;
+import org.apache.commons.math.exception.ArrayTooShortException;
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
@@ -45,7 +47,6 @@ import org.apache.commons.math.analysis.
* </p>
*
* @version $Revision$ $Date$
- *
*/
public class SplineInterpolator implements UnivariateRealInterpolator {
@@ -57,13 +58,11 @@ public class SplineInterpolator implemen
*/
public PolynomialSplineFunction interpolate(double x[], double y[]) {
if (x.length != y.length) {
- throw MathRuntimeException.createIllegalArgumentException(
- "dimension mismatch {0} != {1}", x.length, y.length);
+ throw new DimensionMismatchException(x.length, y.length);
}
if (x.length < 3) {
- throw MathRuntimeException.createIllegalArgumentException(
- "{0} points are required, got only {1}", 3, x.length);
+ throw new ArrayTooShortException(3, x.length);
}
// Number of intervals. The number of data points is n + 1.
@@ -71,9 +70,7 @@ public class SplineInterpolator implemen
for (int i = 0; i < n; i++) {
if (x[i] >= x[i + 1]) {
- throw MathRuntimeException.createIllegalArgumentException(
- "points {0} and {1} are not strictly increasing ({2} >= {3})",
- i, i+1, x[i], x[i+1]);
+ throw new NotStrictlyIncreasingException(i, i+1, x[i], x[i+1]);
}
}
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunction.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunction.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunction.java Fri Jun 11 11:34:36 2010
@@ -17,8 +17,9 @@
package org.apache.commons.math.analysis.interpolation;
import org.apache.commons.math.util.MathUtils;
-import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NoDataException;
+import org.apache.commons.math.exception.OutOfRangeException;
import org.apache.commons.math.analysis.TrivariateRealFunction;
/**
@@ -135,8 +136,8 @@ public class TricubicSplineInterpolating
* every grid point.
* @throws DimensionMismatchException if the various arrays do not contain
* the expected number of elements.
- * @throws IllegalArgumentException if {@code x}, {@code y} or {@code z}
- * are not strictly increasing.
+ * @throws NotStrictlyIncreasingException if {@code x}, {@code y} or
+ * {@code z} are not strictly increasing.
*/
public TricubicSplineInterpolatingFunction(double[] x,
double[] y,
@@ -156,7 +157,7 @@ public class TricubicSplineInterpolating
if (xLen == 0 || yLen == 0 || z.length == 0
|| f.length == 0 || f[0].length == 0) {
- throw MathRuntimeException.createIllegalArgumentException("no data");
+ throw new NoDataException();
}
if (xLen != f.length) {
throw new DimensionMismatchException(xLen, f.length);
@@ -307,18 +308,15 @@ public class TricubicSplineInterpolating
public double value(double x, double y, double z) {
final int i = searchIndex(x, xval);
if (i == -1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- x, xval[0], xval[xval.length - 1]);
+ throw new OutOfRangeException(x, xval[0], xval[xval.length - 1]);
}
final int j = searchIndex(y, yval);
if (j == -1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- y, yval[0], yval[yval.length - 1]);
+ throw new OutOfRangeException(y, yval[0], yval[yval.length - 1]);
}
final int k = searchIndex(z, zval);
if (k == -1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- z, zval[0], zval[zval.length - 1]);
+ throw new OutOfRangeException(z, zval[0], zval[zval.length - 1]);
}
final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
@@ -449,16 +447,13 @@ class TricubicSplineFunction
*/
public double value(double x, double y, double z) {
if (x < 0 || x > 1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- x, 0, 1);
+ throw new OutOfRangeException(x, 0, 1);
}
if (y < 0 || y > 1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- y, 0, 1);
+ throw new OutOfRangeException(y, 0, 1);
}
if (z < 0 || z > 1) {
- throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
- z, 0, 1);
+ throw new OutOfRangeException(z, 0, 1);
}
final double x2 = x * x;
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolator.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolator.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolator.java Fri Jun 11 11:34:36 2010
@@ -16,7 +16,8 @@
*/
package org.apache.commons.math.analysis.interpolation;
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NoDataException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MathException;
import org.apache.commons.math.util.MathUtils;
@@ -40,7 +41,7 @@ public class TricubicSplineInterpolator
final double[][][] fval)
throws MathException, IllegalArgumentException {
if (xval.length == 0 || yval.length == 0 || zval.length == 0 || fval.length == 0) {
- throw MathRuntimeException.createIllegalArgumentException("no data");
+ throw new NoDataException();
}
if (xval.length != fval.length) {
throw new DimensionMismatchException(xval.length, fval.length);
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java Fri Jun 11 11:34:36 2010
@@ -19,7 +19,7 @@ package org.apache.commons.math.analysis
import java.io.Serializable;
import java.util.Arrays;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.ArrayTooShortException;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
@@ -32,11 +32,6 @@ import org.apache.commons.math.analysis.
* @version $Revision$ $Date$
*/
public class PolynomialFunction implements DifferentiableUnivariateRealFunction, Serializable {
-
- /** Message for empty coefficients array. */
- private static final String EMPTY_ARRAY_MESSAGE =
- "empty polynomials coefficients array";
-
/**
* Serialization identifier
*/
@@ -66,7 +61,7 @@ public class PolynomialFunction implemen
public PolynomialFunction(double c[]) {
super();
if (c.length < 1) {
- throw MathRuntimeException.createIllegalArgumentException(EMPTY_ARRAY_MESSAGE);
+ throw new ArrayTooShortException(1, c.length);
}
int l = c.length;
while ((l > 1) && (c[l - 1] == 0)) {
@@ -126,7 +121,7 @@ public class PolynomialFunction implemen
protected static double evaluate(double[] coefficients, double argument) {
int n = coefficients.length;
if (n < 1) {
- throw MathRuntimeException.createIllegalArgumentException(EMPTY_ARRAY_MESSAGE);
+ throw new ArrayTooShortException(1, n);
}
double result = coefficients[n - 1];
for (int j = n -2; j >=0; j--) {
@@ -235,7 +230,7 @@ public class PolynomialFunction implemen
protected static double[] differentiate(double[] coefficients) {
int n = coefficients.length;
if (n < 1) {
- throw MathRuntimeException.createIllegalArgumentException(EMPTY_ARRAY_MESSAGE);
+ throw new ArrayTooShortException(1, n);
}
if (n == 1) {
return new double[]{0};
Modified: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java?rev=953668&r1=953667&r2=953668&view=diff
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java (original)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java Fri Jun 11 11:34:36 2010
@@ -18,11 +18,16 @@ package org.apache.commons.math.analysis
import java.util.Arrays;
-import org.apache.commons.math.ArgumentOutsideDomainException;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.ArrayTooShortException;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NotStrictlyIncreasingException;
+import org.apache.commons.math.exception.OutOfRangeException;
+import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.FunctionEvaluationException;
+
/**
* Represents a polynomial spline function.
* <p>
@@ -96,19 +101,12 @@ public class PolynomialSplineFunction
*/
public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[]) {
if (knots.length < 2) {
- throw MathRuntimeException.createIllegalArgumentException(
- "spline partition must have at least {0} points, got {1}",
- 2, knots.length);
+ throw new ArrayTooShortException(2, knots.length);
}
if (knots.length - 1 != polynomials.length) {
- throw MathRuntimeException.createIllegalArgumentException(
- "number of polynomial interpolants must match the number of segments ({0} != {1} - 1)",
- polynomials.length, knots.length);
- }
- if (!isStrictlyIncreasing(knots)) {
- throw MathRuntimeException.createIllegalArgumentException(
- "knot values must be strictly increasing");
+ throw new DimensionMismatchException(polynomials.length, knots.length - 1);
}
+ MathUtils.checkOrder(knots, 1, true);
this.n = knots.length -1;
this.knots = new double[n + 1];
@@ -128,13 +126,13 @@ public class PolynomialSplineFunction
*
* @param v the point for which the function value should be computed
* @return the value
- * @throws ArgumentOutsideDomainException if v is outside of the domain of
+ * @throws OutOfRangeException if v is outside of the domain of
* of the spline function (less than the smallest knot point or greater
* than the largest knot point)
*/
- public double value(double v) throws ArgumentOutsideDomainException {
+ public double value(double v) throws FunctionEvaluationException {
if (v < knots[0] || v > knots[n]) {
- throw new ArgumentOutsideDomainException(v, knots[0], knots[n]);
+ throw new OutOfRangeException(v, knots[0], knots[n]);
}
int i = Arrays.binarySearch(knots, v);
if (i < 0) {
@@ -207,21 +205,4 @@ public class PolynomialSplineFunction
System.arraycopy(knots, 0, out, 0, n + 1);
return out;
}
-
- /**
- * Determines if the given array is ordered in a strictly increasing
- * fashion.
- *
- * @param x the array to examine.
- * @return <code>true</code> if the elements in <code>x</code> are ordered
- * in a stricly increasing manner. <code>false</code>, otherwise.
- */
- private static boolean isStrictlyIncreasing(double[] x) {
- for (int i = 1; i < x.length; ++i) {
- if (x[i - 1] >= x[i]) {
- return false;
- }
- }
- return true;
- }
}
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ArrayTooShortException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ArrayTooShortException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ArrayTooShortException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ArrayTooShortException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class ArrayTooShortException
+ extends MathIllegalArgumentException {
+
+ /** Value that caused the exception */
+ private int v;
+ /** Minimum required */
+ private int min;
+
+ public ArrayTooShortException(int v,
+ int min) {
+ super(MessageKey.ARRAY_TOO_SHORT, v, min);
+ this.v = v;
+ this.min = min;
+ }
+
+ public ArrayTooShortException(String info,
+ int v,
+ int min) {
+ super(info, MessageKey.ARRAY_TOO_SHORT, v, min);
+ this.v = v;
+ this.min = min;
+ }
+
+ /**
+ * @return the value that generated the exception.
+ */
+ public int getValue() {
+ return v;
+ }
+ /**
+ * @return the required minimum length.
+ */
+ public double getMin() {
+ return min;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ArrayTooShortException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/CannotNormalizeException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/CannotNormalizeException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/CannotNormalizeException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/CannotNormalizeException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class CannotNormalizeException
+ extends MathIllegalArgumentException {
+
+ /** Value that caused the exception */
+ private double v;
+
+ public CannotNormalizeException(double v) {
+ super(MessageKey.CANNOT_NORMALIZE, v);
+ this.v = v;
+ }
+
+ public CannotNormalizeException(String info,
+ double v) {
+ super(info, MessageKey.CANNOT_NORMALIZE, v);
+ this.v = v;
+ }
+
+ /**
+ * @return the value that generated the exception.
+ */
+ public double getValue() {
+ return v;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/CannotNormalizeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+/**
+ * Error thrown when two dimensions differ.
+ *
+ */
+public class DimensionMismatchException
+ extends MathIllegalArgumentException {
+ /** First dimension. */
+ private final int dimension1;
+
+ /** Second dimension. */
+ private final int dimension2;
+
+ /**
+ * Construct an exception from the mismatched dimensions.
+ *
+ * @param dimension1 first dimension
+ * @param dimension2 second dimension
+ */
+ public DimensionMismatchException(int dimension1,
+ int dimension2) {
+ super(MessageKey.DIMENSION_MISMATCH, dimension1, dimension2);
+ this.dimension1 = dimension1;
+ this.dimension2 = dimension2;
+ }
+
+ /**
+ * Construct an exception from the mismatched dimensions.
+ *
+ * @param info Contextual information.
+ * @param dimension1 first dimension
+ * @param dimension2 second dimension
+ */
+ public DimensionMismatchException(String info,
+ int dimension1,
+ int dimension2) {
+ super(info, MessageKey.DIMENSION_MISMATCH, dimension1, dimension2);
+ this.dimension1 = dimension1;
+ this.dimension2 = dimension2;
+ }
+
+ /**
+ * @return the first dimension.
+ */
+ public int getDimension1() {
+ return dimension1;
+ }
+
+ /**
+ * @return the second dimension.
+ */
+ public int getDimension2() {
+ return dimension2;
+ }
+
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,56 @@
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+import org.apache.commons.math.l10n.MessageBuilder;
+
+/**
+ * Base class for all CM exceptions having the semantics of
+ * {@code IllegalArgumentException}.
+ */
+public class MathIllegalArgumentException
+ extends IllegalArgumentException {
+ /**
+ * Exception arguments.
+ */
+ private final Object[] args;
+ /**
+ * Exception type.
+ */
+ private final MessageKey key;
+ /**
+ * Additional contextual information.
+ */
+ private final String info;
+
+ /**
+ * @param key Exception type.
+ * @param args Exception arguments.
+ */
+ protected MathIllegalArgumentException(MessageKey key,
+ Object ... args) {
+ this.key = key;
+ this.args = args;
+ this.info = null;
+ }
+
+ /**
+ * @param info Contextual information (e.g. the name of the variable
+ * that caused the error).
+ * @param key Exception type.
+ * @param args Exception arguments.
+ */
+ protected MathIllegalArgumentException(String info,
+ MessageKey key,
+ Object ... args) {
+ this.key = key;
+ this.args = args;
+ this.info = info;
+ }
+
+ /**
+ * @return a formatted message describing the exception.
+ */
+ public String getMessage() {
+ return MessageBuilder.getMessage(info, key, args);
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativeException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativeException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativeException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativeException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class NegativeException
+ extends MathIllegalArgumentException {
+
+ /** Value that caused the exception */
+ private double v;
+
+ public NegativeException(double v) {
+ super(MessageKey.NEGATIVE, v);
+ this.v = v;
+ }
+
+ public NegativeException(String info,
+ double v) {
+ super(info, MessageKey.NEGATIVE, v);
+ this.v = v;
+ }
+
+ /**
+ * @return the value that generated the exception.
+ */
+ public double getValue() {
+ return v;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativePowerOfIntegerException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativePowerOfIntegerException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativePowerOfIntegerException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativePowerOfIntegerException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import java.math.BigInteger;
+import org.apache.commons.math.l10n.MessageKey;
+
+/**
+ * Error thrown when attempting to raise an integer to a negative power.
+ */
+public class NegativePowerOfIntegerException
+ extends MathIllegalArgumentException {
+ /** Integer. */
+ private final Number integer;
+
+ /** Power. */
+ private final Number power;
+
+ /**
+ * @param integer Integer.
+ * @param power Power.
+ */
+ public NegativePowerOfIntegerException(int integer,
+ int power) {
+ super(MessageKey.NEGATIVE_POWER_OF_INTEGER, integer, power);
+ this.integer = new Integer(integer);
+ this.power = new Integer(power);
+ }
+ /**
+ * @param integer Integer.
+ * @param power Power.
+ */
+ public NegativePowerOfIntegerException(int integer,
+ long power) {
+ super(MessageKey.NEGATIVE_POWER_OF_INTEGER, integer, power);
+ this.integer = new Integer(integer);
+ this.power = new Long(power);
+ }
+ /**
+ * @param integer Integer.
+ * @param power Power.
+ */
+ public NegativePowerOfIntegerException(long integer,
+ int power) {
+ super(MessageKey.NEGATIVE_POWER_OF_INTEGER, integer, power);
+ this.integer = new Long(integer);
+ this.power = new Integer(power);
+ }
+ /**
+ * @param integer Integer.
+ * @param power Power.
+ */
+ public NegativePowerOfIntegerException(long integer,
+ long power) {
+ super(MessageKey.NEGATIVE_POWER_OF_INTEGER, integer, power);
+ this.integer = new Long(integer);
+ this.power = new Long(power);
+ }
+ /**
+ * @param integer Integer.
+ * @param power Power.
+ */
+ public NegativePowerOfIntegerException(BigInteger integer,
+ int power) {
+ super(MessageKey.NEGATIVE_POWER_OF_INTEGER, integer, power);
+ this.integer = integer;
+ this.power = new Integer(power);
+ }
+ /**
+ * @param integer Integer.
+ * @param power Power.
+ */
+ public NegativePowerOfIntegerException(BigInteger integer,
+ long power) {
+ super(MessageKey.NEGATIVE_POWER_OF_INTEGER, integer, power);
+ this.integer = integer;
+ this.power = new Long(power);
+ }
+ /**
+ * @param integer Integer.
+ * @param power Power.
+ */
+ public NegativePowerOfIntegerException(BigInteger integer,
+ BigInteger power) {
+ super(MessageKey.NEGATIVE_POWER_OF_INTEGER, integer, power);
+ this.integer = integer;
+ this.power = power;
+ }
+
+
+ /**
+ * @return the integer.
+ */
+ public Number getInteger() {
+ return integer;
+ }
+
+ /**
+ * @return the power.
+ */
+ public Number getPower() {
+ return power;
+ }
+
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NegativePowerOfIntegerException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NoDataException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NoDataException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NoDataException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NoDataException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class NoDataException
+ extends MathIllegalArgumentException {
+ public NoDataException() {
+ super(MessageKey.NO_DATA);
+ }
+
+ public NoDataException(String info) {
+ super(info, MessageKey.NO_DATA);
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NoDataException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotDecreasingException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotDecreasingException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotDecreasingException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotDecreasingException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class NotDecreasingException
+ extends MathIllegalArgumentException {
+
+ /** Index of the first point */
+ private int index1;
+ /** Index of the second point */
+ private int index2;
+ /** Value of the first point */
+ private double value1;
+ /** Value of the second point */
+ private double value2;
+
+ public NotDecreasingException(int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(MessageKey.NOT_DECREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ public NotDecreasingException(String info,
+ int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(info, MessageKey.NOT_DECREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ /**
+ * @return the index of the first point.
+ */
+ public int getIndex1() {
+ return index1;
+ }
+ /**
+ * @return the index of the second point.
+ */
+ public int getIndex2() {
+ return index2;
+ }
+ /**
+ * @return the value of the first point.
+ */
+ public double getValue1() {
+ return value1;
+ }
+ /**
+ * @return the value of the second point.
+ */
+ public double getValue2() {
+ return index2;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotDecreasingException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotIncreasingException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotIncreasingException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotIncreasingException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotIncreasingException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class NotIncreasingException
+ extends MathIllegalArgumentException {
+
+ /** Index of the first point */
+ private int index1;
+ /** Index of the second point */
+ private int index2;
+ /** Value of the first point */
+ private double value1;
+ /** Value of the second point */
+ private double value2;
+
+ public NotIncreasingException(int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(MessageKey.NOT_INCREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ public NotIncreasingException(String info,
+ int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(info, MessageKey.NOT_INCREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ /**
+ * @return the index of the first point.
+ */
+ public int getIndex1() {
+ return index1;
+ }
+ /**
+ * @return the index of the second point.
+ */
+ public int getIndex2() {
+ return index2;
+ }
+ /**
+ * @return the value of the first point.
+ */
+ public double getValue1() {
+ return value1;
+ }
+ /**
+ * @return the value of the second point.
+ */
+ public double getValue2() {
+ return index2;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotIncreasingException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyDecreasingException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyDecreasingException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyDecreasingException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyDecreasingException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class NotStrictlyDecreasingException
+ extends MathIllegalArgumentException {
+
+ /** Index of the first point */
+ private int index1;
+ /** Index of the second point */
+ private int index2;
+ /** Value of the first point */
+ private double value1;
+ /** Value of the second point */
+ private double value2;
+
+ public NotStrictlyDecreasingException(int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(MessageKey.NOT_STRICTLY_DECREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ public NotStrictlyDecreasingException(String info,
+ int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(info, MessageKey.NOT_STRICTLY_DECREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ /**
+ * @return the index of the first point.
+ */
+ public int getIndex1() {
+ return index1;
+ }
+ /**
+ * @return the index of the second point.
+ */
+ public int getIndex2() {
+ return index2;
+ }
+ /**
+ * @return the value of the first point.
+ */
+ public double getValue1() {
+ return value1;
+ }
+ /**
+ * @return the value of the second point.
+ */
+ public double getValue2() {
+ return index2;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyDecreasingException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyIncreasingException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyIncreasingException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyIncreasingException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyIncreasingException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class NotStrictlyIncreasingException
+ extends MathIllegalArgumentException {
+
+ /** Index of the first point */
+ private int index1;
+ /** Index of the second point */
+ private int index2;
+ /** Value of the first point */
+ private double value1;
+ /** Value of the second point */
+ private double value2;
+
+ public NotStrictlyIncreasingException(int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(MessageKey.NOT_STRICTLY_INCREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ public NotStrictlyIncreasingException(String info,
+ int index1,
+ int index2,
+ double value1,
+ double value2) {
+ super(info, MessageKey.NOT_STRICTLY_INCREASING, index1, index2, value1, value2);
+ this.index1 = index1;
+ this.index2 = index2;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ /**
+ * @return the index of the first point.
+ */
+ public int getIndex1() {
+ return index1;
+ }
+ /**
+ * @return the index of the second point.
+ */
+ public int getIndex2() {
+ return index2;
+ }
+ /**
+ * @return the value of the first point.
+ */
+ public double getValue1() {
+ return value1;
+ }
+ /**
+ * @return the value of the second point.
+ */
+ public double getValue2() {
+ return index2;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyIncreasingException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class OutOfRangeException
+ extends MathIllegalArgumentException {
+
+ /** Value that caused the exception */
+ private double v;
+ /** Lower bound */
+ private double lo;
+ /** Upper bound */
+ private double hi;
+
+ public OutOfRangeException(double v,
+ double lo,
+ double hi) {
+ super(MessageKey.OUT_OF_RANGE, v, lo, hi);
+ this.v = v;
+ this.lo = lo;
+ this.hi = hi;
+ }
+
+ public OutOfRangeException(String info,
+ double v,
+ double lo,
+ double hi) {
+ super(info, MessageKey.OUT_OF_RANGE, v, lo, hi);
+ this.v = v;
+ this.lo = lo;
+ this.hi = hi;
+ }
+
+ /**
+ * @return the value that generated the exception.
+ */
+ public double getValue() {
+ return v;
+ }
+ /**
+ * @return the lower bound of the allowed interval.
+ */
+ public double getLo() {
+ return lo;
+ }
+ /**
+ * @return the higher bound of the allowed interval.
+ */
+ public double getHi() {
+ return hi;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/OutOfRangeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ZeroOrNegativeException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ZeroOrNegativeException.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ZeroOrNegativeException.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ZeroOrNegativeException.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.l10n.MessageKey;
+
+public class ZeroOrNegativeException
+ extends MathIllegalArgumentException {
+
+ /** Value that caused the exception */
+ private double v;
+
+ public ZeroOrNegativeException(double v) {
+ super(MessageKey.ZERO_OR_NEGATIVE, v);
+ this.v = v;
+ }
+
+ public ZeroOrNegativeException(String info,
+ double v) {
+ super(info, MessageKey.ZERO_OR_NEGATIVE, v);
+ this.v = v;
+ }
+
+ /**
+ * @return the value that generated the exception.
+ */
+ public double getValue() {
+ return v;
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/exception/ZeroOrNegativeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Cal10nAdapter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Cal10nAdapter.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Cal10nAdapter.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Cal10nAdapter.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,17 @@
+package org.apache.commons.math.l10n;
+
+import java.util.Locale;
+import ch.qos.cal10n.MessageConveyor;
+
+/**
+ * Bridge to the "CAL10N" library.
+ */
+public class Cal10nAdapter implements Framework {
+ /**
+ * {@inheritDoc}
+ */
+ public <T extends Enum<?>> String getMessage(T key, Object[] args) {
+ final MessageConveyor mc = new MessageConveyor(Locale.getDefault());
+ return mc.getMessage(key, args);
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Cal10nAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Framework.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Framework.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Framework.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Framework.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,9 @@
+package org.apache.commons.math.l10n;
+
+public interface Framework {
+ /**
+ * @param e Exception.
+ * @return a message describing the problem.
+ */
+ public <T extends Enum<?>> String getMessage(T key, Object[] args);
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/Framework.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageBuilder.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageBuilder.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageBuilder.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,38 @@
+package org.apache.commons.math.l10n;
+
+/**
+ * Class for handling message localization.
+ */
+public class MessageBuilder {
+ /**
+ * Message formatting framework.
+ */
+ private static final Framework FRAMEWORK = new Cal10nAdapter();
+
+ /**
+ * Class contains only static methods.
+ */
+ private MessageBuilder() {}
+
+ /**
+ * @param info Contextual information (e.g. the name of the variable
+ * that caused the error).
+ * @param key Exception type.
+ * @param args Exception arguments.
+ * @return a formatted message describing the exception.
+ */
+ public static String getMessage(String info,
+ MessageKey key,
+ Object ... args) {
+ final StringBuilder m = new StringBuilder();
+
+ if (info != null) {
+ m.append(info);
+ m.append(": ");
+ }
+
+ m.append(FRAMEWORK.getMessage(key, args));
+
+ return m.toString();
+ }
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageKey.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageKey.java?rev=953668&view=auto
==============================================================================
--- commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageKey.java (added)
+++ commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageKey.java Fri Jun 11 11:34:36 2010
@@ -0,0 +1,27 @@
+package org.apache.commons.math.l10n;
+
+import ch.qos.cal10n.LocaleData;
+import ch.qos.cal10n.Locale;
+import ch.qos.cal10n.BaseName;
+
+/**
+ * All possible message types.
+ */
+@BaseName("math_messages")
+@LocaleData(defaultCharset = "UTF8",
+ value = { @Locale("en"),
+ @Locale("fr") })
+public enum MessageKey {
+ ZERO_OR_NEGATIVE,
+ NEGATIVE,
+ OUT_OF_RANGE,
+ DIMENSION_MISMATCH,
+ ARRAY_TOO_SHORT,
+ NOT_STRICTLY_INCREASING,
+ NOT_INCREASING,
+ NOT_STRICTLY_DECREASING,
+ NOT_DECREASING,
+ NEGATIVE_POWER_OF_INTEGER,
+ CANNOT_NORMALIZE,
+ NO_DATA,
+}
Propchange: commons/sandbox/commons-math_l10n/trunk/src/main/java/org/apache/commons/math/l10n/MessageKey.java
------------------------------------------------------------------------------
svn:eol-style = native