public void close() throws IOException { try { conn.commit(); } catch (SQLException e){ throw new IOExceptionWithCause(e); } try { conn.close(); } catch (SQLException e) { throw new IOExceptionWithCause(e); } } }
/** * Returns the wrapped exception. The only difference to the overridden * {@link Throwable#getCause()} method is the narrower return type. * * @return wrapped exception */ @Override public IOException getCause() { return (IOException) super.getCause(); }
/** * Constructs a new instance with the given message and cause. * <p> * As specified in {@link Throwable}, the message in the given <code>cause</code> is not used in this instance's * message. * </p> * * @param message * the message (see {@link #getMessage()}) * @param cause * the cause (see {@link #getCause()}). A <code>null</code> value is allowed. */ public IOExceptionWithCause(String message, Throwable cause) { super(message); this.initCause(cause); }
reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml)); } catch (XMLStreamException e) { throw new IOExceptionWithCause(e); throw new IOExceptionWithCause(e);
/** * Constructs a new instance with the given cause. * <p> * The message is set to <code>cause==null ? null : cause.toString()</code>, which by default contains the class * and message of <code>cause</code>. This constructor is useful for call sites that just wrap another throwable. * </p> * * @param cause * the cause (see {@link #getCause()}). A <code>null</code> value is allowed. */ public IOExceptionWithCause(Throwable cause) { super(cause == null ? null : cause.toString()); this.initCause(cause); }
/** * Returns the wrapped exception. The only difference to the overridden * {@link Throwable#getCause()} method is the narrower return type. * * @return wrapped exception */ @Override public IOException getCause() { return (IOException) super.getCause(); }
/** * 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); }
/** * Constructs a new instance with the given message and cause. * <p> * As specified in {@link Throwable}, the message in the given <code>cause</code> is not used in this instance's * message. * </p> * * @param message * the message (see {@link #getMessage()}) * @param cause * the cause (see {@link #getCause()}). A <code>null</code> value is allowed. */ public IOExceptionWithCause(String message, Throwable cause) { super(message); this.initCause(cause); }
/** * Returns the wrapped exception. The only difference to the overridden * {@link Throwable#getCause()} method is the narrower return type. * * @return wrapped exception */ @Override public IOException getCause() { return (IOException) super.getCause(); }
doc = docBuilder.parse(is); } catch (TikaException|SAXException e) { throw new IOExceptionWithCause(e);
/** * Constructs a new instance with the given message and cause. * <p> * As specified in {@link Throwable}, the message in the given <code>cause</code> is not used in this instance's * message. * </p> * * @param message * the message (see {@link #getMessage()}) * @param cause * the cause (see {@link #getCause()}). A <code>null</code> value is allowed. */ public IOExceptionWithCause(String message, Throwable cause) { super(message); this.initCause(cause); }
throw new IOExceptionWithCause(e); } catch (TikaException e) {
/** * Constructs a new instance with the given cause. * <p> * The message is set to <code>cause==null ? null : cause.toString()</code>, which by default contains the class * and message of <code>cause</code>. This constructor is useful for call sites that just wrap another throwable. * </p> * * @param cause * the cause (see {@link #getCause()}). A <code>null</code> value is allowed. */ public IOExceptionWithCause(Throwable cause) { super(cause == null ? null : cause.toString()); this.initCause(cause); }
@Override public void digest(InputStream is, Metadata m, ParseContext parseContext) throws IOException { TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(is, tmp); try { for (DigestingParser.Digester digester : digesters) { digester.digest(tis, m, parseContext); } } finally { try { tmp.dispose(); } catch (TikaException e) { throw new IOExceptionWithCause(e); } } } }
/** * Constructs a new instance with the given cause. * <p> * The message is set to <code>cause==null ? null : cause.toString()</code>, which by default contains the class * and message of <code>cause</code>. This constructor is useful for call sites that just wrap another throwable. * </p> * * @param cause * the cause (see {@link #getCause()}). A <code>null</code> value is allowed. */ public IOExceptionWithCause(Throwable cause) { super(cause == null ? null : cause.toString()); this.initCause(cause); }
@Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (Thread.currentThread().isInterrupted()) { throw new TikaException("interrupted", new InterruptedException()); } Document doc = null; try { DocumentBuilder docBuilder = context.getDocumentBuilder(); doc = docBuilder.parse(stream); } catch (SAXException e) { //to distinguish between SAX on read vs SAX while writing throw new IOExceptionWithCause(e); } Node root = doc.getDocumentElement(); NodeList actions = root.getChildNodes(); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); for (int i = 0; i < actions.getLength(); i++) { executeAction(actions.item(i), metadata, context, xhtml); } xhtml.endDocument(); }
poifs = new POIFSFileSystem(new CloseShieldInputStream(stream)); } catch (RuntimeException e) { throw new IOExceptionWithCause(e);
@Override protected void startDocument(PDDocument pdf) throws IOException { try { handler.startDocument(); } catch (SAXException e) { throw new IOExceptionWithCause("Unable to start a document", e); } }
@Override protected void writeLineSeparator() throws IOException { try { handler.characters("\n"); } catch (SAXException e) { throw new IOExceptionWithCause( "Unable to write a newline character", e); } }
@Override protected void endDocument(PDDocument pdf) throws IOException { try { handler.endDocument(); } catch (SAXException e) { throw new IOExceptionWithCause("Unable to end a document", e); } }