frysk.proc.live
Class TaskObservation

java.lang.Object
  extended by frysk.proc.Observation
      extended by frysk.proc.live.TaskObservation
All Implemented Interfaces:
Event

public abstract class TaskObservation
extends Observation

The binding between an Observer and its Observable.


Field Summary
private  Runnable action
           
private  boolean adding
           
private  LiveTask task
           
 
Fields inherited from class frysk.proc.Observation
observable, observer
 
Constructor Summary
TaskObservation(LiveTask task, TaskObservable observable, TaskObserver observer, boolean adding)
           
TaskObservation(LiveTask task, TaskObservable observable, TaskObserver observer, Runnable action, boolean adding)
          Create a new Observer binding.
 
Method Summary
 void add()
          Runs any action (if suplied) and then adds the observer to the observable.
 void delete()
          Deletes the observer from the observable and then runs any action (if suplied).
 TaskObservable getTaskObservable()
           
 TaskObserver getTaskObserver()
           
 void handleAdd()
          Handle adding the Observer to the Observable.
 void handleDelete()
          Handle deleting the Observer from the Observable.
 boolean isAddition()
          Returns true if this is an addition, false if it is a deletion.
 boolean needsSuspendedAction()
          Returns true if an action was supplied to the constructor to be run when the Task is (temporarily) suspended.
 
Methods inherited from class frysk.proc.Observation
equals, fail, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface frysk.event.Event
execute
 

Field Detail

task

private final LiveTask task

action

private final Runnable action

adding

private final boolean adding
Constructor Detail

TaskObservation

public TaskObservation(LiveTask task,
                       TaskObservable observable,
                       TaskObserver observer,
                       boolean adding)

TaskObservation

public TaskObservation(LiveTask task,
                       TaskObservable observable,
                       TaskObserver observer,
                       Runnable action,
                       boolean adding)
Create a new Observer binding.

Parameters:
task - The Task the observer will be added to.
observable - The TaskObservable (of the specified task) that the observer should be added to.
observer - The TaskObserver to add.
action - An action to run, or null if none, before adding or after deletion while the Task is (temporarily) suspended.
Method Detail

handleAdd

public void handleAdd()
Handle adding the Observer to the Observable. The Task should call add() when it is actually ready to bind the observer to the observable.

Specified by:
handleAdd in class Observation
See Also:
needsSuspendedAction()

handleDelete

public void handleDelete()
Handle deleting the Observer from the Observable. The Task should call delete() when it is actually ready to bind the observer to the observable.

Specified by:
handleDelete in class Observation
See Also:
needsSuspendedAction()

getTaskObservable

public TaskObservable getTaskObservable()

getTaskObserver

public TaskObserver getTaskObserver()

isAddition

public boolean isAddition()
Returns true if this is an addition, false if it is a deletion.


needsSuspendedAction

public boolean needsSuspendedAction()
Returns true if an action was supplied to the constructor to be run when the Task is (temporarily) suspended. If this method returns true then the Task should be suspended before calling add() or delete() on this TaskObservation.


add

public void add()
Runs any action (if suplied) and then adds the observer to the observable. If needsSuspendedAction() returns true then this method should only be called if the Task is (temporarily) suspended.


delete

public void delete()
Deletes the observer from the observable and then runs any action (if suplied). If needsSuspendedAction() returns true then this method should only be called if the Task is (temporarily) suspended.