All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.bliki.api.XMLEditParser Maven / Gradle / Ivy

The newest version!
package info.bliki.api;

import org.xml.sax.SAXException;
import org.xml.sax.Attributes;

/**
 * Reads Edit data from an XML file generated by the Wikimedia API
 */
public class XMLEditParser extends AbstractXMLParser {

    private static final String ERROR_TAG = "error";
    private static final String INFO_ATTR = "info";
    private static final String CODE_ATTR = "code";

    private ErrorData errorData;

    public XMLEditParser(String xmlText) throws SAXException {
        super(xmlText);
    }

    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        fAttributes = attributes;
        if (ERROR_TAG.equalsIgnoreCase(qName)) {
            errorData = new ErrorData();
            errorData.setCode(attributes.getValue(CODE_ATTR));
            errorData.setInfo(attributes.getValue(INFO_ATTR));
        }
    }

    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {
        fAttributes = null;
    }

    public ErrorData getErrorData() {
        return errorData;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy