public abstract class AbstractStreamingDataHandler extends DataHandler implements Closeable
DataHandler extended to offer better buffer management in a streaming
environment.DataHandler is used commonly as a data format across multiple systems
(such as JAXB/WS.) Unfortunately, DataHandler has the semantics of
"read as many times as you want", so this makes it difficult for involving
parties to handle a BLOB in a streaming fashion.AbstractStreamingDataHandler solves this problem by offering methods
that enable faster bulk "consume once" read operation.| Constructor and Description |
|---|
AbstractStreamingDataHandler(DataSource aDataSource) |
AbstractStreamingDataHandler(Object aObj,
String sMimeType) |
AbstractStreamingDataHandler(URL aUrl) |
| Modifier and Type | Method and Description |
|---|---|
String |
getHrefCid() |
abstract InputStream |
readOnce()
Works like
DataHandler.getInputStream() except that this method can be invoked
only once. |
void |
setHrefCid(String sHrefCid) |
getAllCommands, getBean, getCommand, getContent, getContentType, getDataSource, getInputStream, getName, getOutputStream, getPreferredCommands, getTransferData, getTransferDataFlavors, isDataFlavorSupported, setCommandMap, setDataContentHandlerFactory, writeTopublic AbstractStreamingDataHandler(@Nonnull Object aObj, @Nonnull String sMimeType)
public AbstractStreamingDataHandler(@Nonnull DataSource aDataSource)
@Nonnull public abstract InputStream readOnce() throws IOException
DataHandler.getInputStream() except that this method can be invoked
only once.DataHandler.getInputStream() invocation nor readOnce() invocation on
this object (which would result in IOException.)DataHandler is 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.DataHandler.getInputStream() multiple times and
then call 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.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 into
BufferedInputStream.IOException - if any i/o errorCopyright © 2014–2019 Philip Helger. All rights reserved.