axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change
on this file since 46e4682 was
8780cbec,
checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago
|
ABAC sources from Cobham
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | package edu.stanford.rt.parser; |
---|
2 | |
---|
3 | import org.xml.sax.ErrorHandler; |
---|
4 | import org.xml.sax.SAXException; |
---|
5 | import org.xml.sax.SAXParseException; |
---|
6 | |
---|
7 | |
---|
8 | public class ParsingErrorHandler implements ErrorHandler |
---|
9 | { |
---|
10 | /** Warning. */ |
---|
11 | public void warning(SAXParseException ex) |
---|
12 | { |
---|
13 | System.out.println( |
---|
14 | "[Warning] " |
---|
15 | + getLocationString(ex) |
---|
16 | + ": " |
---|
17 | + ex.getMessage()); |
---|
18 | } |
---|
19 | |
---|
20 | /** Error. */ |
---|
21 | public void error(SAXParseException ex) |
---|
22 | { |
---|
23 | System.out.println( |
---|
24 | "[Error] " |
---|
25 | + getLocationString(ex) |
---|
26 | + ": " |
---|
27 | + ex.getMessage()); |
---|
28 | } |
---|
29 | |
---|
30 | /** Fatal error. */ |
---|
31 | public void fatalError(SAXParseException ex) throws SAXException |
---|
32 | { |
---|
33 | System.out.println( |
---|
34 | "[Fatal Error] " |
---|
35 | + getLocationString(ex) |
---|
36 | + ": " |
---|
37 | + ex.getMessage()); |
---|
38 | throw ex; |
---|
39 | } |
---|
40 | |
---|
41 | /** Returns a string of the location. */ |
---|
42 | private String getLocationString(SAXParseException ex) |
---|
43 | { |
---|
44 | StringBuffer str = new StringBuffer(); |
---|
45 | |
---|
46 | String systemId = ex.getSystemId(); |
---|
47 | if (systemId != null) |
---|
48 | { |
---|
49 | int index = systemId.lastIndexOf('/'); |
---|
50 | if (index != -1) |
---|
51 | systemId = systemId.substring(index + 1); |
---|
52 | str.append(systemId); |
---|
53 | } |
---|
54 | str.append(':'); |
---|
55 | str.append(ex.getLineNumber()); |
---|
56 | str.append(':'); |
---|
57 | str.append(ex.getColumnNumber()); |
---|
58 | |
---|
59 | return str.toString(); |
---|
60 | |
---|
61 | } |
---|
62 | |
---|
63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.