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

java.lang.Object
  extended by uk.ac.lancs.relate.trigger.conditions.Condition
      extended by uk.ac.lancs.relate.trigger.conditions.QuantifierCondition
All Implemented Interfaces:
java.io.Serializable

public class QuantifierCondition
extends Condition

Condition which considers spatial relationships between two or more trackables.

Author:
Sara Streng
See Also:
Serialized Form

Constructor Summary
QuantifierCondition(Application app, java.lang.String id1, java.lang.String id2)
          Creates a new trackable condition, meaning a condition which considers spatial relationships between two or more trackables.
 
Method Summary
 void defineActiveTrackable()
          This method defines part of what should be done before evaluating a condition.
 void defineInvolvedTrackables()
          Defines all trackables that are involved in this condition.
 boolean evaluate()
          Return true if the condition is fulfilled, else false.
 boolean evaluateFor2(Trackable t1, Trackable t2)
          Return true if the condition is fulfilled for the combination of two trackables, else false.
 boolean resolveQuantifiers()
          The id2 can also be '*', 'ALL' or 'ANY', for example 'if all users are out of the zone ...'.
 
Methods inherited from class uk.ac.lancs.relate.trigger.conditions.Condition
addInvolvedTrackable, addInvolvedTrackable, getActiveTrackable, getApp, getInvolvedTrackables, getTrackableById, setActiveTrackable, setApp, setInvolvedTrackables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuantifierCondition

public QuantifierCondition(Application app,
                           java.lang.String id1,
                           java.lang.String id2)
Creates a new trackable condition, meaning a condition which considers spatial relationships between two or more trackables. 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.

Parameters:
app - application
id1 - unique id of the active trackable, normally the user
id2 - unique id of the passive trackable, e.g. a device, '*' = 'ANY' or 'ALL'
Method Detail

evaluate

public boolean evaluate()
Return true if the condition is fulfilled, else false.

Specified by:
evaluate in class Condition
Returns:
true if the condition is fulfilled, else false

evaluateFor2

public boolean evaluateFor2(Trackable t1,
                            Trackable t2)
Return true if the condition is fulfilled for the combination of two trackables, else false.

Parameters:
t1 - active trackable, usually the user
t2 - passive trackable, usually the device
Returns:
true if the condition is fulfilled for 2 trackables

resolveQuantifiers

public boolean resolveQuantifiers()
The id2 can also be '*', 'ALL' or 'ANY', for example 'if all users are out of the zone ...'. This method resolves these quantifiers, gets the corresponding trackables from the application and calls the evaluateFor2() method of the sub class to evaluate the for all combinations of 2 individual trackables.

Returns:
true if the condition is fulfilled with respect to the quantifiers, else false

defineInvolvedTrackables

public void defineInvolvedTrackables()
Defines all trackables that are involved in this condition.

Specified by:
defineInvolvedTrackables in class Condition

defineActiveTrackable

public void defineActiveTrackable()
Description copied from class: Condition
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.

Specified by:
defineActiveTrackable in class Condition