commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r990678 - in /commons/proper/math/trunk/src/main: java/org/apache/commons/math/exception/ java/org/apache/commons/math/exception/util/ resources/META-INF/localization/
Date Mon, 30 Aug 2010 00:50:50 GMT
Author: erans
Date: Mon Aug 30 00:50:49 2010
New Revision: 990678

URL: http://svn.apache.org/viewvc?rev=990678&view=rev
Log:
MATH-361 and MATH-195 (continued).
Added new exceptions.
Corrected some typos in Javadoc.

Added:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ConvergenceException.java
  (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
  (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
  (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/TooManyEvaluationsException.java
  (with props)
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooLargeException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooSmallException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java
    commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ConvergenceException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ConvergenceException.java?rev=990678&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ConvergenceException.java
(added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ConvergenceException.java
Mon Aug 30 00:50:49 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.exception.util.Localizable;
+import org.apache.commons.math.exception.util.LocalizedFormats;
+
+/**
+ * Error thrown when a numerical computation can not be performed because the
+ * numerical result failed to converge to a finite value.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class ConvergenceException extends MathIllegalStateException {
+    /** Serializable version Id. */
+    private static final long serialVersionUID = 4330003017885151975L;
+
+    /**
+     * Construct the exception.
+     */
+    public ConvergenceException() {
+        this(null);
+    }
+    /**
+     * Construct the exception with a specific context.
+     *
+     * @param specific Specific contexte pattern.
+     */
+    public ConvergenceException(Localizable specific) {
+        this(specific,
+             LocalizedFormats.CONVERGENCE_FAILED,
+             null);
+    }
+    /**
+     * Construct the exception with a specific context and arguments.
+     *
+     * @param specific Specific contexte pattern.
+     * @param args Arguments.
+     */
+    public ConvergenceException(Localizable specific,
+                                Object ... args) {
+        super(specific,
+              LocalizedFormats.CONVERGENCE_FAILED,
+              args);
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ConvergenceException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java?rev=990678&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
(added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
Mon Aug 30 00:50:49 2010
@@ -0,0 +1,94 @@
+/*
+ * 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.util.Locale;
+
+import org.apache.commons.math.exception.util.ArgUtils;
+import org.apache.commons.math.exception.util.MessageFactory;
+import org.apache.commons.math.exception.util.Localizable;
+
+/**
+ * Base class for all exceptions that signal a mismatch between the
+ * current state and the user's expectations.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class MathIllegalStateException extends IllegalStateException {
+
+    /** Serializable version Id. */
+    private static final long serialVersionUID = -6024911025449780478L;
+
+    /**
+     * Pattern used to build the message (specific context).
+     */
+    private final Localizable specific;
+    /**
+     * Pattern used to build the message (general problem description).
+     */
+    private final Localizable general;
+    /**
+     * Arguments used to build the message.
+     */
+    private final Object[] arguments;
+
+    /**
+     * @param specific Message pattern providing the specific context of
+     * the error.
+     * @param general Message pattern explaining the cause of the error.
+     * @param args Arguments.
+     */
+    public MathIllegalStateException(Localizable specific,
+                                     Localizable general,
+                                     Object ... args) {
+        this.specific = specific;
+        this.general = general;
+        arguments = ArgUtils.flatten(args);
+    }
+    /**
+     * @param general Message pattern explaining the cause of the error.
+     * @param args Arguments.
+     */
+    public MathIllegalStateException(Localizable general,
+                                     Object ... args) {
+        this(null, general, args);
+    }
+
+    /**
+     * Get the message in a specified locale.
+     *
+     * @param locale Locale in which the message should be translated.
+     *
+     * @return the localized message.
+     */
+    public String getMessage(final Locale locale) {
+        return MessageFactory.buildMessage(locale, specific, general, arguments);
+    }
+
+   /** {@inheritDoc} */
+    @Override
+    public String getMessage() {
+        return getMessage(Locale.US);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getLocalizedMessage() {
+        return getMessage(Locale.getDefault());
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java?rev=990678&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
(added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
Mon Aug 30 00:50:49 2010
@@ -0,0 +1,66 @@
+/*
+ * 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.exception.util.Localizable;
+import org.apache.commons.math.exception.util.LocalizedFormats;
+
+/**
+ * Exception to be thrown when some counter maximum value is exceeded.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class MaxCountExceededException extends MathIllegalStateException {
+    /** Serializable version Id. */
+    private static final long serialVersionUID = 4330003017885151975L;
+
+    /**
+     * Maximum number of evaluations.
+     */
+    private final Number max;
+
+    /**
+     * Construct the exception.
+     *
+     * @param max Maximum.
+     */
+    public MaxCountExceededException(Number max) {
+        this(null, max);
+    }
+    /**
+     * Construct the exception with a specific context.
+     *
+     * @param specific Specific contexte pattern.
+     * @param max Maximum.
+     */
+    public MaxCountExceededException(Localizable specific,
+                                     Number max) {
+        super(specific,
+              LocalizedFormats.MAX_COUNT_EXCEEDED,
+              max);
+
+        this.max = max;
+    }
+
+    /**
+     * @return the maximum number of evaluations.
+     */
+    public Number getMax() {
+        return max;
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooLargeException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooLargeException.java?rev=990678&r1=990677&r2=990678&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooLargeException.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooLargeException.java
Mon Aug 30 00:50:49 2010
@@ -43,7 +43,7 @@ public class NumberIsTooLargeException e
      * Construct the exception.
      *
      * @param wrong Value that is larger than the maximum.
-     * @param max maximum.
+     * @param max Maximum.
      * @param boundIsAllowed if true the maximum is included in the allowed range.
      */
     public NumberIsTooLargeException(Number wrong,
@@ -54,9 +54,9 @@ public class NumberIsTooLargeException e
     /**
      * Construct the exception with a specific context.
      *
-     * @param specific Specific contexte pattern .
+     * @param specific Specific contexte pattern.
      * @param wrong Value that is larger than the maximum.
-     * @param max maximum.
+     * @param max Maximum.
      * @param boundIsAllowed if true the maximum is included in the allowed range.
      */
     public NumberIsTooLargeException(Localizable specific,
@@ -75,14 +75,14 @@ public class NumberIsTooLargeException e
 
     /**
      * @return {@code true} if the maximum is included in the allowed range.
-     **/
+     */
     public boolean getBoundIsAllowed() {
         return boundIsAllowed;
     }
 
     /**
      * @return the maximum.
-     **/
+     */
     public Number getMax() {
         return max;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooSmallException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooSmallException.java?rev=990678&r1=990677&r2=990678&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooSmallException.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooSmallException.java
Mon Aug 30 00:50:49 2010
@@ -43,7 +43,7 @@ public class NumberIsTooSmallException e
      * Construct the exception.
      *
      * @param wrong Value that is smaller than the minimum.
-     * @param min minimum.
+     * @param min Minimum.
      * @param boundIsAllowed Whether {@code min} is included in the allowed range.
      */
     public NumberIsTooSmallException(Number wrong,
@@ -55,9 +55,9 @@ public class NumberIsTooSmallException e
     /**
      * Construct the exception with a specific context.
      *
-     * @param specific Specific contexte pattern .
+     * @param specific Specific contexte pattern.
      * @param wrong Value that is smaller than the minimum.
-     * @param min minimum.
+     * @param min Minimum.
      * @param boundIsAllowed Whether {@code min} is included in the allowed range.
      */
     public NumberIsTooSmallException(Localizable specific,
@@ -76,14 +76,14 @@ public class NumberIsTooSmallException e
 
     /**
      * @return {@code true} if the minimum is included in the allowed range.
-     **/
+     */
     public boolean getBoundIsAllowed() {
         return boundIsAllowed;
     }
 
     /**
      * @return the minimum.
-     **/
+     */
     public Number getMin() {
         return min;
     }

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/TooManyEvaluationsException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/TooManyEvaluationsException.java?rev=990678&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/TooManyEvaluationsException.java
(added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/TooManyEvaluationsException.java
Mon Aug 30 00:50:49 2010
@@ -0,0 +1,39 @@
+/*
+ * 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.exception.util.LocalizedFormats;
+
+/**
+ * Exception to be thrown when the maximal number of evaluations is exceeded.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class TooManyEvaluationsException extends MaxCountExceededException {
+    /** Serializable version Id. */
+    private static final long serialVersionUID = 4330003017885151975L;
+
+    /**
+     * Construct the exception.
+     *
+     * @param max Maximum number of evaluations.
+     */
+    public TooManyEvaluationsException(Number max) {
+        super(LocalizedFormats.EVALUATIONS, max);
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/TooManyEvaluationsException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java?rev=990678&r1=990677&r2=990678&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
Mon Aug 30 00:50:49 2010
@@ -40,7 +40,7 @@ public class ZeroException extends MathI
     /**
      * Construct the exception with a specific context.
      *
-     * @param specific Specific contexte pattern .
+     * @param specific Specific context pattern.
      */
     public ZeroException(Localizable specific) {
         super(specific, LocalizedFormats.ZERO_NOT_ALLOWED, 0);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java?rev=990678&r1=990677&r2=990678&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java
Mon Aug 30 00:50:49 2010
@@ -75,7 +75,7 @@ public enum LocalizedFormats implements 
     CONTINUED_FRACTION_NAN_DIVERGENCE("Continued fraction diverged to NaN for value {0}"),
     CONTRACTION_CRITERIA_SMALLER_THAN_EXPANSION_FACTOR("contraction criteria ({0}) smaller
than the expansion factor ({1}).  This would lead to a never ending loop of expansion and
contraction as a newly expanded internal storage array would immediately satisfy the criteria
for contraction."),
     CONTRACTION_CRITERIA_SMALLER_THAN_ONE("contraction criteria smaller than one ({0}). 
This would lead to a never ending loop of expansion and contraction as an internal storage
array length equal to the number of elements would satisfy the contraction criteria."),
-    CONVERGENCE_FAILED("convergence failed"),
+    CONVERGENCE_FAILED("convergence failed"), /* keep */
     CUMULATIVE_PROBABILITY_RETURNED_NAN("Cumulative probability function returned NaN for
argument {0} p = {1}"),
     DIFFERENT_ROWS_LENGTHS("some rows have length {0} while others have length {1}"),
     DIGEST_NOT_INITIALIZED("digest not initialized"),
@@ -135,6 +135,8 @@ public enum LocalizedFormats implements 
     LOWER_BOUND_NOT_BELOW_UPPER_BOUND("lower bound ({0}) must be strictly less than upper
bound ({1})"), /* keep */
     LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT("lower endpoint ({0}) must be less than or equal
to upper endpoint ({1})"),
     MAP_MODIFIED_WHILE_ITERATING("map has been modified while iterating"),
+    EVALUATIONS("evaluations"), /* keep */
+    MAX_COUNT_EXCEEDED("maximal count ({0}) exceeded"), /* keep */
     MAX_EVALUATIONS_EXCEEDED("maximal number of evaluations ({0}) exceeded"),
     MAX_ITERATIONS_EXCEEDED("maximal number of iterations ({0}) exceeded"),
     MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION("minimal step size ({0,number,0.00E00}) reached,
integration needs {1,number,0.00E00}"),
@@ -202,12 +204,12 @@ public enum LocalizedFormats implements 
     NOT_SUBTRACTION_COMPATIBLE_MATRICES("{0}x{1} and {2}x{3} matrices are not subtraction
compatible"),
     NOT_SYMMETRIC_MATRIX("not symmetric matrix"),
     NO_BIN_SELECTED("no bin selected"),
-    NO_CONVERGENCE_WITH_ANY_START_POINT("none of the {0} start points lead to convergence"),
+    NO_CONVERGENCE_WITH_ANY_START_POINT("none of the {0} start points lead to convergence"),
/* keep */
     NO_DATA("no data"), /* keep */
     NO_DEGREES_OF_FREEDOM("no degrees of freedom ({0} measurements, {1} parameters)"),
     NO_DENSITY_FOR_THIS_DISTRIBUTION("This distribution does not have a density function
implemented"),
     NO_FEASIBLE_SOLUTION("no feasible solution"),
-    NO_OPTIMUM_COMPUTED_YET("no optimum computed yet"),
+    NO_OPTIMUM_COMPUTED_YET("no optimum computed yet"), /* keep */
     NO_RESULT_AVAILABLE("no result available"),
     NO_SUCH_MATRIX_ENTRY("no entry at indices ({0}, {1}) in a {2}x{3} matrix"),
     NULL_NOT_ALLOWED("null is not allowed"), /* keep */

Modified: commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties?rev=990678&r1=990677&r2=990678&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties
(original)
+++ commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties
Mon Aug 30 00:50:49 2010
@@ -107,6 +107,8 @@ LOESS_EXPECTS_AT_LEAST_ONE_POINT = la r\
 LOWER_BOUND_NOT_BELOW_UPPER_BOUND = la borne inf\u00e9rieure ({0}) doit \u00eatre strictement
plus petite que la borne sup\u00e9rieure ({1})
 LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT = la borne inf\u00e9rieure ({0}) devrait \u00eatre inf\u00e9rieure

 MAP_MODIFIED_WHILE_ITERATING = la table d''adressage a \u00e9t\u00e9 modifi\u00e9e pendant
l''it\u00e9ration
+EVALUATIONS = \u00e9valuations
+MAX_COUNT_EXCEEDED = limite ({0}) d\u00e9pass\u00e9
 MAX_EVALUATIONS_EXCEEDED = nombre maximal d''\u00e9valuations ({0}) d\u00e9pass\u00e9
 MAX_ITERATIONS_EXCEEDED = nombre maximal d''it\u00e9rations ({0}) d\u00e9pass\u00e9
 MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION = pas minimal ({0,number,0.00E00}) atteint, l''int\u00e9gration
n\u00e9cessite {1,number,0.00E00}



Mime
View raw message