/** * Builds a Document with a DocumentBuilder from the pool * * @since Apache Tika 1.19.1 * * @return a document * @throws TikaException * @throws IOException * @throws SAXException */ public static Document buildDOM(InputStream is) throws TikaException, IOException, SAXException { PoolDOMBuilder builder = acquireDOMBuilder(); try { return builder.getDocumentBuilder().parse(is); } finally { releaseDOMBuilder(builder); } }
/** * Builds a Document with a DocumentBuilder from the pool * * @since Apache Tika 1.19.1 * @param uriString uriString to process * @return a document * @throws TikaException * @throws IOException * @throws SAXException */ public static Document buildDOM(String uriString) throws TikaException, IOException, SAXException { PoolDOMBuilder builder = acquireDOMBuilder(); try { return builder.getDocumentBuilder().parse(uriString); } finally { releaseDOMBuilder(builder); } }
/** * This checks context for a user specified {@link DocumentBuilder}. * If one is not found, this reuses a DocumentBuilder from the pool. * * @since Apache Tika 1.19 * @param is InputStream to parse * @param context context to use * @return a document * @throws TikaException * @throws IOException * @throws SAXException */ public static Document buildDOM(InputStream is, ParseContext context) throws TikaException, IOException, SAXException { DocumentBuilder builder = context.get(DocumentBuilder.class); PoolDOMBuilder poolBuilder = null; if (builder == null) { poolBuilder = acquireDOMBuilder(); builder = poolBuilder.getDocumentBuilder(); } try { return builder.parse(is); } finally { if (poolBuilder != null) { releaseDOMBuilder(poolBuilder); } } }
/** * Builds a Document with a DocumentBuilder from the pool * * @since Apache Tika 1.19.1 * @param uriString uriString to process * @return a document * @throws TikaException * @throws IOException * @throws SAXException */ public static Document buildDOM(String uriString) throws TikaException, IOException, SAXException { PoolDOMBuilder builder = acquireDOMBuilder(); try { return builder.getDocumentBuilder().parse(uriString); } finally { releaseDOMBuilder(builder); } }
/** * Builds a Document with a DocumentBuilder from the pool * * @since Apache Tika 1.19.1 * * @return a document * @throws TikaException * @throws IOException * @throws SAXException */ public static Document buildDOM(InputStream is) throws TikaException, IOException, SAXException { PoolDOMBuilder builder = acquireDOMBuilder(); try { return builder.getDocumentBuilder().parse(is); } finally { releaseDOMBuilder(builder); } }
/** * This checks context for a user specified {@link DocumentBuilder}. * If one is not found, this reuses a DocumentBuilder from the pool. * * @since Apache Tika 1.19 * @param is InputStream to parse * @param context context to use * @return a document * @throws TikaException * @throws IOException * @throws SAXException */ public static Document buildDOM(InputStream is, ParseContext context) throws TikaException, IOException, SAXException { DocumentBuilder builder = context.get(DocumentBuilder.class); PoolDOMBuilder poolBuilder = null; if (builder == null) { poolBuilder = acquireDOMBuilder(); builder = poolBuilder.getDocumentBuilder(); } try { return builder.parse(is); } finally { if (poolBuilder != null) { releaseDOMBuilder(poolBuilder); } } }