1 | package desmoj.core.report; |
2 | |
3 | /** |
4 | * The standard reporter for any reportable object. Its report contains the |
5 | * reportable's name, the simulation time of the last reset and the number of |
6 | * observations made by the reportable. These represent the basic data each |
7 | * reportable can supply. To get more specific information, build a custom |
8 | * reporter for that reportable. |
9 | * |
10 | * @version DESMO-J, Ver. 2.3.3 copyright (c) 2011 |
11 | * @author Tim Lechler |
12 | * |
13 | * Licensed under the Apache License, Version 2.0 (the "License"); |
14 | * you may not use this file except in compliance with the License. You |
15 | * may obtain a copy of the License at |
16 | * http://www.apache.org/licenses/LICENSE-2.0 |
17 | * |
18 | * Unless required by applicable law or agreed to in writing, software |
19 | * distributed under the License is distributed on an "AS IS" |
20 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
21 | * or implied. See the License for the specific language governing |
22 | * permissions and limitations under the License. |
23 | * |
24 | */ |
25 | public class StandardReporter extends Reporter { |
26 | /** |
27 | * Constructs a standrad reporter to report about the given reportable. |
28 | * Reports produced by this standard reporter are always listed last on a |
29 | * report output. |
30 | * |
31 | * @param informationSource |
32 | * desmoj.core.simulator.Reportable : The reportable to produce a report about |
33 | */ |
34 | public StandardReporter(desmoj.core.simulator.Reportable informationSource) { |
35 | |
36 | super(informationSource); |
37 | |
38 | groupID = -2147483648; // lowest possible groupID to display last in |
39 | // report |
40 | groupHeading = "StandardReporter"; |
41 | |
42 | numColumns = 3; |
43 | |
44 | columns = new String[numColumns]; |
45 | entries = new String[numColumns]; |
46 | |
47 | columns[0] = "Title"; |
48 | columns[1] = "(Re)set"; |
49 | columns[2] = "Obs"; |
50 | |
51 | } |
52 | |
53 | /** |
54 | * Returns the array of strings containing the basic information any |
55 | * reportable can offer. |
56 | * |
57 | * @return java.lang.String[] : The array of Strings containing all |
58 | * information about the reportable information source |
59 | */ |
60 | public java.lang.String[] getEntries() { |
61 | |
62 | // if (source instanceof desmoj.core.simulator.Reportable) { // Replaced by test for non-null since instanceof always yields true (JG, 11.03.09) |
63 | if (source != null) { |
64 | |
65 | // Title |
66 | entries[0] = source.getName(); |
67 | // (Re)set |
68 | entries[1] = source.resetAt().toString(); |
69 | // Observations |
70 | entries[2] = Long.toString(source.getObservations()); |
71 | |
72 | } else { |
73 | for (int i = 0; i < numColumns; i++) { |
74 | entries[i] = "Invalid source!"; |
75 | } |
76 | } |
77 | |
78 | return entries; |
79 | |
80 | } |
81 | } |