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 extends DefaultHandler { private StringBuffer currentValue; protected MalObjectStore objectStore; public MalListParser(MalObjectStore 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); }