Code Examples
A repository of 155 code examples for BeepBeep
basic.IncorrectPiping Class Reference

Pipe processors with non-matching event types. More...

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Pipe processors with non-matching event types.

Doing this in BeepBeep causes a ConnectorException to be thrown. This example shows what happens in that case. The chain of processors in this example can be represented graphically as:

Processor graph

The expected output of this program should look like this:

Exception in thread "main" ca.uqac.lif.cep.Connector$IncompatibleTypesException:
Cannot connect output 0 of ABS to input 0 of ¬: incompatible types
 at ca.uqac.lif.cep.Connector.checkForException(Connector.java:357)
 at ca.uqac.lif.cep.Connector.connect(Connector.java:148)
 at ca.uqac.lif.cep.Connector.connect(Connector.java:279)
 at ca.uqac.lif.cep.Connector.connect(Connector.java:251)
 at basic.IncorrectPiping.main(IncorrectPiping.java:42)

If we refer to the picture, the exception is raised when attempting to connect the output of the first function processor (turquoise, representing a number) to the input of the second function processor (light blue, representing a Boolean).

Author
Sylvain Hallé Easy

Definition at line 54 of file IncorrectPiping.java.

Member Function Documentation

◆ main()

static void basic.IncorrectPiping.main ( String []  args)
static

Create a simple source with a single numerical event

Definition at line 56 of file IncorrectPiping.java.

57  {
58  /// Create a simple source with a single numerical event
59  QueueSource source = new QueueSource();
60  source.setEvents(3);
61 
62  /* Create a processor that computes the absolute value of a number
63  * and connect it to that source. */
64  Processor av = new ApplyFunction(Numbers.absoluteValue);
65  Connector.connect(source, av);
66 
67  /* Attempt to connect a processor that computes the negation of a
68  * Boolean value to the av processor defined above. This will cause an
69  * exception to be thrown: the output type of av is Number, while the
70  * input type of neg is Boolean. */
71  Processor neg = new ApplyFunction(Booleans.not);
72  Connector.connect(av, neg); // Will throw an exception
73 
74  /* As a result, this line of the program should not be reached, as the
75  * execution will stop with the throwing of a ConnectorException on
76  * the line above. */
77  System.out.println("This line will not be reached");
78  ///
79  }

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