diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-08-25 08:03:05 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-08-25 08:03:05 +0200 |
commit | bf24af1ed9808dc918dc81f0383103b6c51600a6 (patch) | |
tree | d899dae5a08c94b5184a558c16c9f743aee0c3c7 /src/de/animux/android/andmal/api/MalListParser.java | |
parent | 8a8dc0a2ac4f3552568d9e14bf5ae121394b055c (diff) | |
download | AndMAL-master.tar.gz AndMAL-master.tar.xz AndMAL-master.zip |
refactoring, mangalist, settings (current problem: refresh other list after changing the settings)HEADmaster
Diffstat (limited to 'src/de/animux/android/andmal/api/MalListParser.java')
-rw-r--r-- | src/de/animux/android/andmal/api/MalListParser.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/de/animux/android/andmal/api/MalListParser.java b/src/de/animux/android/andmal/api/MalListParser.java new file mode 100644 index 0000000..014b718 --- /dev/null +++ b/src/de/animux/android/andmal/api/MalListParser.java @@ -0,0 +1,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); +} |