blob: 014b718d7935f68e67ea90b4eb9389b651611210 (
plain) (
blame)
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
|
package de.animux.android.andmal.api;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public abstract class MalListParser<T extends MalObject> extends DefaultHandler {
private StringBuffer currentValue;
protected MalObjectStore<T> objectStore;
public MalListParser(MalObjectStore<T> objectStore) {
super();
this.objectStore = objectStore;
currentValue = new StringBuffer();
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
currentValue.append(new String(ch).substring(start, length - start)
.replaceAll("&", "&"));
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
addElement(localName, currentValue.toString());
currentValue.setLength(0);
}
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
currentValue.setLength(0);
}
abstract public void addElement(String name, String value);
}
|