public abstract class AbstractRemoteFile extends Object implements RemoteFile
Sub classes should override this class, and do the following: - Implement getChecksum. - Implement getInputStream. - Implement cleanup. - Add getInstance(File, Boolean, Boolean, Boolean)-method to make the file work with the factory.
Modifier and Type | Field and Description |
---|---|
protected File |
file
The file this is remote file for.
|
protected boolean |
fileDeletable
If true, the file may be deleted after all transfers are done.
|
protected long |
filesize
The size of the file.
|
protected boolean |
multipleDownloads
If true, the file may be downloaded multiple times.
|
protected boolean |
useChecksums
If true, communication is checksummed.
|
Constructor and Description |
---|
AbstractRemoteFile(File file,
boolean useChecksums,
boolean fileDeletable,
boolean multipleDownloads)
Initialise common fields in remote file.
|
Modifier and Type | Method and Description |
---|---|
void |
appendTo(OutputStream out)
Append this remote file to the given output stream.
|
abstract void |
cleanup()
Invalidate all file handles.
|
void |
copyTo(File destFile)
Copy this remote file to the given file.
|
abstract String |
getChecksum()
Get checksum for file, or null if checksums were not requested.
|
abstract InputStream |
getInputStream()
Get an input stream representing the remote file.
|
String |
getName()
Get the name of the remote file.
|
abstract int |
getNumberOfRetries()
Method for retrieving the number of retries for retrieving a file.
|
long |
getSize()
Get the size of this remote file.
|
String |
toString() |
protected final boolean useChecksums
protected final boolean fileDeletable
protected final boolean multipleDownloads
protected final long filesize
public AbstractRemoteFile(File file, boolean useChecksums, boolean fileDeletable, boolean multipleDownloads)
file
- The file to make remote file for.useChecksums
- If true, communications should be checksummed.fileDeletable
- If true, the file may be downloaded multiple times. Otherwise, the remote file is
invalidated after first transfer.multipleDownloads
- If useChecksums is true, contains the file checksum.public void copyTo(File destFile)
copyTo
in interface RemoteFile
destFile
- The file to write the remote file to.ArgumentNotValid
- on null destFile, or parent to destfile is not a writeable directory, or destfile exists
and cannot be overwritten.IOFailure
- on I/O trouble writing remote file to destination.public void appendTo(OutputStream out)
appendTo
in interface RemoteFile
out
- The stream to write the remote file to.ArgumentNotValid
- if outputstream is null.IOFailure
- on I/O trouble writing remote file to stream.public abstract InputStream getInputStream()
getInputStream
in interface RemoteFile
IOFailure
- on I/O trouble generating inputstream for remote file.public String getName()
getName
in interface RemoteFile
public abstract String getChecksum()
getChecksum
in interface RemoteFile
public abstract void cleanup()
cleanup
in interface RemoteFile
public abstract int getNumberOfRetries()
public long getSize()
getSize
in interface RemoteFile
Copyright © 2005–2018 The Royal Danish Library, the National Library of France and the Austrian National Library.. All rights reserved.