/** * Returns the SAX parser specified in this parsing context. If a parser * is not explicitly specified, then one is created using the specified * or the default SAX parser factory. * <p> * Make sure to wrap your handler in the {@link OfflineContentHandler} to * prevent XML External Entity attacks * </p> * <p> * If you call reset() on the parser, make sure to replace the * SecurityManager which will be cleared by xerces2 on reset(). * </p> * @return SAX parser * @throws TikaException if a SAX parser could not be created * @see #getSAXParserFactory() * @since Apache Tika 0.8 */ public static SAXParser getSAXParser() throws TikaException { try { SAXParser parser = getSAXParserFactory().newSAXParser(); trySetXercesSecurityManager(parser); return parser; } catch (ParserConfigurationException e) { throw new TikaException("Unable to configure a SAX parser", e); } catch (SAXException e) { throw new TikaException("Unable to create a SAX parser", e); } }
for (int i = 0; i < poolSize; i++) { try { SAX_PARSERS.offer(buildPoolParser(generation, getSAXParserFactory().newSAXParser())); } catch (SAXException|ParserConfigurationException e) { throw new TikaException("problem creating sax parser", e);
for (int i = 0; i < poolSize; i++) { try { SAX_PARSERS.offer(buildPoolParser(generation, getSAXParserFactory().newSAXParser())); } catch (SAXException|ParserConfigurationException e) { throw new TikaException("problem creating sax parser", e);
/** * Returns the SAX parser specified in this parsing context. If a parser * is not explicitly specified, then one is created using the specified * or the default SAX parser factory. * <p> * Make sure to wrap your handler in the {@link OfflineContentHandler} to * prevent XML External Entity attacks * </p> * <p> * If you call reset() on the parser, make sure to replace the * SecurityManager which will be cleared by xerces2 on reset(). * </p> * @return SAX parser * @throws TikaException if a SAX parser could not be created * @see #getSAXParserFactory() * @since Apache Tika 0.8 */ public static SAXParser getSAXParser() throws TikaException { try { SAXParser parser = getSAXParserFactory().newSAXParser(); trySetXercesSecurityManager(parser); return parser; } catch (ParserConfigurationException e) { throw new TikaException("Unable to configure a SAX parser", e); } catch (SAXException e) { throw new TikaException("Unable to create a SAX parser", e); } }