|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ConsequenceException.java | - | 52.9% | 50% | 51.7% |
|
1 | package org.drools.spi; | |
2 | ||
3 | /* | |
4 | * $Id: ConsequenceException.java,v 1.6.2.1 2005/05/08 00:57:36 mproctor Exp $ | |
5 | * | |
6 | * Copyright 2001-2003 (C) The Werken Company. All Rights Reserved. | |
7 | * | |
8 | * Redistribution and use of this software and associated documentation | |
9 | * ("Software"), with or without modification, are permitted provided that the | |
10 | * following conditions are met: | |
11 | * | |
12 | * 1. Redistributions of source code must retain copyright statements and | |
13 | * notices. Redistributions must also contain a copy of this document. | |
14 | * | |
15 | * 2. Redistributions in binary form must reproduce the above copyright notice, | |
16 | * this list of conditions and the following disclaimer in the documentation | |
17 | * and/or other materials provided with the distribution. | |
18 | * | |
19 | * 3. The name "drools" must not be used to endorse or promote products derived | |
20 | * from this Software without prior written permission of The Werken Company. | |
21 | * For written permission, please contact bob@werken.com. | |
22 | * | |
23 | * 4. Products derived from this Software may not be called "drools" nor may | |
24 | * "drools" appear in their names without prior written permission of The Werken | |
25 | * Company. "drools" is a trademark of The Werken Company. | |
26 | * | |
27 | * 5. Due credit should be given to The Werken Company. (http://werken.com/) | |
28 | * | |
29 | * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' | |
30 | * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE | |
33 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
34 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
35 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
36 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
37 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
38 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
39 | * POSSIBILITY OF SUCH DAMAGE. | |
40 | * | |
41 | */ | |
42 | ||
43 | import org.drools.AssertionException; | |
44 | import org.drools.rule.Rule; | |
45 | ||
46 | /** | |
47 | * Indicates an error while applying a <code>Consequence<code>. | |
48 | * | |
49 | * @see Consequence | |
50 | * | |
51 | * @author <a href="mailto:bob@werken.com">bob mcwhirter</a> | |
52 | */ | |
53 | public class ConsequenceException extends AssertionException | |
54 | { | |
55 | private Rule rule; | |
56 | private String info; | |
57 | ||
58 | // ------------------------------------------------------------ | |
59 | // Constructors | |
60 | // ------------------------------------------------------------ | |
61 | ||
62 | /** | |
63 | * Construct. | |
64 | */ | |
65 | 1 | public ConsequenceException() |
66 | { | |
67 | // intentionally left blank | |
68 | } | |
69 | ||
70 | 0 | public ConsequenceException(String message) |
71 | { | |
72 | 0 | super( message ); |
73 | } | |
74 | ||
75 | /** | |
76 | * Construct with a root cause. | |
77 | * | |
78 | * @param rootCause | |
79 | * The root cause of this exception. | |
80 | */ | |
81 | 2 | public ConsequenceException(Throwable rootCause) |
82 | { | |
83 | 2 | super( rootCause ); |
84 | } | |
85 | ||
86 | 0 | public ConsequenceException(Rule rule) |
87 | { | |
88 | 0 | this.rule = rule; |
89 | } | |
90 | ||
91 | /** | |
92 | * Construct with a message. Keep this from old ConsequenceException | |
93 | * for backward compatability | |
94 | * | |
95 | * @param rootCause | |
96 | * The root cause of this exception. | |
97 | * | |
98 | * | |
99 | */ | |
100 | 1 | public ConsequenceException(String message, |
101 | Rule rule) | |
102 | { | |
103 | 1 | super( message ); |
104 | 1 | this.rule = rule; |
105 | } | |
106 | ||
107 | /** | |
108 | * Construct with a root cause. Keep this from old ConsequenceException | |
109 | * for backward compatability | |
110 | * | |
111 | * @param rootCause | |
112 | * The root cause of this exception. | |
113 | * | |
114 | * | |
115 | */ | |
116 | 2 | public ConsequenceException(Throwable rootCause, |
117 | Rule rule) | |
118 | { | |
119 | 2 | super( rootCause ); |
120 | 2 | this.rule = rule; |
121 | } | |
122 | ||
123 | 0 | public ConsequenceException(String message, |
124 | Rule rule, | |
125 | String info) | |
126 | { | |
127 | 0 | super( message ); |
128 | 0 | this.rule = rule; |
129 | 0 | this.info = info; |
130 | } | |
131 | ||
132 | /** | |
133 | * Construct with a root cause. | |
134 | * | |
135 | * @param rootCause | |
136 | * The root cause of this exception. | |
137 | */ | |
138 | 1 | public ConsequenceException(Throwable rootCause, |
139 | Rule rule, | |
140 | String info) | |
141 | { | |
142 | 1 | super( rootCause ); |
143 | 1 | this.rule = rule; |
144 | 1 | this.info = info; |
145 | } | |
146 | ||
147 | 0 | public void setRule(Rule rule) |
148 | { | |
149 | 0 | this.rule = rule; |
150 | } | |
151 | ||
152 | 3 | public Rule getRule() |
153 | { | |
154 | 3 | return this.rule; |
155 | } | |
156 | ||
157 | /** | |
158 | * Set arbitrary extra information about the condition. | |
159 | * | |
160 | * <p> | |
161 | * The info property may be used to communicate the actual block text or | |
162 | * other information in the case that Consequence does not have block text. | |
163 | * </p> | |
164 | */ | |
165 | 0 | public void setInfo(String info) |
166 | { | |
167 | 0 | this.info = info; |
168 | } | |
169 | ||
170 | 0 | public String getInfo() |
171 | { | |
172 | 0 | return this.info; |
173 | } | |
174 | } |
|