Code Examples
A repository of 155 code examples for BeepBeep
CustomDouble.java
1 package functions.custom;
2 
3 import java.util.Set;
4 
5 import ca.uqac.lif.cep.Context;
6 import ca.uqac.lif.cep.EventTracker;
7 import ca.uqac.lif.cep.functions.Function;
8 
9 public class CustomDouble extends Function
10 {
11  @Override
12  public void evaluate(Object[] inputs, Object[] outputs, Context c, EventTracker t)
13  {
14  Number n = (Number) inputs[0];
15  outputs[0] = n.floatValue() * 2;
16  }
17 
18  //!
19  @Override
20  public int getInputArity()
21  {
22  return 1;
23  }
24 
25  @Override
26  public int getOutputArity()
27  {
28  return 1;
29  }
30 
31  @Override
32  public Function duplicate(boolean with_state)
33  {
34  return new CustomDouble();
35  }
36  //!
37 
38  @Override
39  public void getInputTypesFor(Set<Class<?>> s, int i)
40  {
41  if (i == 0)
42  s.add(Number.class);
43  }
44 
45  @Override
46  public Class<?> getOutputTypeFor(int i)
47  {
48  if (i == 0)
49  return Number.class;
50  return null;
51  }
52 
53 }