public class DownloadHelper
extends java.lang.Object
Constructor and Description |
---|
DownloadHelper(EsuApi esuApi,
byte[] buffer)
Creates a new download helper.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(ProgressListener listener)
Sets a listener to provide feedback on the transfer's progress.
|
long |
getCurrentBytes()
Gets the current number of bytes that have been downloaded.
|
java.lang.Exception |
getError()
If the transfer has failed, return the error that caused the failure.
|
long |
getTotalBytes()
Gets the total number of bytes to download.
|
boolean |
isChecksumming() |
boolean |
isComplete()
Returns true if the transfer has completed.
|
boolean |
isFailed()
Returns true if the transfer has failed.
|
void |
readObject(Identifier id,
java.io.File f)
Downloads the given object's contents to a file.
|
void |
readObject(Identifier id,
java.io.OutputStream stream,
boolean closeStream)
Downloads the given object's contents to a stream.
|
void |
setChecksumming(boolean checksumming) |
public DownloadHelper(EsuApi esuApi, byte[] buffer)
esuApi
- the API connection object to use to communicate
with the server.buffer
- the buffer to use for the transfers from the server. If
null, a default 4MB buffer will be used.public void readObject(Identifier id, java.io.File f)
id
- the identifier of the object to downloadf
- the file to write the object's contents to.public void readObject(Identifier id, java.io.OutputStream stream, boolean closeStream)
id
- the identifier of the object to download.stream
- the stream to write the object's contents to.closeStream
- specifies whether to close the stream after
the transfer is complete. Defaults to true.public long getCurrentBytes()
public long getTotalBytes()
public boolean isComplete()
public boolean isFailed()
public java.lang.Exception getError()
public void addListener(ProgressListener listener)
listener
- the listener to use for feedback. Set
to null to disable progress notifications.public void setChecksumming(boolean checksumming)
checksumming
- the checksumming to setpublic boolean isChecksumming()