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.ApplyFunction;
27 import ca.uqac.lif.cep.tmf.Filter;
28 import ca.uqac.lif.cep.tmf.Fork;
29 import ca.uqac.lif.cep.tmf.QueueSource;
30 import ca.uqac.lif.cep.util.Numbers;
43 public static void main(String[] args)
46 QueueSource source_values =
new QueueSource();
47 source_values.setEvents(6, 5, 3, 8, 9, 2, 1, 7, 4);
49 Fork fork =
new Fork(2);
50 connect(source_values, fork);
52 Filter filter =
new Filter();
53 connect(fork, LEFT, filter, LEFT);
55 ApplyFunction condition =
new ApplyFunction(Numbers.isEven);
57 connect(fork, RIGHT, condition, INPUT);
59 connect(condition, OUTPUT, filter, RIGHT);
61 Pullable p = filter.getPullableOutput();
64 for (
int i = 0; i < 4; i++)
66 int x = (Integer) p.pull();
67 System.out.printf(
"Output event #%d is %d\n", i, x);
static void main(String[] args)
Filter a trace by evaluating a simple condition on the events of that trace.