01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.parser;
12:
13: import antlr.Token;
14:
15: public class JavaParserException extends antlr.SemanticException {
16:
17: String cat;
18: String filename;
19: String jb;
20:
21: public JavaParserException(String cat, Token t, String filename,
22: int lineOffset, int colOffset) {
23: super ("JavaParser");
24: this .cat = cat;
25: this .jb = t.getText();
26: this .filename = filename;
27: this .line = (lineOffset >= 0) ? t.getLine() + lineOffset : 0;
28: this .column = (colOffset >= 0) ? t.getColumn() + colOffset : 0;
29: }
30:
31: public JavaParserException(String cat, Token t, String filename) {
32: super ("JavaParser");
33: this .cat = cat;
34: this .jb = t.getText();
35: this .filename = filename;
36: this .line = t.getLine();
37: this .column = t.getColumn();
38:
39: }
40:
41: public JavaParserException(String message) {
42: super (message);
43: }
44:
45: public String getFilename() {
46: return filename;
47: }
48:
49: public int getLine() {
50: return line;
51: }
52:
53: public int getColumn() {
54: return column;
55: }
56:
57: /**
58: * Returns a clean error message (no line number/column information)
59: */
60: public String getErrorMessage() {
61: return cat;
62: }
63:
64: /**
65: * Returns a clean error message (no line number/column information)
66: */
67: public String getMessage() {
68: return getErrorMessage();
69: }
70:
71: /**
72: * Returns a string representation of this exception.
73: */
74: public String toString() {
75: return filename + "(" + this .getLine() + ", "
76: + this .getColumn() + "): " + getErrorMessage();
77: }
78: }
|