KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > math > FunctionEvaluationException


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.math;
17
18 /**
19  * Exeption thrown when an error occurs evaluating a function.
20  * <p>
21  * Maintains an <code>argument</code> property holding the input value that
22  * caused the function evaluation to fail.
23  *
24  * @version $Revision$ $Date: 2005-02-26 05:11:52 -0800 (Sat, 26 Feb 2005) $
25  */

26 public class FunctionEvaluationException extends MathException {
27     
28     /** Serializable version identifier */
29     static final long serialVersionUID = -317289374378977972L;
30     
31     /** Argument causing function evaluation failure */
32     private double argument = Double.NaN;
33     
34     /**
35      * Construct an exception indicating the argument value
36      * that caused the function evaluation to fail. Generates an exception
37      * message of the form "Evaluation failed for argument = " + argument.
38      *
39      * @param argument the failing function argument
40      */

41     public FunctionEvaluationException(double argument) {
42         this(argument, "Evaluation failed for argument = " + argument);
43     }
44     
45     /**
46      * Construct an exception using the given argument and message
47      * text. The message text of the exception will start with
48      * <code>message</code> and be followed by
49      * " Evaluation failed for argument = " + argument.
50      *
51      * @param argument the failing function argument
52      * @param message the exception message text
53      */

54     public FunctionEvaluationException(double argument, String JavaDoc message) {
55         this(argument, message, null);
56     }
57
58     /**
59      * Construct an exception with the given argument, message and root cause.
60      * The message text of the exception will start with <code>message</code>
61      * and be followed by " Evaluation failed for argument = " + argument.
62      *
63      * @param argument the failing function argument
64      * @param message descriptive error message
65      * @param cause root cause.
66      */

67     public FunctionEvaluationException(double argument, String JavaDoc message,
68             Throwable JavaDoc cause) {
69         super(message + " Evaluation failed for argument=" + argument, cause);
70         this.argument = argument;
71     }
72     
73     /**
74      * Returns the function argument that caused this exception.
75      *
76      * @return argument that caused function evaluation to fail
77      */

78     public double getArgument() {
79         return this.argument;
80     }
81 }
82
Popular Tags