use of org.xml.sax.XMLReader in project AndEngine by nicolasgramlich.
the class TexturePackLoader method load.
public TexturePack load(final InputStream pInputStream, final String pAssetBasePath) throws TexturePackParseException {
try {
final SAXParserFactory spf = SAXParserFactory.newInstance();
final SAXParser sp = spf.newSAXParser();
final XMLReader xr = sp.getXMLReader();
final TexturePackParser texturePackParser = new TexturePackParser(this.mAssetManager, pAssetBasePath, this.mTextureManager);
xr.setContentHandler(texturePackParser);
xr.parse(new InputSource(new BufferedInputStream(pInputStream)));
return texturePackParser.getTexturePack();
} catch (final SAXException e) {
throw new TexturePackParseException(e);
} catch (final ParserConfigurationException pe) {
/* Doesn't happen. */
return null;
} catch (final IOException e) {
throw new TexturePackParseException(e);
} finally {
StreamUtils.close(pInputStream);
}
}
use of org.xml.sax.XMLReader in project AndEngine by nicolasgramlich.
the class AnimationPackLoader method load.
public AnimationPack load(final InputStream pInputStream, final String pAssetBasePath) throws AnimationPackParseException {
try {
final SAXParserFactory spf = SAXParserFactory.newInstance();
final SAXParser sp = spf.newSAXParser();
final XMLReader xr = sp.getXMLReader();
final AnimationPackParser animationPackParser = new AnimationPackParser(this.mAssetManager, pAssetBasePath, this.mTextureManager);
xr.setContentHandler(animationPackParser);
xr.parse(new InputSource(new BufferedInputStream(pInputStream)));
return animationPackParser.getAnimationPack();
} catch (final SAXException e) {
throw new AnimationPackParseException(e);
} catch (final ParserConfigurationException pe) {
/* Doesn't happen. */
return null;
} catch (final IOException e) {
throw new AnimationPackParseException(e);
} finally {
StreamUtils.close(pInputStream);
}
}
use of org.xml.sax.XMLReader in project che by eclipse.
the class RefactoringSessionReader method createParser.
/**
* Creates a new parser from the specified factory.
*
* @param factory
* the parser factoring to use
* @return the created parser
* @throws ParserConfigurationException
* if no parser is available with the given configuration
* @throws SAXException
* if an error occurs while creating the parser
*/
private SAXParser createParser(final SAXParserFactory factory) throws ParserConfigurationException, SAXException {
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
try {
//$NON-NLS-1$
reader.setFeature("http://xml.org/sax/features/validation", false);
//$NON-NLS-1$
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
} catch (SAXNotRecognizedException exception) {
// Do nothing
} catch (SAXNotSupportedException exception) {
// Do nothing
}
return parser;
}
use of org.xml.sax.XMLReader in project android_frameworks_base by ResurrectionRemix.
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 intellij-community by JetBrains.
the class UnsupportedFeaturesUtil method fillTestCaseMethods.
private static void fillTestCaseMethods() throws IOException {
final Logger log = Logger.getInstance(UnsupportedFeaturesUtil.class.getName());
final FileReader reader = new FileReader(PythonHelpersLocator.getHelperPath("/tools/class_method_versions.xml"));
try {
final XMLReader xr = XMLReaderFactory.createXMLReader();
final ClassMethodsParser parser = new ClassMethodsParser();
xr.setContentHandler(parser);
xr.parse(new InputSource(reader));
} catch (SAXException e) {
log.error("Improperly formed \"class_method_versions.xml\". " + e.getMessage());
} finally {
reader.close();
}
}
Aggregations