de.lmu.ifi.dbs.elki.logging.progress
Class AbstractProgress

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.progress.AbstractProgress
All Implemented Interfaces:
Progress
Direct Known Subclasses:
FiniteProgress, IndefiniteProgress

public abstract class AbstractProgress
extends Object
implements Progress

Abstract base class for FiniteProgress objects.


Field Summary
private  long lastLogged
          For logging rate control.
private  AtomicInteger processed
          The number of items already processed at a time being.
private  String task
          The task name.
 
Constructor Summary
AbstractProgress(String task)
          Default constructor.
 
Method Summary
abstract  StringBuffer appendToBuffer(StringBuffer buf)
          Serialize a description into a String buffer.
 int getProcessed()
          Get the number of items already processed at a time being.
 String getTask()
          Provides the name of the task.
 void incrementProcessed()
          Increment the processed counter.
 void incrementProcessed(Logging logger)
          Increment the processed counter.
 void setProcessed(int processed)
          Sets the number of items already processed at a time being.
 void setProcessed(int processed, Logging logger)
          Sets the number of items already processed at a time being.
protected  boolean testLoggingRate()
          Logging rate control.
 String toString()
          Returns a String representation of the progress suitable as a message for printing to the command line interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.logging.progress.Progress
isComplete
 

Field Detail

processed

private AtomicInteger processed
The number of items already processed at a time being. We use AtomicInteger to allow threaded use without synchronization.


task

private String task
The task name.


lastLogged

private long lastLogged
For logging rate control.

Constructor Detail

AbstractProgress

public AbstractProgress(String task)
Default constructor.

Parameters:
task - Task name.
Method Detail

getTask

public String getTask()
Provides the name of the task.

Returns:
the name of the task

setProcessed

public void setProcessed(int processed)
                  throws IllegalArgumentException
Sets the number of items already processed at a time being.

Parameters:
processed - the number of items already processed at a time being
Throws:
IllegalArgumentException - if an invalid value was passed.

setProcessed

public void setProcessed(int processed,
                         Logging logger)
                  throws IllegalArgumentException
Sets the number of items already processed at a time being.

Parameters:
processed - the number of items already processed at a time being
logger - Logger to report to
Throws:
IllegalArgumentException - if an invalid value was passed.

getProcessed

public int getProcessed()
Get the number of items already processed at a time being.

Returns:
number of processed items

appendToBuffer

public abstract StringBuffer appendToBuffer(StringBuffer buf)
Serialize a description into a String buffer.

Specified by:
appendToBuffer in interface Progress
Parameters:
buf - Buffer to serialize to
Returns:
Buffer the data was serialized to.

toString

public String toString()
Returns a String representation of the progress suitable as a message for printing to the command line interface.

Specified by:
toString in interface Progress
Overrides:
toString in class Object
See Also:
Object.toString()

incrementProcessed

public void incrementProcessed()
Increment the processed counter.


incrementProcessed

public void incrementProcessed(Logging logger)
Increment the processed counter.

Parameters:
logger - Logger to report to.

testLoggingRate

protected boolean testLoggingRate()
Logging rate control.

Returns:
true when logging is sensible

Release 0.4.0 (2011-09-20_1324)