uk.ac.lancs.relate.trigger.conditions
Class Condition

java.lang.Object
  extended by uk.ac.lancs.relate.trigger.conditions.Condition
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AlwaysTrueAllTrackablesInvolved, QuantifierCondition, ZoneCondition

public abstract class Condition
extends java.lang.Object
implements java.io.Serializable

A condition contains a evaluate method, which returns a boolean expression. The evaluate method must not have any parameters since it is called generically. Thus the parameters have to be set in the constructor of the condition object. The condition object partly redesigned in this version. Indeed, it was required in order for since the SCT (Spatial Condition Toolkit) to accept rules based on runtime objects (Trackables) instead of compile time Trackables as it was before the refactoring process.

Author:
Sara Streng and Dominique Guinard
Personal Homepage
See Also:
Serialized Form

Constructor Summary
Condition()
           
 
Method Summary
protected  void addInvolvedTrackable(java.lang.String id)
          Adds a trackable to the list of objects that play a role in this condition.
 void addInvolvedTrackable(Trackable trackable)
          Adds a trackable to the list of objects that play a role in this condition.
abstract  void defineActiveTrackable()
          This method defines part of what should be done before evaluating a condition.
abstract  void defineInvolvedTrackables()
          This method defines part of what should be done before evaluating a condition.
abstract  boolean evaluate()
          This method defines the condition.
 Trackable getActiveTrackable()
          Returns the active activeTrackable, normally the user.
 Application getApp()
          Get the application needed to provide access to all other trackables.
 java.util.ArrayList<Trackable> getInvolvedTrackables()
          Returns a list of all trackables that play a role in this condition
protected  Trackable getTrackableById(java.lang.String id)
          Gets the Trackable corresponding to the provided id.
protected  void setActiveTrackable(java.lang.String id)
          Sets the active activeTrackable, normally the user.
 void setApp(Application app)
          Set the application needed to provide access to all other trackables.
protected  void setInvolvedTrackables(java.util.ArrayList<Trackable> involvedTrackables)
          Sets the list of all trackables that play a role in this condition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition

public Condition()
Method Detail

evaluate

public abstract boolean evaluate()
This method defines the condition. If the condition is fulfilled, true is returned, else false. This method is automatically called by the toolkit.

Returns:
true if condition is fulfilled

defineInvolvedTrackables

public abstract void defineInvolvedTrackables()
This method defines part of what should be done before evaluating a condition. i.e. Defining the involved trackables. defineInvolvedTrackables() is automatically called by this class in the getActiveTrackable() method. It is to be implemented by subclasses since these know which trackables should be active at run time. This method is the core of the SCT's refactoring to make it dynamic. It enables the programmer to list of trackables involved in the condition at runtime instead of compile time.


defineActiveTrackable

public abstract void defineActiveTrackable()
This method defines part of what should be done before evaluating a condition. i.e. Defining the active trackables. This method is automatically called by this class in the getActiveTrackable() method. It is to be implemented by subclasses since these know which trackables should be active at run time. This method is the core of the SCT's refactoring to make it dynamic. It enables the programmer to list of trackables involved in the condition at runtime instead of compile time.


getApp

public Application getApp()
Get the application needed to provide access to all other trackables.


setApp

public void setApp(Application app)
Set the application needed to provide access to all other trackables.


getActiveTrackable

public Trackable getActiveTrackable()
Returns the active activeTrackable, normally the user.

Returns:
active activeTrackable, normally the user

setActiveTrackable

protected void setActiveTrackable(java.lang.String id)
Sets the active activeTrackable, normally the user.

Parameters:
id - of the active activeTrackable, normally the user

getInvolvedTrackables

public java.util.ArrayList<Trackable> getInvolvedTrackables()
Returns a list of all trackables that play a role in this condition

Returns:
list of all involved trackables

setInvolvedTrackables

protected void setInvolvedTrackables(java.util.ArrayList<Trackable> involvedTrackables)
Sets the list of all trackables that play a role in this condition

Parameters:
involvedTrackables - involved trackables

addInvolvedTrackable

protected void addInvolvedTrackable(java.lang.String id)
Adds a trackable to the list of objects that play a role in this condition.

Parameters:
id - of the trackable to add.

addInvolvedTrackable

public void addInvolvedTrackable(Trackable trackable)
Adds a trackable to the list of objects that play a role in this condition.

Parameters:
trackable - trackable to add to the list

getTrackableById

protected Trackable getTrackableById(java.lang.String id)
Gets the Trackable corresponding to the provided id.

Parameters:
unique - identifier of the trackable