info.bliki.api.XMLEditParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bliki-core Show documentation
Show all versions of bliki-core Show documentation
This is the core project.
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;
}
}