de.esprit.appsuite.task

## Class TaskUtil

- java.lang.Object
- - de.esprit.appsuite.task.TaskUtil

-     public class TaskUtil
      extends java.lang.Object

  This utility class provides static helper methods for the `AsyncTask` framework.
  Author:
    Rainer Buesch

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `checkAndRethrowNonErrorExceptions(java.lang.Exception e)` Rethrows the Exception if it is one of `StopException`, `InterruptedException` or `CancellationException`.
    `static void` | `checkForErrorAndRethrow(RunStateFlag stateFlag, java.lang.Exception e)` Used to store an Error (if any) or a cancellation in the given `RunStateFlag`.
    `static SwingTaskMonitor` | `fetchSwingTaskMonitor(AsyncTask task)` Fetches the `SwingTaskMonitor` of the given task.
    `static SwingTaskMonitor` | `findSwingTaskMonitor(AsyncTask task)` Tries to find a `SwingTaskMonitor` in the monitors of the given task.
    `static SwingTaskMonitor` | `findSwingTaskMonitor(TaskMonitor[] monitors)` Tries to find a `SwingTaskMonitor` in the given monitor array.
    `static boolean` | `isCancellationException(java.lang.Exception e)`
    `static RunState` | `resultingRunStateOf(RunStateFlag flag)` Return the resulting `RunState` of a `RunStateFlag` of a finished task.
    `static void` | `sleepChecked(AsyncExecutable task, long millis)` Puts the calling thread to sleep for millis.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### checkForErrorAndRethrow

          public static void checkForErrorAndRethrow(RunStateFlag stateFlag,
                                     java.lang.Exception e)
                                              throws java.lang.Exception

      Used to store an Error (if any) or a cancellation in the given `RunStateFlag`. Note that `CancellationException`. `InterruptedException` and `StopException` are NOT considered to be an error. In any case the given Exception is rethrown.
      Throws:
        `java.lang.Exception`

    - #### checkAndRethrowNonErrorExceptions

          public static void checkAndRethrowNonErrorExceptions(java.lang.Exception e)
                                                        throws java.lang.Exception

      Rethrows the Exception if it is one of `StopException`, `InterruptedException` or `CancellationException`.
      Throws:
        `java.lang.Exception`

    - #### isCancellationException

          public static boolean isCancellationException(java.lang.Exception e)

    - #### fetchSwingTaskMonitor

          public static SwingTaskMonitor fetchSwingTaskMonitor(AsyncTask task)

      Fetches the `SwingTaskMonitor` of the given task.
      Throws:
        `ProgrammingErrorException` - if the task does not have a SwingTaskMonitor

    - #### findSwingTaskMonitor

          public static SwingTaskMonitor findSwingTaskMonitor(AsyncTask task)

      Tries to find a `SwingTaskMonitor` in the monitors of the given task.

    - #### findSwingTaskMonitor

          public static SwingTaskMonitor findSwingTaskMonitor(TaskMonitor[] monitors)

      Tries to find a `SwingTaskMonitor` in the given monitor array.

    - #### sleepChecked

          public static void sleepChecked(AsyncExecutable task,
                          long millis)

      Puts the calling thread to sleep for millis. Before and after sleep the isCancelled state of the task is checked and a `CancellationException` is thrown just in case.

    - #### resultingRunStateOf

          public static RunState resultingRunStateOf(RunStateFlag flag)

      Return the resulting `RunState` of a `RunStateFlag` of a finished task.

Copyright © 2014 EsprIT-Systems. All Rights Reserved.