public static <T> Param<T> load(InputStream stream) throws SAXException, IOException, TikaException { DocumentBuilder db = XMLReaderUtils.getDocumentBuilder(); Document document = db.parse(stream); return load(document.getFirstChild()); }
public void save(OutputStream stream) throws TransformerException, TikaException { DocumentBuilder builder = XMLReaderUtils.getDocumentBuilder(); Document doc = builder.newDocument(); Element paramEl = doc.createElement("param"); doc.appendChild(paramEl); save(paramEl); Transformer transformer = XMLReaderUtils.getTransformer(); transformer.transform(new DOMSource(paramEl), new StreamResult(stream)); }
public static List<ExternalParser> read(InputStream stream) throws TikaException, IOException { try { DocumentBuilder builder = XMLReaderUtils.getDocumentBuilder(); Document document = builder.parse(new InputSource(stream)); return read(document); } catch (SAXException e) { throw new TikaException("Invalid parser configuration", e); } }
/** * Returns the DOM builder specified in this parsing context. * If a builder is not explicitly specified, then a builder * instance is created and returned. The builder instance is * configured to apply an {@link XMLReaderUtils#IGNORING_SAX_ENTITY_RESOLVER}, * and it sets the ErrorHandler to <code>null</code>. * Consider using {@link XMLReaderUtils#buildDOM(InputStream, ParseContext)} * instead for more efficient reuse of document builders. * * @since Apache Tika 1.13 * @return DOM Builder */ public DocumentBuilder getDocumentBuilder() throws TikaException { DocumentBuilder documentBuilder = get(DocumentBuilder.class); if (documentBuilder != null) { return documentBuilder; } else { return XMLReaderUtils.getDocumentBuilder(); } }
public Options build(InputStream is) throws IOException { Document doc = null; try { DocumentBuilder docBuilder = XMLReaderUtils.getDocumentBuilder(); doc = docBuilder.parse(is); } catch (TikaException|SAXException e) {
/** * Builds a BatchProcess from runtime arguments and a * input stream of a configuration file. With the exception of the QueueBuilder, * the builders choose how to adjudicate between * runtime arguments and the elements in the configuration file. * <p/> * This does not close the InputStream! * @param is inputStream * @param runtimeAttributes incoming runtime attributes * @return batch process * @throws java.io.IOException */ public BatchProcess build(InputStream is, Map<String,String> runtimeAttributes) throws IOException { Document doc = null; try { DocumentBuilder docBuilder = XMLReaderUtils.getDocumentBuilder(); doc = docBuilder.parse(is); } catch (TikaException|SAXException e) { throw new IOExceptionWithCause(e); } Node docElement = doc.getDocumentElement(); return build(docElement, runtimeAttributes); }
public static ResultsReporter build(Path p) throws Exception { ResultsReporter r = new ResultsReporter(); DocumentBuilder docBuilder = XMLReaderUtils.getDocumentBuilder(); Document doc; try (InputStream is = Files.newInputStream(p)) { doc = docBuilder.parse(is); } Node docElement = doc.getDocumentElement(); assert (docElement.getNodeName().equals("reports")); NodeList children = docElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if ("before".equals(n.getNodeName())) { for (String before : getSql(n)) { r.addBefore(before); } } else if ("after".equals(n.getNodeName())) { for (String after : getSql(n)) { r.addAfter(after); } } else if ("report".equals(n.getNodeName())) { Report report = buildReport(n); r.addReport(report); } } return r; }
DocumentBuilder docBuilder = XMLReaderUtils.getDocumentBuilder();
for (int i = 0; i < poolSize; i++) { DOM_BUILDERS.offer( new PoolDOMBuilder(POOL_GENERATION.get(), getDocumentBuilder()));
public static <T> Param<T> load(InputStream stream) throws SAXException, IOException, TikaException { DocumentBuilder db = XMLReaderUtils.getDocumentBuilder(); Document document = db.parse(stream); return load(document.getFirstChild()); }
public void save(OutputStream stream) throws TransformerException, TikaException { DocumentBuilder builder = XMLReaderUtils.getDocumentBuilder(); Document doc = builder.newDocument(); Element paramEl = doc.createElement("param"); doc.appendChild(paramEl); save(paramEl); Transformer transformer = XMLReaderUtils.getTransformer(); transformer.transform(new DOMSource(paramEl), new StreamResult(stream)); }
public static List<ExternalParser> read(InputStream stream) throws TikaException, IOException { try { DocumentBuilder builder = XMLReaderUtils.getDocumentBuilder(); Document document = builder.parse(new InputSource(stream)); return read(document); } catch (SAXException e) { throw new TikaException("Invalid parser configuration", e); } }
/** * Returns the DOM builder specified in this parsing context. * If a builder is not explicitly specified, then a builder * instance is created and returned. The builder instance is * configured to apply an {@link XMLReaderUtils#IGNORING_SAX_ENTITY_RESOLVER}, * and it sets the ErrorHandler to <code>null</code>. * Consider using {@link XMLReaderUtils#buildDOM(InputStream, ParseContext)} * instead for more efficient reuse of document builders. * * @since Apache Tika 1.13 * @return DOM Builder */ public DocumentBuilder getDocumentBuilder() throws TikaException { DocumentBuilder documentBuilder = get(DocumentBuilder.class); if (documentBuilder != null) { return documentBuilder; } else { return XMLReaderUtils.getDocumentBuilder(); } }
DocumentBuilder docBuilder = XMLReaderUtils.getDocumentBuilder();
for (int i = 0; i < poolSize; i++) { DOM_BUILDERS.offer( new PoolDOMBuilder(POOL_GENERATION.get(), getDocumentBuilder()));