/** * This checks context for a user specified {@link SAXParser}. * If one is not found, this reuses a SAXParser from the pool. * * @since Apache Tika 1.19 * @param is InputStream to parse * @param contentHandler handler to use * @param context context to use * @return * @throws TikaException * @throws IOException * @throws SAXException */ public static void parseSAX(InputStream is, DefaultHandler contentHandler, ParseContext context) throws TikaException, IOException, SAXException { SAXParser saxParser = context.get(SAXParser.class); PoolSAXParser poolSAXParser = null; if (saxParser == null) { poolSAXParser = acquireSAXParser(); saxParser = poolSAXParser.getSAXParser(); } try { saxParser.parse(is, contentHandler); } finally { if (poolSAXParser != null) { releaseParser(poolSAXParser); } } }
/** * This checks context for a user specified {@link SAXParser}. * If one is not found, this reuses a SAXParser from the pool. * * @since Apache Tika 1.19 * @param is InputStream to parse * @param contentHandler handler to use * @param context context to use * @return * @throws TikaException * @throws IOException * @throws SAXException */ public static void parseSAX(InputStream is, DefaultHandler contentHandler, ParseContext context) throws TikaException, IOException, SAXException { SAXParser saxParser = context.get(SAXParser.class); PoolSAXParser poolSAXParser = null; if (saxParser == null) { poolSAXParser = acquireSAXParser(); saxParser = poolSAXParser.getSAXParser(); } try { saxParser.parse(is, contentHandler); } finally { if (poolSAXParser != null) { releaseParser(poolSAXParser); } } }