Class TransferResource

java.lang.Object
org.eclipse.aether.transfer.TransferResource

public final class TransferResource extends Object
Describes a resource being uploaded or downloaded by the repository system.
  • Constructor Details

    • TransferResource

      public TransferResource(String repositoryId, String repositoryUrl, String resourceName, File file, RequestTrace trace)
      Creates a new transfer resource with the specified properties.
      Parameters:
      repositoryId - The ID of the repository used to transfer the resource, may be null or empty if unknown.
      repositoryUrl - The base URL of the repository, may be null or empty if unknown. If not empty, a trailing slash will automatically be added if missing.
      resourceName - The relative path to the resource within the repository, may be null. A leading slash (if any) will be automatically removed.
      file - The source/target file involved in the transfer, may be null.
      trace - The trace information, may be null.
      Since:
      1.1.0
  • Method Details

    • getRepositoryId

      The ID of the repository, e.g., "central".
      Returns:
      The ID of the repository or an empty string if unknown, never null.
      Since:
      1.1.0
    • getRepositoryUrl

      The base URL of the repository, e.g. "http://repo1.maven.org/maven2/". Unless the URL is unknown, it will be terminated by a trailing slash.
      Returns:
      The base URL of the repository or an empty string if unknown, never null.
    • getResourceName

      The path of the resource relative to the repository's base URL, e.g. "org/apache/maven/maven/3.0/maven-3.0.pom".
      Returns:
      The path of the resource, never null.
    • getFile

      public File getFile()
      Gets the local file being uploaded or downloaded. When the repository system merely checks for the existence of a remote resource, no local file will be involved in the transfer.
      Returns:
      The source/target file involved in the transfer or null if none.
    • getContentLength

      public long getContentLength()
      The size of the resource in bytes. Note that the size of a resource during downloads might be unknown to the client which is usually the case when transfers employ compression like gzip. In general, the content length is not known until the transfer has started.
      Returns:
      The size of the resource in bytes or a negative value if unknown.
    • setContentLength

      public TransferResource setContentLength(long contentLength)
      Sets the size of the resource in bytes.
      Parameters:
      contentLength - The size of the resource in bytes or a negative value if unknown.
      Returns:
      This resource for chaining, never null.
    • getResumeOffset

      public long getResumeOffset()
      Gets the byte offset within the resource from which the download starts. A positive offset indicates a previous download attempt is being resumed, 0 means the transfer starts at the first byte.
      Returns:
      The zero-based index of the first byte being transferred, never negative.
    • setResumeOffset

      public TransferResource setResumeOffset(long resumeOffset)
      Sets the byte offset within the resource at which the download starts.
      Parameters:
      resumeOffset - The zero-based index of the first byte being transferred, must not be negative.
      Returns:
      This resource for chaining, never null.
    • getTransferStartTime

      public long getTransferStartTime()
      Gets the timestamp when the transfer of this resource was started.
      Returns:
      The timestamp when the transfer of this resource was started.
    • getTrace

      Gets the trace information that describes the higher level request/operation during which this resource is transferred.
      Returns:
      The trace information about the higher level operation or null if none.
    • toString

      public String toString()
      Overrides:
      toString in class Object