java.lang.Object
org.miaixz.bus.http.plugin.httpv.Progress
Represents the progress of an upload or download operation.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default step size in bytes for progress updates. -
Constructor Summary
ConstructorsConstructorDescriptionProgress(long totalBytes, long doneBytes) Constructs a newProgressinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDoneBytes(long delta) Adds a delta to the number of completed bytes.longReturns the number of bytes that have been completed.doublegetRate()Returns the progress rate as a value between 0.0 and 1.0.longReturns the total number of bytes.voidIncrements the number of completed bytes by one.booleanisDone()Returns whether the operation is complete.booleannotDoneOrReached(long bytes) Returns whether the operation is not yet done or has not reached a certain number of bytes.
-
Field Details
-
DEFAULT_STEP_BYTES
public static final int DEFAULT_STEP_BYTESThe default step size in bytes for progress updates.- See Also:
-
-
Constructor Details
-
Progress
public Progress(long totalBytes, long doneBytes) Constructs a newProgressinstance.- 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:
trueif the operation is complete,falseotherwise.
-
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:
trueif the operation is not done or has not reached the threshold.
-