Holger's
Java API

com.antelmann.util
Class DelayedTask

java.lang.Object
  extended by com.antelmann.util.DelayedTask
All Implemented Interfaces:
Wrapped<Task<?>>

public class DelayedTask
extends Object
implements Wrapped<Task<?>>

a utility class to define a delayed task while allowing to easily postpone the execution at any time to the full delay time. This is particularly suitable for automatic logouts after a certain time of inaction.

Since:
20.06.2014, 19:27:04
Author:
holger

Constructor Summary
DelayedTask(ActionListener al, long delay)
          runs the given ActionListener in the event thread
DelayedTask(Runnable r, long delay)
           
DelayedTask(Task<?> task, long delay)
           
 
Method Summary
 void cancel()
           
 void close()
          cancels this instance while ignoring exceptions thrown
 void delay()
           
 void delay(long delayTime)
           
 Exception getException()
           
 long getTimeUntilExecution()
           
 boolean hasRun()
           
 boolean isRunning()
           
 Task<?> unwrap()
          returns the embedded instance that this wrapper encloses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelayedTask

public DelayedTask(ActionListener al,
                   long delay)
runs the given ActionListener in the event thread


DelayedTask

public DelayedTask(Runnable r,
                   long delay)

DelayedTask

public DelayedTask(Task<?> task,
                   long delay)
Method Detail

unwrap

public Task<?> unwrap()
Description copied from interface: Wrapped
returns the embedded instance that this wrapper encloses

Specified by:
unwrap in interface Wrapped<Task<?>>

delay

public final void delay()
                 throws IllegalStateException
Throws:
IllegalStateException

delay

public final void delay(long delayTime)
                 throws IllegalStateException
Throws:
IllegalStateException

close

public void close()
cancels this instance while ignoring exceptions thrown


cancel

public void cancel()
            throws IllegalStateException
Throws:
IllegalStateException

getTimeUntilExecution

public long getTimeUntilExecution()

hasRun

public final boolean hasRun()

isRunning

public final boolean isRunning()

getException

public final Exception getException()
                             throws IllegalStateException
Throws:
IllegalStateException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads