01: package gnu.text;
02:
03: /** Represents an error message from processing a "source" file. */
04:
05: public class SourceError {
06: public SourceError next;
07:
08: /** The seriousness of the error - one of 'w' (for warning),
09: * 'e' (for error), or 'f' (for fatal error). */
10: public char severity;
11:
12: public String filename;
13:
14: /** The (1-origin) location of the error. */
15: public int line;
16: public int column;
17:
18: public String message;
19:
20: public SourceError(char severity, String filename, int line,
21: int column, String message) {
22: this .severity = severity;
23: this .filename = filename;
24: this .line = line;
25: this .column = column;
26: this .message = message;
27: }
28:
29: public SourceError(LineBufferedReader port, char severity,
30: String message) {
31: this (severity, port.getName(), port.getLineNumber() + 1, port
32: .getColumnNumber(), message);
33: if (column >= 0)
34: column++;
35: }
36:
37: public String toString() {
38: StringBuffer buffer = new StringBuffer();
39: buffer.append(filename == null ? "<unknown>" : filename);
40: buffer.append(':');
41: buffer.append(line);
42: if (column > 0) {
43: buffer.append(':');
44: buffer.append(column);
45: }
46: buffer.append(": ");
47: if (severity == 'w')
48: buffer.append("warning - ");
49: buffer.append(message);
50: return buffer.toString();
51: }
52:
53: public void print(java.io.PrintWriter out) {
54: out.print(this);
55: }
56: }
|