use of org.xml.sax.XMLReader in project android_frameworks_base by ParanoidAndroid.
the class Xml method parse.
/**
* Parses xml from the given input stream and fires events on the given SAX
* handler.
*/
public static void parse(InputStream in, Encoding encoding, ContentHandler contentHandler) throws IOException, SAXException {
XMLReader reader = new ExpatReader();
reader.setContentHandler(contentHandler);
InputSource source = new InputSource(in);
source.setEncoding(encoding.expatName);
reader.parse(source);
}
use of org.xml.sax.XMLReader in project android_frameworks_base by ParanoidAndroid.
the class Xml method parse.
/**
* Parses the given xml string and fires events on the given SAX handler.
*/
public static void parse(String xml, ContentHandler contentHandler) throws SAXException {
try {
XMLReader reader = new ExpatReader();
reader.setContentHandler(contentHandler);
reader.parse(new InputSource(new StringReader(xml)));
} catch (IOException e) {
throw new AssertionError(e);
}
}
use of org.xml.sax.XMLReader in project jmonkeyengine by jMonkeyEngine.
the class SceneMaterialLoader method load.
public MaterialList load(AssetManager assetManager, String folderName, InputStream in) throws IOException {
try {
this.assetManager = assetManager;
this.folderName = folderName;
reset();
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
XMLReader xr = factory.newSAXParser().getXMLReader();
xr.setContentHandler(this);
xr.setErrorHandler(this);
InputStreamReader r = null;
try {
r = new InputStreamReader(in);
xr.parse(new InputSource(r));
} finally {
if (r != null) {
r.close();
}
}
return materialList;
} catch (SAXException ex) {
IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
ioEx.initCause(ex);
throw ioEx;
} catch (ParserConfigurationException ex) {
IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
ioEx.initCause(ex);
throw ioEx;
}
}
use of org.xml.sax.XMLReader in project OpenNotebook by jaltekruse.
the class OldReader method readFile.
public Document readFile(InputStreamReader file) throws SAXException, IOException {
attributeNameInError = null;
attributeValueInError = null;
objectWithError = null;
XMLReader reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(this);
reader.setErrorHandler(this);
reader.parse(new InputSource(file));
if (doc == null) {
if (DEBUG) {
System.out.println("error 1");
}
throw new IOException("improper document format");
}
if (hadAttributeError) {
if (DEBUG) {
System.out.println("error 2");
}
throw new IOException("improper document format, error with attribute '" + attributeNameInError + "' with a value of '" + attributeValueInError + "'" + " in object '" + objectWithError + "'");
}
return doc;
}
use of org.xml.sax.XMLReader in project musicbrainz-android by jdamcd.
the class ResponseParser method parse.
protected void parse(InputStream stream, DefaultHandler handler) throws IOException {
try {
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
InputSource source = new InputSource(stream);
reader.setContentHandler(handler);
reader.parse(source);
} catch (SAXException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
Aggregations