20 import static ca.uqac.lif.cep.Connector.INPUT;
21 import static ca.uqac.lif.cep.Connector.LEFT;
22 import static ca.uqac.lif.cep.Connector.OUTPUT;
23 import static ca.uqac.lif.cep.Connector.RIGHT;
24 import static ca.uqac.lif.cep.Connector.connect;
25 import ca.uqac.lif.cep.Pullable;
26 import ca.uqac.lif.cep.functions.StreamVariable;
27 import ca.uqac.lif.cep.functions.Constant;
28 import ca.uqac.lif.cep.functions.ApplyFunction;
29 import ca.uqac.lif.cep.functions.FunctionTree;
30 import ca.uqac.lif.cep.tmf.Filter;
31 import ca.uqac.lif.cep.tmf.Fork;
32 import ca.uqac.lif.cep.tmf.QueueSource;
33 import ca.uqac.lif.cep.util.Booleans;
34 import ca.uqac.lif.cep.util.Numbers;
50 public static void main(String[] args)
53 QueueSource source_values =
new QueueSource();
54 source_values.setEvents(6, 5, 3, 8, 9, 2, 1, 7, 4, 5,
55 2, 4, 7, 6, 12, 8, 1);
57 Fork fork =
new Fork(2);
58 connect(source_values, fork);
60 Filter filter =
new Filter();
61 connect(fork, LEFT, filter, LEFT);
63 FunctionTree tree =
new FunctionTree(Booleans.and,
65 new FunctionTree(Numbers.isGreaterThan,
68 ApplyFunction condition =
new ApplyFunction(tree);
70 connect(fork, RIGHT, condition, INPUT);
72 connect(condition, OUTPUT, filter, RIGHT);
74 Pullable p = filter.getPullableOutput();
76 for (
int i = 0; i < 4; i++)
78 int x = (Integer) p.pull();
79 System.out.printf(
"Output event #%d is %d\n", i, x);
Filter a trace by evaluating a compound condition on the events of that trace.