Code Examples
A repository of 155 code examples for BeepBeep
CutString.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 CutString extends Function
10 {
11  public void evaluate(Object[] inputs, Object[] outputs, Context c, EventTracker t) {
12  outputs[0] = ((String) inputs[0]).substring(0,
13  (Integer) inputs[1]);
14  }
15 
16  public int getInputArity() {
17  return 2;
18  }
19 
20  public int getOutputArity() {
21  return 1;
22  }
23 
24  public Function duplicate(boolean with_state) {
25  return new CutString();
26  }
27 
28  public void getInputTypesFor(Set<Class<?>> s, int i) {
29  if (i == 0)
30  s.add(String.class);
31  if (i == 1)
32  s.add(Number.class);
33  }
34 
35  public Class<?> getOutputTypeFor(int i) {
36  if (i == 0)
37  return String.class;
38  return null;
39  }
40 }