Module bus.http

Class Progress

java.lang.Object
org.miaixz.bus.http.plugin.httpv.Progress

public class Progress extends Object
Represents the progress of an upload or download operation.
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default step size in bytes for progress updates.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Progress(long totalBytes, long doneBytes)
    Constructs a new Progress instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDoneBytes(long delta)
    Adds a delta to the number of completed bytes.
    long
    Returns the number of bytes that have been completed.
    double
    Returns the progress rate as a value between 0.0 and 1.0.
    long
    Returns the total number of bytes.
    void
    Increments the number of completed bytes by one.
    boolean
    Returns whether the operation is complete.
    boolean
    notDoneOrReached(long bytes)
    Returns whether the operation is not yet done or has not reached a certain number of bytes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_STEP_BYTES

      public static final int DEFAULT_STEP_BYTES
      The default step size in bytes for progress updates.
      See Also:
  • Constructor Details

    • Progress

      public Progress(long totalBytes, long doneBytes)
      Constructs a new Progress instance.
      Parameters:
      totalBytes - The total number of bytes.
      doneBytes - The number of bytes already completed.
  • Method Details

    • getRate

      public double getRate()
      Returns the progress rate as a value between 0.0 and 1.0.
      Returns:
      The progress rate.
    • getTotalBytes

      public long getTotalBytes()
      Returns the total number of bytes.
      Returns:
      The total number of bytes.
    • getDoneBytes

      public long getDoneBytes()
      Returns the number of bytes that have been completed.
      Returns:
      The number of completed bytes.
    • isDone

      public boolean isDone()
      Returns whether the operation is complete.
      Returns:
      true if the operation is complete, false otherwise.
    • addDoneBytes

      public void addDoneBytes(long delta)
      Adds a delta to the number of completed bytes.
      Parameters:
      delta - The number of bytes to add.
    • increaseDoneBytes

      public void increaseDoneBytes()
      Increments the number of completed bytes by one.
    • notDoneOrReached

      public boolean notDoneOrReached(long bytes)
      Returns whether the operation is not yet done or has not reached a certain number of bytes.
      Parameters:
      bytes - The threshold in bytes.
      Returns:
      true if the operation is not done or has not reached the threshold.