01: package org.drools.compiler;
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.commons.jci.problems.CompilationProblem;
20: import org.drools.lang.descr.BaseDescr;
21: import org.drools.rule.Package;
22:
23: public class FactTemplateError extends DroolsError {
24: private Package pkg;
25: private BaseDescr descr;
26: private Object object;
27: private String message;
28: private int[] line;
29:
30: public FactTemplateError(final Package pkg, final BaseDescr descr,
31: final Object object, final String message) {
32: super ();
33: this .pkg = pkg;
34: this .descr = descr;
35: this .object = object;
36: this .message = message;
37: this .line = new int[] { (this .descr != null) ? this .descr
38: .getLine() : -1 };
39: }
40:
41: public Package getPackage() {
42: return this .pkg;
43: }
44:
45: public BaseDescr getDescr() {
46: return this .descr;
47: }
48:
49: public Object getObject() {
50: return this .object;
51: }
52:
53: public int[] getErrorLines() {
54: return this .line;
55: }
56:
57: /**
58: * This will return the line number of the error, if possible
59: * Otherwise it will be -1
60: */
61: public int getLine() {
62: return this .line[0];
63: }
64:
65: public String getMessage() {
66: String summary = this .message;
67: if (this .object instanceof CompilationProblem[]) {
68: final CompilationProblem[] problem = (CompilationProblem[]) this .object;
69: for (int i = 0; i < problem.length; i++) {
70: summary = summary + " " + problem[i].getMessage();
71: }
72:
73: }
74: return summary;
75: }
76:
77: }
|