Code Examples
A repository of 155 code examples for BeepBeep
stockticker.LandmarkQuery Class Reference

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Definition at line 41 of file LandmarkQuery.java.

Member Function Documentation

◆ main()

static void stockticker.LandmarkQuery.main ( String []  args)
static

On each list, check if MSFT is greater than 50

Definition at line 43 of file LandmarkQuery.java.

44  {
45  ///
46  TickerFeed feed = new TickerFeed(10, 20);
47  Fork fork1 = new Fork(2);
48  Connector.connect(feed, fork1);
49  Filter filter = new Filter();
50  Connector.connect(fork1, 0, filter, 0);
51  ApplyFunction gt_100 = new ApplyFunction(
52  new FunctionTree(Numbers.isGreaterThan,
53  new FunctionTree(
54  Numbers.numberCast, new NthElement(0)),
55  new Constant(10)));
56  Connector.connect(fork1, 1, gt_100, 0);
57  Connector.connect(gt_100, 0, filter, 1);
58  Fork fork2 = new Fork(3);
59  Connector.connect(filter, fork2);
60  Lists.Pack pack = new Lists.Pack();
61  Connector.connect(fork2, 0, pack, 0);
62  Trim trim = new Trim(1);
63  Connector.connect(fork2, 1, trim, 0);
64  ApplyFunction eq = new ApplyFunction(new FunctionTree(Booleans.not,
65  new FunctionTree(Equals.instance,
66  new FunctionTree(new NthElement(0), StreamVariable.X),
67  new FunctionTree(new NthElement(0), StreamVariable.Y))));
68  Connector.connect(trim, 0, eq, 0);
69  Connector.connect(fork2, 2, eq, 1);
70  Insert insert = new Insert(1, false);
71  Connector.connect(eq, insert);
72  Connector.connect(insert, 0, pack, 1);
73  ///
74 
75  //! On each list, check if MSFT is greater than 50
76  GroupProcessor gp = new GroupProcessor(1, 1);
77  ApplyFunction ms_50 = new ApplyFunction(
78  new FunctionTree(Booleans.implies,
79  new FunctionTree(
80  Equals.instance,
81  new Constant("MSFT"),
82  new FunctionTree(
83  new NthElement(1), StreamVariable.X)),
84  new FunctionTree(Numbers.isGreaterThan,
85  new FunctionTree(
86  new NthElement(2), StreamVariable.X),
87  new Constant(250))));
88  gp.addProcessor(ms_50);
89  gp.associateInput(0, ms_50, 0);
90  Cumulate c_50 = new Cumulate(
91  new CumulativeFunction<Boolean>(Booleans.and));
92  Connector.connect(ms_50, c_50);
93  gp.addProcessor(c_50);
94  gp.associateOutput(0, c_50, 0);
95  Bags.RunOn ro = new Bags.RunOn(gp);
96  Fork fork3 = new Fork(2);
97  Connector.connect(pack, fork3);
98  Filter f_ms_50 = new Filter();
99  Connector.connect(fork3, 0, f_ms_50, 0);
100  Connector.connect(fork3, 1, ro, 0);
101  Connector.connect(ro, 0, f_ms_50, 1);
102 
103  // Unpack each day into separate events
104  Lists.Unpack up = new Lists.Unpack();
105  Connector.connect(f_ms_50, up);
106  //!
107 
108  Pullable p = up.getPullableOutput();
109  while (p.hasNext())
110  {
111  System.out.println(UtilityMethods.print(p.pull()));
112  }
113  }

The documentation for this class was generated from the following file: