Package com.helger.mail.datahandler
Class DataSourceStreamingDataHandler
java.lang.Object
jakarta.activation.DataHandler
com.helger.mail.datahandler.AbstractStreamingDataHandler
com.helger.mail.datahandler.DataSourceStreamingDataHandler
- All Implemented Interfaces:
Closeable,AutoCloseable
An implementation of AbstractStreamingDataHandler using
DataSource as
the source.- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()readOnce()Works likeDataHandler.getInputStream()except that this method can be invoked only once.
This is used as a signal from the caller that there will be no furtherDataHandler.getInputStream()invocation norAbstractStreamingDataHandler.readOnce()invocation on this object (which would result inIOException.)
WhenDataHandleris backed by a streaming BLOB (such as an attachment in a web service read from the network), this allows the callee to avoid unnecessary buffering.
Note that it is legal to callDataHandler.getInputStream()multiple times and then callAbstractStreamingDataHandler.readOnce()afterward.Methods inherited from class com.helger.mail.datahandler.AbstractStreamingDataHandler
getHrefCid, setHrefCidMethods inherited from class jakarta.activation.DataHandler
getAllCommands, getBean, getCommand, getContent, getContentType, getDataSource, getInputStream, getName, getOutputStream, getPreferredCommands, getTransferData, getTransferDataFlavors, isDataFlavorSupported, setCommandMap, setDataContentHandlerFactory, writeTo
-
Constructor Details
-
DataSourceStreamingDataHandler
-
-
Method Details
-
readOnce
Description copied from class:AbstractStreamingDataHandlerWorks likeDataHandler.getInputStream()except that this method can be invoked only once.
This is used as a signal from the caller that there will be no furtherDataHandler.getInputStream()invocation norAbstractStreamingDataHandler.readOnce()invocation on this object (which would result inIOException.)
WhenDataHandleris backed by a streaming BLOB (such as an attachment in a web service read from the network), this allows the callee to avoid unnecessary buffering.
Note that it is legal to callDataHandler.getInputStream()multiple times and then callAbstractStreamingDataHandler.readOnce()afterward. Streams created such a way can be read in any order - there's no requirement that streams created earlier must be read first.- Specified by:
readOncein classAbstractStreamingDataHandler- Returns:
- always non-
null. Represents the content of this BLOB. The returned stream is generally not buffered, so for better performance read in a big batch or wrap this intoBufferedInputStream. - Throws:
IOException- if any i/o error
-
close
- Throws:
IOException
-