Code Examples
A repository of 155 code examples for BeepBeep
PlaceholderUsage.java
1 /*
2  BeepBeep, an event stream processor
3  Copyright (C) 2008-2016 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 functions;
19 
20 import ca.uqac.lif.cep.functions.StreamVariable;
21 import ca.uqac.lif.cep.functions.Function;
22 import ca.uqac.lif.cep.functions.FunctionException;
23 
24 /**
25  * Use the {@link ca.uqac.lif.cep.functions.StreamVariable ArgumentPlaceholder}
26  * function to refer to the <i>i</i>-th argument of a function.
27  * @author Sylvain HallĂ©
28  */
29 public class PlaceholderUsage
30 {
31  public static void main(String[] args) throws FunctionException
32  {
33  /* Create an instance of the ArgumentPlaceholder function. This
34  * function simply returns its <i>i</i>-th input argument, with
35  * the value <i>i</i> passed to the constructor. Indices start
36  * at zero. */
37  Function foo = StreamVariable.Y;
38  Object values[] = new Object[1];
39 
40  /* A constant does not need any argument; we may pass
41  * an empty array, or simply null. */
42  Object inputs[] = new Object[]{42, "foo"};
43  foo.evaluate(inputs, values);
44  String s_value = (String) values[0]; // = "foo"
45  System.out.printf("The value of foo is %s\n", s_value);
46  }
47 }
Use the ArgumentPlaceholder function to refer to the i-th argument of a function. ...