Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class AbstractPollableRunnable

java.lang.Object
  extended by com.jivesoftware.util.AbstractPollableRunnable
All Implemented Interfaces:
PollableRunnable, java.io.Serializable, java.lang.Runnable
Direct Known Subclasses:
AbstractReportRunner, AttachmentUpgradeTask, DbDataExport, DbDataImport, QuickStats.QuickStatsGenerator, WikiSyntaxEscapeTask

public abstract class AbstractPollableRunnable
extends java.lang.Object
implements PollableRunnable, java.io.Serializable

An abstract implementation of the PollableRunnable interface. This preconfigures a 0->100 determinate progress meter and has a simple implementation of the run() method.

Developers need only to override the getTaskValue() method and the doRun() method.

See Also:
Serialized Form

Constructor Summary
AbstractPollableRunnable()
           
 
Method Summary
 void cancel()
          Not implemented in this implementation.
abstract  void doRun()
          Executes the logic of the task.
 java.util.Date getEndDate()
          Returns the date the task ended.
 double getPercentComplete()
          Returns the percent complete of the task as a double value between 0.0 and 100.0.
 java.util.Date getStartDate()
          Returns the date the task was started.
 int getTaskMaximum()
          Returns the maximum value of task progress (default is 100).
 int getTaskMinimum()
          Returns the minimum value of task progress (default is 0).
abstract  int getTaskValue()
          Returns the current value of the task's progress.
 boolean isFinished()
          A simple call back method which will be called when the task has completed.
 boolean isIndeterminate()
          Returns true if we are unable to determine the progress being made, false othewise.
 boolean isRunning()
          Returns true if the task is running, false otherwise.
 void run()
          A simple implementation of the Runnable.run() method which sets this task's running status to true then calls the abstract method doRun().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPollableRunnable

public AbstractPollableRunnable()
Method Detail

isRunning

public boolean isRunning()
Description copied from interface: PollableRunnable
Returns true if the task is running, false otherwise.

Specified by:
isRunning in interface PollableRunnable
Returns:
true if the task is running, false otherwise.

getTaskMinimum

public int getTaskMinimum()
Description copied from interface: PollableRunnable
Returns the minimum value of task progress (default is 0). If this is in indeterminate mode then this will return -1.

Specified by:
getTaskMinimum in interface PollableRunnable
Returns:
the minimum value of task progress.

getTaskMaximum

public int getTaskMaximum()
Description copied from interface: PollableRunnable
Returns the maximum value of task progress (default is 100). If this is in indeterminate mode then this will return -1.

Specified by:
getTaskMaximum in interface PollableRunnable
Returns:
the maximum value of task progress.

getTaskValue

public abstract int getTaskValue()
Description copied from interface: PollableRunnable
Returns the current value of the task's progress. This will be x where min <= x <= max. If this is in indeterminate mode then this will return -1.

Specified by:
getTaskValue in interface PollableRunnable
Returns:
the current value of the task's progress.

getStartDate

public java.util.Date getStartDate()
Description copied from interface: PollableRunnable
Returns the date the task was started.

Specified by:
getStartDate in interface PollableRunnable
Returns:
the date the task was started.

getEndDate

public java.util.Date getEndDate()
Description copied from interface: PollableRunnable
Returns the date the task ended.

Specified by:
getEndDate in interface PollableRunnable
Returns:
the date the task ended.

getPercentComplete

public double getPercentComplete()
Description copied from interface: PollableRunnable
Returns the percent complete of the task as a double value between 0.0 and 100.0. If this is an indeterminate mode then this will return -1.

Specified by:
getPercentComplete in interface PollableRunnable
Returns:
the percent complete of the task.

isIndeterminate

public boolean isIndeterminate()
Description copied from interface: PollableRunnable
Returns true if we are unable to determine the progress being made, false othewise. This is useful to use when progress can't be determined but some indication of activity needs to be displayed.

Specified by:
isIndeterminate in interface PollableRunnable
Returns:
true if we are unable to determine the progress being made, false othewise.

isFinished

public boolean isFinished()
Description copied from interface: PollableRunnable
A simple call back method which will be called when the task has completed.

Specified by:
isFinished in interface PollableRunnable
Returns:
true if the task is finished, false otherwise.

cancel

public void cancel()
Not implemented in this implementation.

Specified by:
cancel in interface PollableRunnable

run

public final void run()
A simple implementation of the Runnable.run() method which sets this task's running status to true then calls the abstract method doRun(). When doRun() returns it will set the running status to false then call the isFinished() callback.

Note, this method is final so it cannot be subclassed - it will call doRun() which is abstract and must be implemented by subclasses.

Specified by:
run in interface java.lang.Runnable

doRun

public abstract void doRun()
Executes the logic of the task. Errors should be handled by the implementing class as this method does not throw any exceptions.


Jive Forums Project Page

Copyright © 1999-2006 Jive Software.