1 8 9 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 { 16 private String symbol; 17 private String text; 18 private String lineSnippet = null; 19 private boolean location = false; 20 private String source; 21 private int lineNumber; 22 private int columnNumber; 23 24 public ParseException(String message) 25 { 26 super(message); 27 } 28 29 public ParseException(String message, String symbol, String text, Locator locator) 30 { 31 super(message); 32 33 this.symbol = symbol; 34 this.text = text; 35 36 if (locator!=null) 37 { 38 this.source = locator.getSystemId(); 39 this.lineNumber = locator.getLineNumber(); 40 this.columnNumber = locator.getColumnNumber(); 41 location = true; 42 } 43 } 44 45 public ParseException(String message, String symbol, String text, String lineSnippet, 46 Locator locator) 47 { 48 this(message, symbol, text, locator); 49 50 this.lineSnippet = lineSnippet; 51 } 52 53 public ParseException(String message, String symbol, String text, String lineSnippet, 54 String source, int lineNumber, int columnNumber) 55 { 56 super(message); 57 58 this.symbol = symbol; 59 this.text = text; 60 61 this.lineSnippet = lineSnippet; 62 this.source = source; 63 this.lineNumber = lineNumber; 64 this.columnNumber = columnNumber; 65 } 66 67 public String getSymbol() 68 { 69 return symbol; 70 } 71 72 public String getText() 73 { 74 return text; 75 } 76 77 public String getLineSnippet() 78 { 79 return lineSnippet; 80 } 81 82 public boolean isLocalized() 83 { 84 return location; 85 } 86 87 public String getSource() 88 { 89 return source; 90 } 91 92 public int getLineNumber() 93 { 94 return lineNumber; 95 } 96 97 public int getColumnNumber() 98 { 99 return columnNumber; 100 } 101 102 public String toString() 103 { 104 if (location) 105 return getMessage()+"["+lineNumber+":"+columnNumber+"]"; 106 107 return getMessage(); 108 } 109 } 110 | Popular Tags |