Code Examples
A repository of 155 code examples for BeepBeep
UnpackPush.java
1 /*
2  BeepBeep, an event stream processor
3  Copyright (C) 2008-2018 Sylvain HallĂ©
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package util;
19 
20 import java.util.List;
21 
22 import ca.uqac.lif.cep.Connector;
23 import ca.uqac.lif.cep.Pushable;
24 import ca.uqac.lif.cep.UtilityMethods;
25 import ca.uqac.lif.cep.io.Print;
26 import ca.uqac.lif.cep.util.Lists;
27 
28 /**
29  * See the effect of using the
30  * {@link ca.uqac.lif.cep.util.Lists.Unpack Unpack} processor in push mode.
31  * Graphically, this chain of processors can be represented as:
32  * <p>
33  * <img src="./doc-files/util/UnpackPush.png" alt="Processor graph">
34 * <p>
35  * The output of this program is:
36  * <pre>
37  * Before first push
38  * 1,2,3,4,
39  * Before second push
40  * 5,6,7,
41  * After second push
42  * </pre>
43  *
44  * @author Sylvain HallĂ©
45  * @difficulty Easy
46  */
47 public class UnpackPush
48 {
49  public static void main(String[] args)
50  {
51  Lists.Unpack unpack = new Lists.Unpack();
52  Print print = new Print();
53  Connector.connect(unpack, print);
54  Pushable p = unpack.getPushableInput();
55  ///
56  List<Object> list = UtilityMethods.createList(1, 2, 3, 4);
57  System.out.println("Before first push");
58  p.push(list);
59  list = UtilityMethods.createList(5, 6, 7);
60  System.out.println("\nBefore second push");
61  p.push(list);
62  System.out.println("\nAfter second push");
63  ///
64  }
65 }
See the effect of using the Unpack processor in push mode.
Definition: UnpackPush.java:47