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 FieldTemplateError 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 FieldTemplateError(final Package pkg, final BaseDescr descr,
31: final Object object, final String message) {
32: this .pkg = pkg;
33: this .descr = descr;
34: this .object = object;
35: this .message = message;
36: this .line = new int[] { (this .descr != null) ? this .descr
37: .getLine() : -1 };
38: }
39:
40: public Package getPackage() {
41: return this .pkg;
42: }
43:
44: public BaseDescr getDescr() {
45: return this .descr;
46: }
47:
48: public Object getObject() {
49: return this .object;
50: }
51:
52: public int[] getErrorLines() {
53: return this .line;
54: }
55:
56: /**
57: * This will return the line number of the error, if possible
58: * Otherwise it will be -1
59: */
60: public int getLine() {
61: return this .line[0];
62: }
63:
64: public String getMessage() {
65: String summary = this .message;
66: if (this .object instanceof CompilationProblem[]) {
67: final CompilationProblem[] problem = (CompilationProblem[]) this .object;
68: for (int i = 0; i < problem.length; i++) {
69: summary = summary + " " + problem[i].getMessage();
70: }
71:
72: }
73: return summary;
74: }
75:
76: }
|