Code Examples
A repository of 155 code examples for BeepBeep
ContextExample.java
1
/*
2
BeepBeep, an event stream processor
3
Copyright (C) 2008-2017 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
basic;
19
20
import
ca.uqac.lif.cep.Connector;
21
import
ca.uqac.lif.cep.Pushable;
22
import
ca.uqac.lif.cep.functions.ApplyFunction;
23
import
ca.uqac.lif.cep.functions.ContextVariable;
24
import
ca.uqac.lif.cep.functions.FunctionTree;
25
import
ca.uqac.lif.cep.functions.StreamVariable;
26
import
ca.uqac.lif.cep.io.Print;
27
import
ca.uqac.lif.cep.util.Numbers;
28
29
/**
30
* Use a processor's {@link ca.uqac.lif.cep.Context Context} object.
31
* @author Sylvain Hallé
32
*/
33
public
class
ContextExample
34
{
35
public
static
void
main(String[] args)
36
{
37
///
38
ApplyFunction af =
new
ApplyFunction(
new
FunctionTree(
39
Numbers.addition,
40
StreamVariable.X,
41
new
ContextVariable(
"foo"
)));
42
Connector.connect(af,
new
Print());
43
af.setContext(
"foo"
, 10);
44
Pushable p = af.getPushableInput();
45
p.push(3);
46
af.setContext(
"foo"
, 6);
47
p.push(4);
48
///
49
}
50
}
basic.ContextExample
Use a processor's Context object.
Definition:
ContextExample.java:33
Source
src
basic
ContextExample.java
Generated by
1.8.13