1 | package de.uka.ipd.sdq.pipesandfilters.framework.filters; |
2 | |
3 | import de.uka.ipd.sdq.pipesandfilters.framework.PipeData; |
4 | |
5 | /** |
6 | * A simple filter example for test cases. This filter simply forwards incoming |
7 | * data. It also counts the number of elements he has received. |
8 | * |
9 | * @author pmerkle |
10 | * @author Baum |
11 | */ |
12 | |
13 | public class ExampleFilter extends Filter { |
14 | |
15 | /** |
16 | * This element stores the last pipe data element that arrived. |
17 | */ |
18 | private PipeData lastArrivedData = null; |
19 | |
20 | /** |
21 | * This element stores the number of elements the filter has received. |
22 | */ |
23 | private int receiveCount = 0; |
24 | |
25 | /** |
26 | * The processData method of the ExampleFilter. Incoming data only forwarded |
27 | * to the successive pipe element. No actual filtering is performed. |
28 | */ |
29 | @Override |
30 | public void processData(PipeData data) { |
31 | lastArrivedData = data; |
32 | receiveCount++; |
33 | super.processData(data); |
34 | } |
35 | |
36 | /** |
37 | * Getter method for lastArrivedData. |
38 | * |
39 | * @return the last pipe data element that arrived. |
40 | */ |
41 | public PipeData getLastArrivedData() { |
42 | return lastArrivedData; |
43 | } |
44 | |
45 | /** |
46 | * Returns the number of data elements this filter has received. |
47 | * |
48 | * @return The number of data elements received. |
49 | */ |
50 | public int getReceiveCount() { |
51 | return receiveCount; |
52 | } |
53 | } |