01: /*
02: * Copyright (C) Chaperon. All rights reserved.
03: * -------------------------------------------------------------------------
04: * This software is published under the terms of the Apache Software License
05: * version 1.1, a copy of which has been included with this distribution in
06: * the LICENSE file.
07: */
08:
09: package net.sourceforge.chaperon.process;
10:
11: import org.xml.sax.Locator;
12: import org.xml.sax.SAXException;
13:
14: public class ParseException extends SAXException {
15: private String symbol;
16: private String text;
17: private String lineSnippet = null;
18: private boolean location = false;
19: private String source;
20: private int lineNumber;
21: private int columnNumber;
22:
23: public ParseException(String message) {
24: super (message);
25: }
26:
27: public ParseException(String message, String symbol, String text,
28: Locator locator) {
29: super (message);
30:
31: this .symbol = symbol;
32: this .text = text;
33:
34: if (locator != null) {
35: this .source = locator.getSystemId();
36: this .lineNumber = locator.getLineNumber();
37: this .columnNumber = locator.getColumnNumber();
38: location = true;
39: }
40: }
41:
42: public ParseException(String message, String symbol, String text,
43: String lineSnippet, Locator locator) {
44: this (message, symbol, text, locator);
45:
46: this .lineSnippet = lineSnippet;
47: }
48:
49: public ParseException(String message, String symbol, String text,
50: String lineSnippet, String source, int lineNumber,
51: int columnNumber) {
52: super (message);
53:
54: this .symbol = symbol;
55: this .text = text;
56:
57: this .lineSnippet = lineSnippet;
58: this .source = source;
59: this .lineNumber = lineNumber;
60: this .columnNumber = columnNumber;
61: }
62:
63: public String getSymbol() {
64: return symbol;
65: }
66:
67: public String getText() {
68: return text;
69: }
70:
71: public String getLineSnippet() {
72: return lineSnippet;
73: }
74:
75: public boolean isLocalized() {
76: return location;
77: }
78:
79: public String getSource() {
80: return source;
81: }
82:
83: public int getLineNumber() {
84: return lineNumber;
85: }
86:
87: public int getColumnNumber() {
88: return columnNumber;
89: }
90:
91: public String toString() {
92: if (location)
93: return getMessage() + "[" + lineNumber + ":" + columnNumber
94: + "]";
95:
96: return getMessage();
97: }
98: }
|