Defining advanced event expressions
An event template is the simplest form of an event expression. All event expression operators, including ->, can themselves take entire event expressions as operands.
It is useful to think of event expressions as being Boolean expressions. Each clause in an event expression can be true or false, and the whole event expression must evaluate to true before the listener triggers and calls the match listener’s match method.
As before, for the sake of brevity, let us use the letters A, B, C and D to represent event templates, and A’, B’, C’ and D’ to represent individual events that match those templates, respectively.
Once more, consider this representation of an event expression,
A -> B -> C -> D
When the listener is first activated it is helpful to consider the expression as starting off by being false. When an event that satisfies the
A clause occurs, the
A clause becomes true. Once
B is satisfied,
A -> B becomes true in turn, and evaluation progresses in a similar manner until eventually all
A -> B -> C -> D evaluates to true. Only then does the listener trigger and call the associated match listener’s
match method. Of course, this event expression might never become true in its entirety (as the events required might never occur) since no time constraint (see
Specifying the timer operators) has been applied to any part of the event expression.