-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrorHandler.java
50 lines (35 loc) · 1.49 KB
/
ErrorHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.sanbit.android.mystats;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class ErrorHandler extends DefaultHandler{
// ===========================================================
// Fields
// ===========================================================
private boolean in_outertag = false;
private boolean in_innertag = false;
private boolean in_mytag = false;
private ParsedErrorDataSet myParsedErrorDataSet = new ParsedErrorDataSet();
// ===========================================================
// Getter & Setter
// ===========================================================
public ParsedErrorDataSet getParsedData() {
return this.myParsedErrorDataSet;
}
/** Gets be called on opening tags like:
* <tag>
* Can provide attribute(s), when xml was like:
* <tag attribute="attributeValue">*/
@Override
public void startElement(String namespaceURI, String localName,String qName, Attributes atts) throws SAXException {
if (localName.equals("message")) {
myParsedErrorDataSet.setExtractedString(atts.getValue("thenumber"));
}
}
/** Gets be called on the following structure:
* <tag>characters</tag> */
@Override
public void characters(char ch[], int start, int length) {
myParsedErrorDataSet.setExtractedString(new String(ch, start, length));
}
}