Class GetTask
java.lang.Object
org.eclipse.aether.spi.connector.transport.TransportTask
org.eclipse.aether.spi.connector.transport.GetTask
A task to download a resource from the remote repository.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the checksums which the remote repository advertises for the resource.byte[]
Gets the data that was downloaded into memory.Gets the file (if any) where the downloaded data should be stored.Gets the data that was downloaded into memory as a string.long
Gets the byte offset within the resource from which the download should resume if supported.Opens an output stream to store the downloaded data.newOutputStream
(boolean resume) Opens an output stream to store the downloaded data.setChecksum
(String algorithm, String value) Sets a checksum which the remote repository advertises for the resource.setDataFile
(File dataFile) Sets the file where the downloaded data should be stored.setDataFile
(File dataFile, boolean resume) Sets the file where the downloaded data should be stored.setListener
(TransportListener listener) Sets the listener that is to be notified during the transfer.toString()
Methods inherited from class org.eclipse.aether.spi.connector.transport.TransportTask
getListener, getLocation
-
Constructor Details
-
GetTask
Creates a new task for the specified remote resource.- Parameters:
location
- The relative location of the resource in the remote repository, must not benull
.
-
-
Method Details
-
newOutputStream
Opens an output stream to store the downloaded data. Depending ongetDataFile()
, this stream writes either to a file on disk or a growable buffer in memory. It's the responsibility of the caller to close the provided stream.- Returns:
- The output stream for the data, never
null
. The stream is unbuffered. - Throws:
IOException
- If the stream could not be opened.
-
newOutputStream
Opens an output stream to store the downloaded data. Depending ongetDataFile()
, this stream writes either to a file on disk or a growable buffer in memory. It's the responsibility of the caller to close the provided stream.- Parameters:
resume
-true
if the download resumes from the byte offset given bygetResumeOffset()
,false
if the download starts at the first byte of the resource.- Returns:
- The output stream for the data, never
null
. The stream is unbuffered. - Throws:
IOException
- If the stream could not be opened.
-
getDataFile
Gets the file (if any) where the downloaded data should be stored. If the specified file already exists, it will be overwritten.- Returns:
- The data file or
null
if the data will be buffered in memory.
-
setDataFile
Sets the file where the downloaded data should be stored. If the specified file already exists, it will be overwritten. Unless the caller can reasonably expect the resource to be small, use of a data file is strongly recommended to avoid exhausting heap memory during the download.- Parameters:
dataFile
- The file to store the downloaded data, may benull
to store the data in memory.- Returns:
- This task for chaining, never
null
.
-
setDataFile
Sets the file where the downloaded data should be stored. If the specified file already exists, it will be overwritten or appended to, depending on theresume
argument and the capabilities of the transporter. Unless the caller can reasonably expect the resource to be small, use of a data file is strongly recommended to avoid exhausting heap memory during the download.- Parameters:
dataFile
- The file to store the downloaded data, may benull
to store the data in memory.resume
-true
to request resuming a previous download attempt, starting from the current length of the data file,false
to download the resource from its beginning.- Returns:
- This task for chaining, never
null
.
-
getResumeOffset
Gets the byte offset within the resource from which the download should resume if supported.- Returns:
- The zero-based index of the first byte to download or
0
for a full download from the start of the resource, never negative.
-
getDataBytes
Gets the data that was downloaded into memory. Note: This method may only be called ifgetDataFile()
isnull
as otherwise the downloaded data has been written directly to disk.- Returns:
- The possibly empty data bytes, never
null
.
-
getDataString
Gets the data that was downloaded into memory as a string. The downloaded data is assumed to be encoded using UTF-8. Note: This method may only be called ifgetDataFile()
isnull
as otherwise the downloaded data has been written directly to disk.- Returns:
- The possibly empty data string, never
null
.
-
setListener
Sets the listener that is to be notified during the transfer.- Parameters:
listener
- The listener to notify of progress, may benull
.- Returns:
- This task for chaining, never
null
.
-
getChecksums
Gets the checksums which the remote repository advertises for the resource. The map is keyed by algorithm name and the values are hexadecimal representations of the corresponding value. Note: This is optional data that a transporter may return if the underlying transport protocol provides metadata (e.g. HTTP headers) along with the actual resource data. Checksums returned by this method have kind ofChecksumPolicy.ChecksumKind.REMOTE_INCLUDED
.- Returns:
- The (read-only) checksums advertised for the downloaded resource, possibly empty but never
null
.
-
setChecksum
Sets a checksum which the remote repository advertises for the resource. Note: Transporters should only use this method to record checksum information which is readily available while performing the actual download, they should not perform additional transfers to gather this data.- Parameters:
algorithm
- The name of the checksum algorithm (e.g."SHA-1"
, may benull
.value
- The hexadecimal representation of the checksum, may benull
.- Returns:
- This task for chaining, never
null
.
-
toString
-