Class ProgressObserver

java.lang.Object
net.ssehub.easy.basics.progress.ProgressObserver
Direct Known Subclasses:
BasicProgressObserver

public abstract class ProgressObserver extends Object
Observes the progress of a longer lasting task.
Author:
Holger Eichelberger
  • Field Details

    • 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.
  • Constructor Details

    • ProgressObserver

      public ProgressObserver()
  • Method Details

    • registerTask

      public abstract ProgressObserver.ITask registerTask(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(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 use registerTask(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 use registerTask(String) for registering a task)
      subtask - the subtask (may be NO_SUBTASK) (initially use registerSubtask(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 use registerTask(String) for registering a task)
      step - the current step in 0<=step<=max
      max - 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 use registerTask(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 use registerTask(String) for registering a task)
      subtask - the identification of the subtask (may be NO_SUBTASK, initially use registerSubtask(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 use registerTask(String) for registering a task)
      subtask - the identification of the subtask (may be NO_SUBTASK, initially use registerSubtask(String) for registering a sub task)
      step - the current step in 0<=step<=max
      max - 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 by registerTask(String) and registerSubtask(String). This method shall implicitly unregister the given task and/or subtask.
      Parameters:
      task - the identification of the task which ends (initially use registerTask(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 by registerTask(String) and registerSubtask(String). This method shall implicitly unregister the given task and/or subtask.
      Parameters:
      task - the identification of the task which ends (initially use registerTask(String) for registering a task)
      subtask - the identification of the subtask with task (may be NO_SUBTASK, if given, only the subtask is supposed to end, initially use registerSubtask(String) for registering a sub task)