net.sf.jomic.tools
Class AbstractTask

java.lang.Object
  extended by net.sf.jomic.tools.AbstractTask
All Implemented Interfaces:
Task
Direct Known Subclasses:
AbstractCreateComicTask, ConvertComicTask, ConvertImageTask, CopyFileTask, CreateComicTask, CreateImagInfoMapTask, CreateZipArchiveTask, ExtractComicTask, ExtractPdfImagesTask, ExtractRarTask, ExtractZipTask, NestedTask

public abstract class AbstractTask
extends java.lang.Object
implements Task

Base for a Task already handling progress related issues.

Author:
Thomas Aglassinger

Constructor Summary
protected AbstractTask()
           
 
Method Summary
 void addProgressChangeListener(ProgressChangeListener newListener)
           
 long getMaxProgress()
           
 long getProgress()
           
 java.lang.String getProgressMessage()
          Get a message describing the current progress, for example "Rendering hugo.png".
protected  boolean isInterrupted()
          Return true if the current thread was interrupted.
 void removeProgressChangeListener(ProgressChangeListener listenerToRemove)
           
protected  void setMaxProgress(long newMaxProgress)
          Set maximum progress to newMaxProgress.
protected  void setProgress(long newProgress)
          Set progress to newProgress and notify progress listeners of it.
protected  void setProgressMessage(java.lang.String newMessage)
           
abstract  void start()
          Start the task, which will cause the progress to iterate from 0 to getMaximum.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTask

protected AbstractTask()
Method Detail

setMaxProgress

protected final void setMaxProgress(long newMaxProgress)
Set maximum progress to newMaxProgress. This should only be called from the constructor.


setProgress

protected void setProgress(long newProgress)
Set progress to newProgress and notify progress listeners of it.


setProgressMessage

protected void setProgressMessage(java.lang.String newMessage)

getMaxProgress

public long getMaxProgress()
Specified by:
getMaxProgress in interface Task

getProgress

public long getProgress()
Specified by:
getProgress in interface Task

getProgressMessage

public java.lang.String getProgressMessage()
Get a message describing the current progress, for example "Rendering hugo.png". This can not be null.

Specified by:
getProgressMessage in interface Task

isInterrupted

protected boolean isInterrupted()
Return true if the current thread was interrupted.

See Also:
Thread.isInterrupted()

addProgressChangeListener

public void addProgressChangeListener(ProgressChangeListener newListener)
Specified by:
addProgressChangeListener in interface Task

removeProgressChangeListener

public void removeProgressChangeListener(ProgressChangeListener listenerToRemove)
Specified by:
removeProgressChangeListener in interface Task

start

public abstract void start()
                    throws java.lang.Exception
Description copied from interface: Task
Start the task, which will cause the progress to iterate from 0 to getMaximum.

Specified by:
start in interface Task
Throws:
java.lang.Exception