01: package org.drools;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.drools.rule.Package;
20:
21: /**
22: * Indicates an error integrating a <code>Package</code> into a
23: * <code>RuleBase</code>.
24: *
25: * @see RuleBase#addRule
26: * @see RuleBase#addPackage
27: *
28: */
29: public class PackageIntegrationException extends IntegrationException {
30: /**
31: *
32: */
33: private static final long serialVersionUID = 400L;
34: /** The rule. */
35: private final Package pkg;
36:
37: /**
38: * @see java.lang.Exception#Exception()
39: *
40: * @param pkg
41: * The offending rule.
42: */
43: public PackageIntegrationException(final String message,
44: final Package pkg) {
45: super (message);
46: this .pkg = pkg;
47: }
48:
49: /**
50: * @see java.lang.Exception#Exception()
51: *
52: * @param pkg
53: * The offending rule.
54: */
55: public PackageIntegrationException(final Package pkg) {
56: super (createMessage(pkg));
57: this .pkg = pkg;
58: }
59:
60: /**
61: * @see java.lang.Exception#Exception(Throwable cause)
62: *
63: * @param pkg
64: * The offending rule.
65: */
66: public PackageIntegrationException(final Package pkg,
67: final Throwable cause) {
68: super (createMessage(pkg), cause);
69: this .pkg = pkg;
70: }
71:
72: /**
73: * Retrieve the <code>Package</code>.
74: *
75: * @return The pkg
76: */
77: public Package getPackage() {
78: return this .pkg;
79: }
80:
81: private static String createMessage(final Package pkg) {
82: return pkg.getName() + " cannot be integrated";
83: }
84: }
|