MATH-361 and MATH-195 (continued).
Added new exceptions. Corrected some typos in Javadoc. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@990678 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ec92a0fc2
commit
79c6cb129d
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ public class NumberIsTooLargeException extends MathIllegalNumberException {
|
|||
* 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 extends MathIllegalNumberException {
|
|||
/**
|
||||
* 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 extends MathIllegalNumberException {
|
|||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class NumberIsTooSmallException extends MathIllegalNumberException {
|
|||
* 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 extends MathIllegalNumberException {
|
|||
/**
|
||||
* 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 extends MathIllegalNumberException {
|
|||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ public class ZeroException extends MathIllegalNumberException {
|
|||
/**
|
||||
* 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);
|
||||
|
|
|
@ -75,7 +75,7 @@ public enum LocalizedFormats implements Localizable {
|
|||
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 Localizable {
|
|||
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 Localizable {
|
|||
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 */
|
||||
|
|
|
@ -107,6 +107,8 @@ LOESS_EXPECTS_AT_LEAST_ONE_POINT = la r\u00e9gression Loess n\u00e9cessite au mo
|
|||
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}
|
||||
|
|
Loading…
Reference in New Issue