~ubuntu-branches/ubuntu/maverick/commons-math/maverick

« back to all changes in this revision

Viewing changes to src/main/java/org/apache/commons/math/FunctionEvaluationException.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-08-22 01:13:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090822011325-hi4peq1ua5weguwn
Tags: 2.0-1
* New upstream release.
* Set Maintainer field to Debian Java Team
* Add myself as Uploaders
* Switch to Quilt patch system:
  - Refresh all patchs
  - Remove B-D on dpatch, Add B-D on quilt
  - Include patchsys-quilt.mk in debian/rules
* Bump Standards-Version to 3.8.3:
  - Add a README.source to describe patch system
* Maven POMs:
  - Add a Build-Depends-Indep dependency on maven-repo-helper
  - Use mh_installpom and mh_installjar to install the POM and the jar to the
    Maven repository
* Use default-jdk/jre:
  - Depends on java5-runtime-headless
  - Build-Depends on default-jdk
  - Use /usr/lib/jvm/default-java as JAVA_HOME
* Move api documentation to /usr/share/doc/libcommons-math-java/api
* Build-Depends on junit4 instead of junit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 *
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
package org.apache.commons.math;
 
18
 
 
19
import org.apache.commons.math.linear.ArrayRealVector;
 
20
 
 
21
/**
 
22
 * Exception thrown when an error occurs evaluating a function.
 
23
 * <p>
 
24
 * Maintains an <code>argument</code> property holding the input value that
 
25
 * caused the function evaluation to fail.
 
26
 * 
 
27
 * @version $Revision: 783702 $ $Date: 2009-06-11 04:54:02 -0400 (Thu, 11 Jun 2009) $
 
28
 */
 
29
public class FunctionEvaluationException extends MathException  {
 
30
    
 
31
    /** Serializable version identifier. */
 
32
    private static final long serialVersionUID = -4305020489115478365L;
 
33
 
 
34
    /** Argument causing function evaluation failure */
 
35
    private double[] argument;
 
36
    
 
37
    /**
 
38
     * Construct an exception indicating the argument value
 
39
     * that caused the function evaluation to fail.
 
40
     * 
 
41
     * @param argument  the failing function argument 
 
42
     */
 
43
    public FunctionEvaluationException(double argument) {
 
44
        super("evaluation failed for argument = {0}", argument);
 
45
        this.argument = new double[] { argument };
 
46
    }
 
47
    
 
48
    /**
 
49
     * Construct an exception indicating the argument value
 
50
     * that caused the function evaluation to fail.
 
51
     * 
 
52
     * @param argument  the failing function argument 
 
53
     * @since 2.0
 
54
     */
 
55
    public FunctionEvaluationException(double[] argument) {
 
56
        super("evaluation failed for argument = {0}", new ArrayRealVector(argument));
 
57
        this.argument = argument.clone();
 
58
    }
 
59
    
 
60
    /**
 
61
     * Constructs an exception with specified formatted detail message.
 
62
     * Message formatting is delegated to {@link java.text.MessageFormat}.
 
63
     * @param argument  the failing function argument 
 
64
     * @param pattern format specifier
 
65
     * @param arguments format arguments
 
66
     * @since 1.2
 
67
     */
 
68
    public FunctionEvaluationException(double argument,
 
69
                                       String pattern, Object ... arguments) {
 
70
        super(pattern, arguments);
 
71
        this.argument = new double[] { argument };
 
72
    }
 
73
 
 
74
    /**
 
75
     * Constructs an exception with specified formatted detail message.
 
76
     * Message formatting is delegated to {@link java.text.MessageFormat}.
 
77
     * @param argument  the failing function argument 
 
78
     * @param pattern format specifier
 
79
     * @param arguments format arguments
 
80
     * @since 2.0
 
81
     */
 
82
    public FunctionEvaluationException(double[] argument,
 
83
                                       String pattern, Object ... arguments) {
 
84
        super(pattern, arguments);
 
85
        this.argument = argument.clone();
 
86
    }
 
87
 
 
88
    /**
 
89
     * Constructs an exception with specified root cause.
 
90
     * Message formatting is delegated to {@link java.text.MessageFormat}.
 
91
     * @param cause  the exception or error that caused this exception to be thrown
 
92
     * @param argument  the failing function argument 
 
93
     * @since 1.2
 
94
     */
 
95
    public FunctionEvaluationException(Throwable cause, double argument) {
 
96
        super(cause);
 
97
        this.argument = new double[] { argument };
 
98
    }
 
99
 
 
100
    /**
 
101
     * Constructs an exception with specified root cause.
 
102
     * Message formatting is delegated to {@link java.text.MessageFormat}.
 
103
     * @param cause  the exception or error that caused this exception to be thrown
 
104
     * @param argument  the failing function argument 
 
105
     * @since 2.0
 
106
     */
 
107
    public FunctionEvaluationException(Throwable cause, double[] argument) {
 
108
        super(cause);
 
109
        this.argument = argument.clone();
 
110
    }
 
111
 
 
112
    /**
 
113
     * Constructs an exception with specified formatted detail message and root cause.
 
114
     * Message formatting is delegated to {@link java.text.MessageFormat}.
 
115
     * @param cause  the exception or error that caused this exception to be thrown
 
116
     * @param argument  the failing function argument 
 
117
     * @param pattern format specifier
 
118
     * @param arguments format arguments
 
119
     * @since 1.2
 
120
     */
 
121
    public FunctionEvaluationException(Throwable cause,
 
122
                                       double argument, String pattern,
 
123
                                       Object ... arguments) {
 
124
        super(cause, pattern, arguments);
 
125
        this.argument = new double[] { argument };
 
126
    }
 
127
 
 
128
    /**
 
129
     * Constructs an exception with specified formatted detail message and root cause.
 
130
     * Message formatting is delegated to {@link java.text.MessageFormat}.
 
131
     * @param cause  the exception or error that caused this exception to be thrown
 
132
     * @param argument  the failing function argument 
 
133
     * @param pattern format specifier
 
134
     * @param arguments format arguments
 
135
     * @since 2.0
 
136
     */
 
137
    public FunctionEvaluationException(Throwable cause,
 
138
                                       double[] argument, String pattern,
 
139
                                       Object ... arguments) {
 
140
        super(cause, pattern, arguments);
 
141
        this.argument = argument.clone();
 
142
    }
 
143
 
 
144
    /**
 
145
     * Returns the function argument that caused this exception.
 
146
     * 
 
147
     * @return  argument that caused function evaluation to fail
 
148
     */
 
149
    public double[] getArgument() {
 
150
        return argument.clone();
 
151
    }
 
152
 
 
153
}