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.math3.exception;
18
19 import org.apache.commons.math3.exception.util.Localizable;
20 import org.apache.commons.math3.exception.util.LocalizedFormats;
21
22 /**
23 * Exception to be thrown when function values have the same sign at both
24 * ends of an interval.
25 *
26 * @since 3.0
27 * @version $Id: NoBracketingException.java 1364378 2012-07-22 17:42:38Z tn $
28 */
29 public class NoBracketingException extends MathIllegalArgumentException {
30 /** Serializable version Id. */
31 private static final long serialVersionUID = -3629324471511904459L;
32 /** Lower end of the interval. */
33 private final double lo;
34 /** Higher end of the interval. */
35 private final double hi;
36 /** Value at lower end of the interval. */
37 private final double fLo;
38 /** Value at higher end of the interval. */
39 private final double fHi;
40
41 /**
42 * Construct the exception.
43 *
44 * @param lo Lower end of the interval.
45 * @param hi Higher end of the interval.
46 * @param fLo Value at lower end of the interval.
47 * @param fHi Value at higher end of the interval.
48 */
49 public NoBracketingException(double lo, double hi,
50 double fLo, double fHi) {
51 this(LocalizedFormats.SAME_SIGN_AT_ENDPOINTS, lo, hi, fLo, fHi);
52 }
53
54 /**
55 * Construct the exception with a specific context.
56 *
57 * @param specific Contextual information on what caused the exception.
58 * @param lo Lower end of the interval.
59 * @param hi Higher end of the interval.
60 * @param fLo Value at lower end of the interval.
61 * @param fHi Value at higher end of the interval.
62 * @param args Additional arguments.
63 */
64 public NoBracketingException(Localizable specific,
65 double lo, double hi,
66 double fLo, double fHi,
67 Object ... args) {
68 super(specific, lo, hi, fLo, fHi, args);
69 this.lo = lo;
70 this.hi = hi;
71 this.fLo = fLo;
72 this.fHi = fHi;
73 }
74
75 /**
76 * Get the lower end of the interval.
77 *
78 * @return the lower end.
79 */
80 public double getLo() {
81 return lo;
82 }
83 /**
84 * Get the higher end of the interval.
85 *
86 * @return the higher end.
87 */
88 public double getHi() {
89 return hi;
90 }
91 /**
92 * Get the value at the lower end of the interval.
93 *
94 * @return the value at the lower end.
95 */
96 public double getFLo() {
97 return fLo;
98 }
99 /**
100 * Get the value at the higher end of the interval.
101 *
102 * @return the value at the higher end.
103 */
104 public double getFHi() {
105 return fHi;
106 }
107 }