Package elki.logging.progress
Class FiniteProgress
- java.lang.Object
-
- elki.logging.progress.AbstractProgress
-
- elki.logging.progress.FiniteProgress
-
- All Implemented Interfaces:
Progress
- Direct Known Subclasses:
StepProgress
public class FiniteProgress extends AbstractProgress
A progress object for a given overall number of items to process. The number of already processed items at a point in time can be updated.The main feature of this class is to provide a String representation of the progress suitable as a message for printing to the command line interface.
- Since:
- 0.1
- Author:
- Arthur Zimek
-
-
Field Summary
Fields Modifier and Type Field Description private inttotalThe overall number of items to process.private inttotalLengthHolds the length of a String describing the total number.-
Fields inherited from class elki.logging.progress.AbstractProgress
ratems
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFiniteProgress(java.lang.String task, int total)Constructor.FiniteProgress(java.lang.String task, int total, Logging logger)Constructor with auto-reporting to logging.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBuilderappendToBuffer(java.lang.StringBuilder buf)Append a string representation of the progress to the given string buffer.voidensureCompleted(Logging logger)Ensure that the progress was completed, to make progress bars disappearintgetTotal()Get the final value for the progress.booleanisComplete()Test whether the progress was completed.private intnumDigits(int x)Length of a number.protected voidsetProcessed(int processed)Sets the number of items already processed at a time being.-
Methods inherited from class elki.logging.progress.AbstractProgress
getProcessed, getTask, incrementProcessed, setProcessed, testLoggingRate, toString
-
-
-
-
Constructor Detail
-
FiniteProgress
protected FiniteProgress(java.lang.String task, int total)Constructor.- Parameters:
task- the name of the tasktotal- the overall number of items to process
-
FiniteProgress
public FiniteProgress(java.lang.String task, int total, Logging logger)Constructor with auto-reporting to logging.- Parameters:
task- the name of the tasktotal- the overall number of items to processlogger- the logger to report to
-
-
Method Detail
-
setProcessed
protected void setProcessed(int processed) throws java.lang.IllegalArgumentExceptionSets the number of items already processed at a time being.- Overrides:
setProcessedin classAbstractProgress- Parameters:
processed- the number of items already processed at a time being- Throws:
java.lang.IllegalArgumentException- if the given number is negative or exceeds the overall number of items to process
-
appendToBuffer
public java.lang.StringBuilder appendToBuffer(java.lang.StringBuilder buf)
Append a string representation of the progress to the given string buffer.- Specified by:
appendToBufferin interfaceProgress- Specified by:
appendToBufferin classAbstractProgress- Parameters:
buf- Buffer to serialize to- Returns:
- Buffer the data was serialized to.
-
numDigits
private int numDigits(int x)
Length of a number.- Parameters:
x- Number- Returns:
- Number of digits
-
isComplete
public boolean isComplete()
Test whether the progress was completed.- Returns:
- Whether the progress was completed.
-
getTotal
public int getTotal()
Get the final value for the progress.- Returns:
- final value
-
ensureCompleted
public void ensureCompleted(Logging logger)
Ensure that the progress was completed, to make progress bars disappear- Parameters:
logger- Logger to report to.
-
-