Changeset 6906 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-03-10T02:33:20+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r6643 r6906 43 43 */ 44 44 public class XmlObjectParser implements Iterable<Object> { 45 public static class PresetParsingException extends SAXException {46 private int columnNumber;47 private int lineNumber;48 49 /**50 * Constructs a new {@code PresetParsingException}.51 */52 public PresetParsingException() {53 super();54 }55 56 public PresetParsingException(Exception e) {57 super(e);58 }59 60 public PresetParsingException(String message, Exception e) {61 super(message, e);62 }63 64 public PresetParsingException(String message) {65 super(message);66 }67 68 public PresetParsingException rememberLocation(Locator locator) {69 if (locator == null) return this;70 this.columnNumber = locator.getColumnNumber();71 this.lineNumber = locator.getLineNumber();72 return this;73 }74 75 @Override76 public String getMessage() {77 String msg = super.getMessage();78 if (lineNumber == 0 && columnNumber == 0)79 return msg;80 if (msg == null) {81 msg = getClass().getName();82 }83 msg = msg + " " + tr("(at line {0}, column {1})", lineNumber, columnNumber);84 return msg;85 }86 87 public int getColumnNumber() {88 return columnNumber;89 }90 91 public int getLineNumber() {92 return lineNumber;93 }94 }95 96 45 public static final String lang = LanguageInfo.getLanguageCodeXML(); 97 46 … … 127 76 } 128 77 129 protected void throwException(Exception e) throws PresetParsingException{ 130 throw new PresetParsingException(e).rememberLocation(locator); 131 } 132 133 @Override public void startElement(String ns, String lname, String qname, Attributes a) throws SAXException { 78 protected void throwException(Exception e) throws XmlParsingException { 79 throw new XmlParsingException(e).rememberLocation(locator); 80 } 81 82 @Override 83 public void startElement(String ns, String lname, String qname, Attributes a) throws SAXException { 134 84 if (mapping.containsKey(qname)) { 135 85 Class<?> klass = mapping.get(qname).klass; … … 150 100 } 151 101 } 152 @Override public void endElement(String ns, String lname, String qname) throws SAXException { 102 103 @Override 104 public void endElement(String ns, String lname, String qname) throws SAXException { 153 105 if (mapping.containsKey(qname) && !mapping.get(qname).onStart) { 154 106 report(); … … 158 110 } 159 111 } 160 @Override public void characters(char[] ch, int start, int length) { 112 113 @Override 114 public void characters(char[] ch, int start, int length) { 161 115 characters.append(ch, start, length); 162 116 } … … 281 235 private Iterator<Object> queueIterator = null; 282 236 237 /** 238 * Constructs a new {@code XmlObjectParser}. 239 */ 283 240 public XmlObjectParser() { 284 241 parser = new Parser();
Note:
See TracChangeset
for help on using the changeset viewer.