java.lang.Object
org.eclipse.aether.spi.connector.transport.TransportTask
org.eclipse.aether.spi.connector.transport.GetTask

public final class GetTask extends TransportTask
A task to download a resource from the remote repository.
See Also:
  • Constructor Details Link icon

    • GetTask Link icon

      public GetTask(URI location)
      Creates a new task for the specified remote resource.
      Parameters:
      location - The relative location of the resource in the remote repository, must not be null.
  • Method Details Link icon

    • newOutputStream Link icon

      Opens an output stream to store the downloaded data. Depending on getDataFile(), 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 Link icon

      public OutputStream newOutputStream(boolean resume) throws IOException
      Opens an output stream to store the downloaded data. Depending on getDataFile(), 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 by getResumeOffset(), 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 Link icon

      Deprecated.
      Use getDataPath() instead.
      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.
    • getDataPath Link icon

      public Path getDataPath()
      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.
      Since:
      2.0.0
    • setDataFile Link icon

      @Deprecated public GetTask setDataFile(File dataFile)
      Deprecated.
      Use setDataPath(Path) instead.
      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 be null to store the data in memory.
      Returns:
      This task for chaining, never null.
    • setDataPath Link icon

      public GetTask setDataPath(Path dataPath)
      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:
      dataPath - The file to store the downloaded data, may be null to store the data in memory.
      Returns:
      This task for chaining, never null.
      Since:
      2.0.0
    • setDataFile Link icon

      @Deprecated public GetTask setDataFile(File dataFile, boolean resume)
      Deprecated.
      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 the resume 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 be null 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.
    • setDataPath Link icon

      public GetTask setDataPath(Path dataPath, boolean resume)
      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 the resume 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:
      dataPath - The file to store the downloaded data, may be null 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.
      Since:
      2.0.0
    • getResumeOffset Link icon

      public long 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 Link icon

      public byte[] getDataBytes()
      Gets the data that was downloaded into memory. Note: This method may only be called if getDataFile() is null as otherwise the downloaded data has been written directly to disk.
      Returns:
      The possibly empty data bytes, never null.
    • getDataString Link icon

      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 if getDataFile() is null as otherwise the downloaded data has been written directly to disk.
      Returns:
      The possibly empty data string, never null.
    • setListener Link icon

      Sets the listener that is to be notified during the transfer.
      Parameters:
      listener - The listener to notify of progress, may be null.
      Returns:
      This task for chaining, never null.
    • getChecksums Link icon

      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 of ChecksumPolicy.ChecksumKind.REMOTE_INCLUDED.
      Returns:
      The (read-only) checksums advertised for the downloaded resource, possibly empty but never null.
    • setChecksum Link icon

      public GetTask setChecksum(String algorithm, String value)
      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 be null.
      value - The hexadecimal representation of the checksum, may be null.
      Returns:
      This task for chaining, never null.
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object