Package net.ssehub.easy.basics.progress
Class ProgressObserver
- java.lang.Object
-
- net.ssehub.easy.basics.progress.ProgressObserver
-
- Direct Known Subclasses:
EclipseProgressObserver,EclipseProgressObserver
public abstract class ProgressObserver extends java.lang.ObjectObserves the progress of a longer lasting task.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceProgressObserver.ISubtaskMarker interface for a subtask.static interfaceProgressObserver.ITaskMarker interface for a task.
-
Field Summary
Fields Modifier and Type Field Description static ProgressObserverNO_OBSERVERDefines an observer which does nothing.static ProgressObserver.ISubtaskNO_SUBTASKDenotes the empty subtask.
-
Constructor Summary
Constructors Constructor Description ProgressObserver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidnotifyEnd(ProgressObserver.ITask task)Notifies about ending a (sub)task.abstract voidnotifyEnd(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask)Notifies about ending a (sub)task.voidnotifyProgress(ProgressObserver.ITask task, int step)Notifies about processing a task or a subtask.voidnotifyProgress(ProgressObserver.ITask task, int step, int max)Notifies about processing a task or a subtask.voidnotifyProgress(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask, int step)Notifies about processing a task or a subtask.abstract voidnotifyProgress(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask, int step, int max)Notifies about processing a task or a subtask.voidnotifyStart(ProgressObserver.ITask task, int max)Notifies about starting a task.abstract voidnotifyStart(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask, int max)Notifies about starting a (sub)task.abstract ProgressObserver.ISubtaskregisterSubtask(java.lang.String subtask)Registers a subtask to notify about processing progress.abstract ProgressObserver.ITaskregisterTask(java.lang.String task)Registers a task for notify about processing progress.
-
-
-
Field Detail
-
NO_SUBTASK
public static final ProgressObserver.ISubtask NO_SUBTASK
Denotes the empty subtask.
-
NO_OBSERVER
public static final ProgressObserver NO_OBSERVER
Defines an observer which does nothing. Avoids a lot of if-then-else constructs.
-
-
Method Detail
-
registerTask
public abstract ProgressObserver.ITask registerTask(java.lang.String task)
Registers a task for notify about processing progress.- Parameters:
task- the name of the task- Returns:
- the task identification
-
registerSubtask
public abstract ProgressObserver.ISubtask registerSubtask(java.lang.String subtask)
Registers a subtask to notify about processing progress.- Parameters:
subtask- the name of the sub task- Returns:
- the task identification
-
notifyStart
public void notifyStart(ProgressObserver.ITask task, int max)
Notifies about starting a task.- Parameters:
task- the identification of task to notify about (initially useregisterTask(String)for registering a task)max- the intended maximum steps of the subtask
-
notifyStart
public abstract void notifyStart(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask, int max)
Notifies about starting a (sub)task. Subtask notifications shall occur after task notifications, i.e. nested.- Parameters:
task- the identification of task to notify about (initially useregisterTask(String)for registering a task)subtask- the subtask (may beNO_SUBTASK) (initially useregisterSubtask(String)for registering a sub task)max- the intended maximum steps of the subtask
-
notifyProgress
public void notifyProgress(ProgressObserver.ITask task, int step, int max)
Notifies about processing a task or a subtask.- Parameters:
task- the identification of the task to notify about (initially useregisterTask(String)for registering a task)step- the current step in 0<=step<=maxmax- the maximum number of steps, ignored if negative and value from start notification is used instead
-
notifyProgress
public void notifyProgress(ProgressObserver.ITask task, int step)
Notifies about processing a task or a subtask.- Parameters:
task- the identification of the task to notify about (initially useregisterTask(String)for registering a task)step- the current step in 0<=step<=max
-
notifyProgress
public void notifyProgress(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask, int step)
Notifies about processing a task or a subtask.- Parameters:
task- the identification of the task to notify about (initially useregisterTask(String)for registering a task)subtask- the identification of the subtask (may beNO_SUBTASK, initially useregisterSubtask(String)for registering a sub task)step- the current step in 0<=step<=max
-
notifyProgress
public abstract void notifyProgress(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask, int step, int max)
Notifies about processing a task or a subtask.- Parameters:
task- the identification of the task to notify about (initially useregisterTask(String)for registering a task)subtask- the identification of the subtask (may beNO_SUBTASK, initially useregisterSubtask(String)for registering a sub task)step- the current step in 0<=step<=maxmax- the maximum number of steps, ignored if negative and value from start notification is used instead
-
notifyEnd
public void notifyEnd(ProgressObserver.ITask task)
Notifies about ending a (sub)task. Subtask notifications shall occur before task notifications, i.e. correctly nested. Use the identifications returned byregisterTask(String)andregisterSubtask(String). This method shall implicitly unregister the given task and/or subtask.- Parameters:
task- the identification of the task which ends (initially useregisterTask(String)for registering a task)
-
notifyEnd
public abstract void notifyEnd(ProgressObserver.ITask task, ProgressObserver.ISubtask subtask)
Notifies about ending a (sub)task. Subtask notifications shall occur before task notifications, i.e. correctly nested. Use the identifications returned byregisterTask(String)andregisterSubtask(String). This method shall implicitly unregister the given task and/or subtask.- Parameters:
task- the identification of the task which ends (initially useregisterTask(String)for registering a task)subtask- the identification of the subtask withtask(may be <NO_SUBTASK, if given, only the subtask is supposed to end, initially useregisterSubtask(String)for registering a sub task)
-
-