public abstract class AbstractDataFetcher extends Object implements DataFetcher
AbstractDataFetcher is a sensible base implementation of
DataFetcher.
Implementers must only implement a single simplified method that copies all
bytes from an InputStream to an OutputStream:
doCopy(InputStream, OutputStream, DataFetchProgressListener).
| Constructor and Description |
|---|
AbstractDataFetcher() |
| Modifier and Type | Method and Description |
|---|---|
void |
copy(InputStream in,
OutputStream out)
Copies the content of a given
InputStream into a given
OutputStream. |
void |
copy(InputStream in,
OutputStream out,
boolean closeIn,
boolean closeOut)
Copies the content of a given
InputStream into a given
OutputStream. |
void |
copy(InputStream in,
OutputStream out,
DataFetchProgressListener listener)
Copies the content of a given
InputStream into a given
OutputStream. |
void |
copy(InputStream in,
OutputStream out,
DataFetchProgressListener listener,
boolean closeIn,
boolean closeOut)
Copies the content of a given
InputStream into a given
OutputStream. |
protected abstract void |
doCopy(InputStream in,
OutputStream out,
DataFetchProgressListener listener)
Copies the content of a given
InputStream into a given
OutputStream. |
byte[] |
fetch(InputStream in)
Fetches the content of a given
InputStream into a fresh byte[]. |
byte[] |
fetch(InputStream in,
boolean close)
Fetches the content of a given
InputStream into a fresh byte[]. |
byte[] |
fetch(InputStream in,
DataFetchProgressListener listener)
Fetches the content of a given
InputStream into a fresh byte[]. |
byte[] |
fetch(InputStream in,
DataFetchProgressListener listener,
boolean close)
Fetches the content of a given
InputStream into a fresh byte[]. |
public final byte[] fetch(InputStream in) throws DataFetchException
DataFetcherInputStream into a fresh byte[].
See DataFetcher.copy(InputStream, OutputStream, boolean, boolean)
for the handling of missing or invalid arguments.
fetch in interface DataFetcherin - The InputStream to read from.byte[], containing the content of the given
InputStream.DataFetchException - If anything went wrong while reading from the given
InputStream.public final byte[] fetch(InputStream in, boolean close) throws DataFetchException
DataFetcherInputStream into a fresh byte[].
See DataFetcher.copy(InputStream, OutputStream, boolean, boolean)
for the handling of missing or invalid arguments.
fetch in interface DataFetcherin - The InputStream to read from.close - Whether to close the given InputStream, after reading
from it.byte[], containing the content of the given
InputStream.DataFetchException - If anything went wrong while reading from the given
InputStream. FetchExceptions
thrown while trying to close the given InputStream,
if requested, are ignored.public final byte[] fetch(InputStream in, DataFetchProgressListener listener) throws DataFetchException
DataFetcherInputStream into a fresh byte[].
See DataFetcher.copy(InputStream, OutputStream, boolean, boolean)
for the handling of missing or invalid arguments.
fetch in interface DataFetcherin - The InputStream to read from.listener - The DataFetchProgressListener to report to.byte[], containing the content of the given
InputStream.DataFetchException - If anything went wrong while reading from the given
InputStream.public final byte[] fetch(InputStream in, DataFetchProgressListener listener, boolean close) throws DataFetchException
DataFetcherInputStream into a fresh byte[].
See DataFetcher.copy(InputStream, OutputStream, boolean, boolean)
for the handling of missing or invalid arguments.
fetch in interface DataFetcherin - The InputStream to read from.listener - The DataFetchProgressListener to report to.close - Whether to close the given InputStream, after reading
from it.byte[], containing the content of the given
InputStream.DataFetchException - If anything went wrong while reading from the given
InputStream. FetchExceptions
thrown while trying to close the given InputStream,
if requested, are ignored.public final void copy(InputStream in, OutputStream out) throws DataFetchException
DataFetcherInputStream into a given
OutputStream.
See DataFetcher.copy(InputStream, OutputStream, boolean, boolean)
for the handling of missing or invalid arguments.
copy in interface DataFetcherin - The InputStream to read from.out - The OutputStream to write to.DataFetchException - If anything went wrong while reading from the given
InputStream or writing to the given
OutputStream.public final void copy(InputStream in, OutputStream out, boolean closeIn, boolean closeOut) throws DataFetchException
DataFetcherInputStream into a given
OutputStream.
Missing or invalid arguments are handled gracefully with the following behaviour.
A null is given as an InputStream, it is simply ignored
and handled as if there was nothing to read. If closeOut is
true, the given OutputStream will be closed anyway
A null is given as an OutputStream, it is simply ignored,
but the content of given InputStream is fetched anyway. If
closeIn is true, the given InputStream will be
closed anyway
copy in interface DataFetcherin - The InputStream to read from.out - The OutputStream to write to.closeIn - Whether to close the given InputStream, after reading
from it.closeOut - Whether to close the given OutputStream, after writing
to it.DataFetchException - If anything went wrong while reading from the given
InputStream or writing to the given
OutputStream. FetchExceptions
thrown while trying to close one of the given streams, if
requested, are ignored.public final void copy(InputStream in, OutputStream out, DataFetchProgressListener listener) throws DataFetchException
DataFetcherInputStream into a given
OutputStream.
See DataFetcher.copy(InputStream, OutputStream, boolean, boolean)
for the handling of missing or invalid arguments.
copy in interface DataFetcherin - The InputStream to read from.out - The OutputStream to write to.listener - The DataFetchProgressListener to report to.DataFetchException - If anything went wrong while reading from the given
InputStream or writing to the given
OutputStream.public final void copy(InputStream in, OutputStream out, DataFetchProgressListener listener, boolean closeIn, boolean closeOut) throws DataFetchException
DataFetcherInputStream into a given
OutputStream.
Missing or invalid arguments are handled gracefully with the following behaviour.
A null is given as an InputStream, it is simply ignored
and handled as if there was nothing to read. If closeOut is
true, the given OutputStream will be closed anyway
A null is given as an OutputStream, it is simply ignored,
but the content of given InputStream is fetched anyway. If
closeIn is true, the given InputStream will be
closed anyway
copy in interface DataFetcherin - The InputStream to read from.out - The OutputStream to write to.listener - The DataFetchProgressListener to report to.closeIn - Whether to close the given InputStream, after reading
from it.closeOut - Whether to close the given OutputStream, after writing
to it.DataFetchException - If anything went wrong while reading from the given
InputStream or writing to the given
OutputStream. FetchExceptions
thrown while trying to close one of the given streams, if
requested, are ignored.protected abstract void doCopy(InputStream in, OutputStream out, DataFetchProgressListener listener) throws DataFetchException
InputStream into a given
OutputStream.
It is guaranteed that neither the given InputStream nor the given
OutputStream nor the given DataFetchProgressListener is
null.
Implementers must not close either of the given streams.
in - The InputStream to read from.out - The OutputStream to write to.listener - The DataFetchProgressListener to report to.DataFetchException - If anything went wrong while reading from the given
InputStream or writing to the given
OutputStream.Copyright © 2015–2016 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.