summaryrefslogtreecommitdiff
path: root/test/java/src/org/apache/qetest/Reporter.java
blob: 34efd0694c6e779353e12a181796acb40133d18f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the  "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * $Id$
 */

/*
 *
 * Reporter.java
 *
 */
package org.apache.qetest;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import java.util.StringTokenizer;

/**
 * Class defining how a test can report results including convenience methods.
 * <p>Tests generally interact with a Reporter, which turns around to call
 * a Logger to actually store the results.  The Reporter serves as a
 * single funnel for all results, hiding both the details and number of
 * actual loggers that might currently be turned on (file, screen, network,
 * etc.) from the test that created us.</p>
 * <p>Note that Reporter adds numerous convenience methods that, while they
 * are not strictly necessary to express a test's results, make coding
 * tests much easier.  Reporter is designed to be subclassed for your
 * particular application; in general you only need to provide setup mechanisims
 * specific to your testing/product environment.</p>
 * @todo all methods should check that available loggers are OK
 * @todo explain better how results are rolled up and calculated
 * @author Shane_Curcuru@lotus.com
 * @author Jo_Grant@lotus.com
 * @version $Id$
 */
public class Reporter implements Logger
{

    /**
     * Parameter: (optional) Name of results summary file.
     * <p>This is a custom parameter optionally used in writeResultsStatus.</p>
     */
    public static final String OPT_SUMMARYFILE = "summaryFile";


    /**
     * Constructor calls initialize(p).
     * @param p Properties block to initialize us with.
     */
    public Reporter(Properties p)
    {
        ready = initialize(p);
    }

    /** If we're ready to start outputting yet. */
    protected boolean ready = false;

    //-----------------------------------------------------
    //-------- Implement Logger Control and utility routines --------
    //-----------------------------------------------------

    /**
     * Return a description of what this Logger/Reporter does.
     * @author Shane_Curcuru@lotus.com
     * @return description of how this Logger outputs results, OR
     * how this Reporter uses Loggers, etc..
     */
    public String getDescription()
    {
        return "Reporter: default reporter implementation";
    }

    /**
     * Returns information about the Property name=value pairs that
     * are understood by this Logger/Reporter.
     * @author Shane_Curcuru@lotus.com
     * @return same as {@link java.applet.Applet.getParameterInfo}.
     */
    public String[][] getParameterInfo()
    {

        String pinfo[][] =
        {
            { OPT_LOGGERS, "String", "FQCN of Loggers to add" },
            { OPT_LOGFILE, "String",
              "Name of file to use for file-based Logger output" },
            { OPT_LOGGINGLEVEL, "int",
              "to setLoggingLevel() to control amount of output" },
            { OPT_PERFLOGGING, "boolean",
              "if we should log performance data as well" },
            { OPT_INDENT, "int",
              "number of spaces to indent for supporting Loggers" },
            { OPT_DEBUG, "boolean", "generic debugging flag" }
        };

        return pinfo;
    }

    /**
     * Accessor methods for a properties block.
     * @return our Properties block.
     * @todo should this clone first?
     */
    public Properties getProperties()
    {
        return reporterProps;
    }

    /**
     * Accessor methods for a properties block.
     * Always having a Properties block allows users to pass common
     * options to a Logger/Reporter without having to know the specific
     * 'properties' on the object.
     * <p>Much like in Applets, users can call getParameterInfo() to
     * find out what kind of properties are available.  Callers more
     * commonly simply call initialize(p) instead of setProperties(p)</p>
     * @author Shane_Curcuru@lotus.com
     * @param p Properties to set (should be cloned).
     */
    public void setProperties(Properties p)
    {
        if (p != null)
            reporterProps = (Properties) p.clone();
    }

    /**
     * Call once to initialize this Logger/Reporter from Properties.
     * <p>Simple hook to allow Logger/Reporters with special output
     * items to initialize themselves.</p>
     *
     * @author Shane_Curcuru@lotus.com
     * @param p Properties block to initialize from.
     * @param status, true if OK, false if an error occoured.
     */
    public boolean initialize(Properties p)
    {

        setProperties(p);

        String dbg = reporterProps.getProperty(OPT_DEBUG);

        if ((dbg != null) && dbg.equalsIgnoreCase("true"))
        {
            setDebug(true);
        }

        String perf = reporterProps.getProperty(OPT_PERFLOGGING);

        if ((perf != null) && perf.equalsIgnoreCase("true"))
        {
            setPerfLogging(true);
        }

        // int values need to be parsed
        String logLvl = reporterProps.getProperty(OPT_LOGGINGLEVEL);

        if (logLvl != null)
        {
            try
            {
                setLoggingLevel(Integer.parseInt(logLvl));
            }
            catch (NumberFormatException numEx)
            { /* no-op */
            }
        }

        // Add however many loggers are askedfor
        boolean b = true;
        StringTokenizer st =
            new StringTokenizer(reporterProps.getProperty(OPT_LOGGERS),
                                LOGGER_SEPARATOR);
        int i;

        for (i = 0; st.hasMoreTokens(); i++)
        {
            String temp = st.nextToken();

            if ((temp != null) && (temp.length() > 1))
            {
                b &= addLogger(temp, reporterProps);
            }
        }

        return true;
    }

    /**
     * Is this Logger/Reporter ready to log results?
     * @author Shane_Curcuru@lotus.com
     * @return status - true if it's ready to report, false otherwise
     * @todo should we check our contained Loggers for their status?
     */
    public boolean isReady()
    {
        return ready;
    }

    /**
     * Flush this Logger/Reporter - should ensure all output is flushed.
     * Note that the flush operation is not necessarily pertinent to
     * all types of Logger/Reporter - console-type Loggers no-op this.
     * @author Shane_Curcuru@lotus.com
     */
    public void flush()
    {

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].flush();
        }
    }

    /**
     * Close this Logger/Reporter - should include closing any OutputStreams, etc.
     * Logger/Reporters should return isReady() = false after closing.
     * @author Shane_Curcuru@lotus.com
     */
    public void close()
    {

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].close();
        }
    }

    /**
     * Generic properties for this Reporter.
     * <p>Use a Properties block to make it easier to add new features
     * and to be able to pass data to our loggers.  Any properties that
     * we recognize will be set here, and the entire block will be passed
     * to any loggers that we control.</p>
     */
    protected Properties reporterProps = new Properties();

    /**
     * This determines the amount of data actually logged out to results.
     * <p>Setting this higher will result in more data being logged out.
     * Values range from Reporter.CRITICALMSG (0) to TRACEMSG (60).
     * For non-performance-critical testing, you may wish to set this high,
     * so all data gets logged, and then use reporting tools on the test output
     * to filter for human use (since the appropriate level is stored with
     * every logMsg() call)</p>
     * @see #logMsg(int, java.lang.String)
     */
    protected int loggingLevel = DEFAULT_LOGGINGLEVEL;

    /**
     * Marker that a testcase is currently running.
     * <p>NEEDSWORK: should do a better job of reporting results in cases
     * where users might not call testCaseInit/testCaseClose in non-nested pairs.</p>
     */
    protected boolean duringTestCase = false;

    /**
     * Flag if we should force loggers closed upon testFileClose.
     * <p>Default: true.  Standalone tests can leave this alone.
     * Test Harnesses may want to reset this so they can have multiple
     * file results in one actual output 'file' for file-based loggers.</p>
     */
    protected boolean closeOnFileClose = true;

    /**
     * Accessor method for closeOnFileClose.  
     *
     * @return our value for closeOnFileClose
     */
    public boolean getCloseOnFileClose()
    {
        return closeOnFileClose;
    }

    /**
     * Accessor method for closeOnFileClose.  
     *
     * @param b value to set for closeOnFileClose
     */
    public void setCloseOnFileClose(boolean b)
    {
        closeOnFileClose = b;
    }

    //-----------------------------------------------------
    //-------- Test results computation members and methods --------
    //-----------------------------------------------------

    /** Name of the current test. */
    protected String testName;

    /** Description of the current test. */
    protected String testComment;

    /** Number of current case within a test, usually automatically calculated. */
    protected int caseNum;

    /** Description of current case within a test. */
    protected String caseComment;

    /** Overall test result of current test, automatically calculated. */
    protected int testResult;

    /** Overall test result of current testcase, automatically calculated. */
    protected int caseResult;

    /**
     * Counters for overall number of results - passes, fails, etc.
     * @todo update this if we use TestResult objects
     */
    protected static final int FILES = 0;

    /** NEEDSDOC Field CASES          */
    protected static final int CASES = 1;

    /** NEEDSDOC Field CHECKS          */
    protected static final int CHECKS = 2;

    /** NEEDSDOC Field MAX_COUNTERS          */
    protected static final int MAX_COUNTERS = CHECKS + 1;

    /**
     * Counters for overall number of results - passes, fails, etc.
     * @todo update this if we use TestResult objects
     */
    protected int[] incpCount = new int[MAX_COUNTERS];

    /** NEEDSDOC Field passCount          */
    protected int[] passCount = new int[MAX_COUNTERS];

    /** NEEDSDOC Field ambgCount          */
    protected int[] ambgCount = new int[MAX_COUNTERS];

    /** NEEDSDOC Field failCount          */
    protected int[] failCount = new int[MAX_COUNTERS];

    /** NEEDSDOC Field errrCount          */
    protected int[] errrCount = new int[MAX_COUNTERS];
    

    //-----------------------------------------------------
    //-------- Composite Pattern Variables And Methods --------
    //-----------------------------------------------------

    /**
     * Optimization: max number of loggers, stored in an array.
     * <p>This is a design decision: normally, you might use a ConsoleReporter,
     * some sort of file-based one, and maybe a network-based one.</p>
     */
    protected int MAX_LOGGERS = 3;

    /**
     * Array of loggers to whom we pass results.
     * <p>Store our loggers in an array for optimization, since we want
     * logging calls to take as little time as possible.</p>
     */
    protected Logger[] loggers = new Logger[MAX_LOGGERS];

    /** NEEDSDOC Field numLoggers          */
    protected int numLoggers = 0;

    /**
     * Add a new Logger to our array, optionally initializing it with Properties.
     * <p>Store our Loggers in an array for optimization, since we want
     * logging calls to take as little time as possible.</p>
     * @todo enable users to add more than MAX_LOGGERS
     * @author Gang Of Four
     * @param rName fully qualified class name of Logger to add.
     * @param p (optional) Properties block to initialize the Logger with.
     * @return status - true if successful, false otherwise.
     */
    public boolean addLogger(String rName, Properties p)
    {

        if ((rName == null) || (rName.length() < 1))
            return false;

        debugPrintln("addLogger(" + numLoggers + ", " + rName + " ...)");

        if ((numLoggers + 1) > loggers.length)
        {

            // @todo enable users to add more than MAX_LOGGERS
            return false;
        }

        // Attempt to add Logger to our list
        Class rClass;
        Constructor rCtor;

        try
        {
            rClass = Class.forName(rName);

            debugPrintln("rClass is " + rClass.toString());

            if (p == null)

            // @todo should somehow pass along our own props as well
            // Need to ensure Reporter and callers of this method always 
            //  coordinate the initialization of the Loggers we hold
            {
                loggers[numLoggers] = (Logger) rClass.newInstance();
            }
            else
            {
                Class[] parameterTypes = new Class[1];

                parameterTypes[0] = java.util.Properties.class;
                rCtor = rClass.getConstructor(parameterTypes);

                Object[] initArgs = new Object[1];

                initArgs[0] = (Object) p;
                loggers[numLoggers] = (Logger) rCtor.newInstance(initArgs);
            }
        }
        catch (Exception e)
        {

            // @todo should we inform user why it failed?
            // Note: the logMsg may fail since we might not have any reporters at this point!
            debugPrintln("addLogger exception: " + e.toString());
            logCriticalMsg("addLogger exception: " + e.toString());
            logThrowable(CRITICALMSG, e, "addLogger exception:");

            return false;
        }

        // Increment counter for later use
        numLoggers++;

        return true;
    }

    /**
     * Return an Hashtable of all active Loggers.
     * @todo revisit; perhaps use a Vector
     * @reurns Hash of all active Loggers; null if none
     *
     * NEEDSDOC ($objectName$) @return
     */
    public Hashtable getLoggers()
    {

        // Optimization
        if (numLoggers == 0)
            return (null);

        Hashtable temp = new Hashtable();

        for (int i = 0; i < numLoggers; i++)
        {
            temp.put(loggers[i].getClass().getName(), loggers[i]);
        }

        return temp;
    }

    /**
     * Add the default Logger to this Reporter, whatever it is.
     * <p>Only adds the Logger if numLoggers <= 0; if the user has already
     * setup another Logger, this is a no-op (for the testwriter who doesn't
     * want the performance hit or annoyance of having Console output)</p>
     * @author Gang Of Four
     * @return status - true if successful, false otherwise.
     */
    public boolean addDefaultLogger()
    {

        // Optimization - return true, since they already have a logger
        if (numLoggers > 0)
            return true;

        return addLogger(DEFAULT_LOGGER, reporterProps);
    }

    //-----------------------------------------------------
    //-------- Testfile / Testcase start and stop routines --------
    //-----------------------------------------------------

    /**
     * Call once to initialize your Loggers for your test file.
     * Also resets test name, result, case results, etc.
     * <p>Currently, you must init/close your test file before init/closing
     * any test cases.  No checking is currently done to ensure that
     * mismatched test files are not nested.  This is an area that needs
     * design decisions and some work eventually to be a really clean design.</p>
     * <p>Not only do nested testfiles/testcases have implications for good
     * testing practices, they may also have implications for various Loggers,
     * especially XML or other ones with an implicit hierarcy in the reports.</p>
     * @author Shane_Curcuru@lotus.com
     * @param name file name or tag specifying the test.
     * @param comment comment about the test.
     */
    public void testFileInit(String name, String comment)
    {

        testName = name;
        testComment = comment;
        testResult = DEFAULT_RESULT;
        caseNum = 0;
        caseComment = null;
        caseResult = DEFAULT_RESULT;
        duringTestCase = false;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].testFileInit(testName, testComment);
        }

        // Log out time whole test script starts
        // Note there is a slight delay while logPerfMsg calls all reporters
        long t = System.currentTimeMillis();

        logPerfMsg(TEST_START, t, testName);
    }

    /**
     * Call once to close out your test and summate results.
     * <p>will close an open testCase before closing the file.  May also
     * force all Loggers closed if getCloseOnFileClose() (which may imply
     * that no more output will be logged to file-based reporters)</p>
     * @author Shane_Curcuru@lotus.com
     * @todo make this settable as to how/where the resultsCounters get output
     */
    public void testFileClose()
    {

        // Cache the time whole test script ends
        long t = System.currentTimeMillis();

        if (duringTestCase)
        {

            // Either user messed up (forgot to call testCaseClose) or something went wrong
            logErrorMsg("WARNING! testFileClose when duringTestCase=true!");

            // Force call to testCaseClose()
            testCaseClose();
        }

        // Actually log the time the test script ends after closing any potentially open testcases
        logPerfMsg(TEST_STOP, t, testName);

        // Increment our results counters 
        incrementResultCounter(FILES, testResult);

        // Print out an overall count of results by type
        // @todo make this settable as to how/where the resultsCounters get output
        logResultsCounters();

        // end this testfile - finish up any reporting we need to
        for (int i = 0; i < numLoggers; i++)
        {

            // Log we're done and then flush
            loggers[i].testFileClose(testComment, resultToString(testResult));
            loggers[i].flush();

            // Only close each reporter if asked to; this implies we're done
            //  and can't perform any more logging ourselves (or our reporters)
            if (getCloseOnFileClose())
            {
                loggers[i].close();
            }
        }

        // Note: explicitly leave testResult, caseResult, etc. set for debugging
        //       purposes or for use by external test harnesses
    }

    /**
     * Implement Logger-only method.
     * <p>Here, a Reporter is simply acting as a logger: so don't
     * summate any results, do performance measuring, or anything
     * else, just pass the call through to our Loggers.
     * @param msg message to log out
     * @param result result of testfile
     */
    public void testFileClose(String msg, String result)
    {

        if (duringTestCase)
        {

            // Either user messed up (forgot to call testCaseClose) or something went wrong
            logErrorMsg("WARNING! testFileClose when duringTestCase=true!");

            // Force call to testCaseClose()
            testCaseClose();
        }

        // end this testfile - finish up any reporting we need to
        for (int i = 0; i < numLoggers; i++)
        {

            // Log we're done and then flush
            loggers[i].testFileClose(testComment, resultToString(testResult));
            loggers[i].flush();

            // Only close each reporter if asked to; this implies we're done
            //  and can't perform any more logging ourselves (or our reporters)
            if (getCloseOnFileClose())
            {
                loggers[i].close();
            }
        }
    }

    /**
     * Call once to start each test case; logs out testcase number and your comment.
     * <p>Testcase numbers are calculated as integers incrementing from 1.  Will
     * also close any previously init'd but not closed testcase.</p>
     * @author Shane_Curcuru@lotus.com
     * @todo investigate tieing this to the actual testCase methodnames,
     * instead of blindly incrementing the counter
     * @param comment short description of this test case's objective.
     */
    public void testCaseInit(String comment)
    {

        if (duringTestCase)
        {

            // Either user messed up (forgot to call testCaseClose) or something went wrong
            logErrorMsg("WARNING! testCaseInit when duringTestCase=true!");

            // Force call to testCaseClose()
            testCaseClose();
        }

        caseNum++;

        caseComment = comment;
        caseResult = DEFAULT_RESULT;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].testCaseInit(String.valueOf(caseNum) + " "
                                    + caseComment);
        }

        duringTestCase = true;

        // Note there is a slight delay while logPerfMsg calls all reporters
        long t = System.currentTimeMillis();

        logPerfMsg(CASE_START, t, caseComment);
    }

    /**
     * Call once to end each test case and sub-summate results.
     * @author Shane_Curcuru@lotus.com
     */
    public void testCaseClose()
    {

        long t = System.currentTimeMillis();

        logPerfMsg(CASE_STOP, t, caseComment);

        if (!duringTestCase)
        {
            logErrorMsg("WARNING! testCaseClose when duringTestCase=false!");

            // Force call to testCaseInit()
            // NEEDSWORK: should we really do this?  This ensures any results
            //            are well-formed, however a user might not expect this.
            testCaseInit("WARNING! testCaseClose when duringTestCase=false!");
        }

        duringTestCase = false;
        testResult = java.lang.Math.max(testResult, caseResult);

        // Increment our results counters 
        incrementResultCounter(CASES, caseResult);

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].testCaseClose(
                String.valueOf(caseNum) + " " + caseComment,
                resultToString(caseResult));
        }
    }

    /**
     * Implement Logger-only method.
     * <p>Here, a Reporter is simply acting as a logger: so don't
     * summate any results, do performance measuring, or anything
     * else, just pass the call through to our Loggers.
     * @param msg message of name of test case to log out
     * @param result result of testfile
     */
    public void testCaseClose(String msg, String result)
    {

        if (!duringTestCase)
        {
            logErrorMsg("WARNING! testCaseClose when duringTestCase=false!");

            // Force call to testCaseInit()
            // NEEDSWORK: should we really do this?  This ensures any results
            //            are well-formed, however a user might not expect this.
            testCaseInit("WARNING! testCaseClose when duringTestCase=false!");
        }

        duringTestCase = false;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].testCaseClose(
                String.valueOf(caseNum) + " " + caseComment,
                resultToString(caseResult));
        }
    }

    /**
     * Calls back into a Test to run test cases in order.
     * <p>Use reflection to call back and execute each testCaseXX method
     * in the calling test in order, catching exceptions along the way.</p>
     * //@todo rename to 'executeTestCases' or something
     * //@todo implement options: either an inclusion or exclusion list
     * @author Shane Curcuru
     * @param testObject the test object itself.
     * @param numTestCases number of consecutively numbered test cases to execute.
     * @param options (future use: options to pass to testcases)
     * @return status, true if OK, false if big bad error occoured
     */
    public boolean executeTests(Test testObject, int numTestCases,
                                Object options)
    {

        // Flag denoting if we've had any errors
        boolean gotException = false;

        // Declare all needed java variables
        String tmpErrString = "executeTests: no errors yet";
        Object noArgs[] = new Object[0];  // use options instead
        Class noParams[] = new Class[0];
        Method currTestCase;
        Class testClass;

        // Get class reference for the test applet itself
        testClass = testObject.getClass();

        logTraceMsg("executeTests: running " + numTestCases + " tests now.");

        for (int tcNum = 1; tcNum <= numTestCases; tcNum++)
        {
            try
            {  // get a reference to the next test case that we'll be calling
                tmpErrString = "executeTests: No such method: testCase"
                               + tcNum + "()";
                currTestCase = testClass.getMethod("testCase" + tcNum,
                                                   noParams);

                // Now directly invoke that test case
                tmpErrString =
                    "executeTests: Method threw an exception: testCase"
                    + tcNum + "(): ";

                logTraceMsg("executeTests: invoking testCase" + tcNum
                            + " now.");
                currTestCase.invoke(testObject, noArgs);
            }
            catch (InvocationTargetException ite)
            {
                // Catch any error, log it as an error, and allow next test case to run
                gotException = true;
                testResult = java.lang.Math.max(ERRR_RESULT, testResult);
                tmpErrString += ite.toString();
                logErrorMsg(tmpErrString);

                // Grab the contained error, log it if available 
                java.lang.Throwable containedThrowable =
                    ite.getTargetException();
                if (containedThrowable != null)
                {
                    logThrowable(ERRORMSG, containedThrowable, tmpErrString + "(1)");
                }
                logThrowable(ERRORMSG, ite, tmpErrString + "(2)");
            }  // end of catch
            catch (Throwable t)
            {
                // Catch any error, log it as an error, and allow next test case to run
                gotException = true;
                testResult = java.lang.Math.max(ERRR_RESULT, testResult);
                tmpErrString += t.toString();
                logErrorMsg(tmpErrString);
                logThrowable(ERRORMSG, t, tmpErrString);
            }  // end of catch
        }  // end of for

        // Convenience functionality: remind user if they appear to 
        //  have set numTestCases too low 
        try
        {  
            // Get a reference to the *next* test case after numTestCases
            int moreTestCase = numTestCases + 1;
            currTestCase = testClass.getMethod("testCase" + moreTestCase, noParams);

            // If we get here, we found another testCase - warn the user
            logWarningMsg("executeTests: extra testCase"+ moreTestCase
                          + " found, perhaps numTestCases is too low?");
        }
        catch (Throwable t)
        {
            // Ignore errors: we don't care, since they didn't 
            //  ask us to look for this method anyway
        }

        // Return true only if everything passed
        if (testResult == PASS_RESULT)
            return true;
        else
            return false;
    }  // end of executeTests

    //-----------------------------------------------------
    //-------- Test results logging routines --------
    //-----------------------------------------------------

    /**
     * Accessor for loggingLevel, determines what level of log*() calls get output.
     * @return loggingLevel, as an int.
     */
    public int getLoggingLevel()
    {
        return loggingLevel;
    }

    /**
     * Accessor for loggingLevel, determines what level of log*() calls get output.
     * @param setLL loggingLevel; normalized to be between CRITICALMSG and TRACEMSG.
     */
    public void setLoggingLevel(int setLL)
    {

        if (setLL < CRITICALMSG)
        {
            loggingLevel = CRITICALMSG;
        }
        else if (setLL > TRACEMSG)
        {
            loggingLevel = TRACEMSG;
        }
        else
        {
            loggingLevel = setLL;
        }
    }

    /**
     * Report a comment to result file with specified severity.
     * <p>Works in conjunction with {@link #loggingLevel };
     * only outputs messages that are more severe (i.e. lower)
     * than the current logging level.</p>
     * <p>Note that some Loggers may limit the comment string,
     * either in overall length or by stripping any linefeeds, etc.
     * This is to allow for optimization of file or database-type
     * reporters with fixed fields.  Users who need to log out
     * special string data should use logArbitrary() instead.</p>
     * <p>Remember, use {@link #check(String, String, String)
     * various check*() methods} to report the actual results
     * of your tests.</p>
     * @author Shane_Curcuru@lotus.com
     * @param level severity of message.
     * @param msg comment to log out.
     * @see #loggingLevel
     */
    public void logMsg(int level, String msg)
    {

        if (level > loggingLevel)
            return;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].logMsg(level, msg);
        }
    }

    /**
     * Report an arbitrary String to result file with specified severity.
     * Log out the String provided exactly as-is.
     * @author Shane_Curcuru@lotus.com
     * @param level severity or class of message.
     * @param msg arbitrary String to log out.
     */
    public void logArbitrary(int level, String msg)
    {

        if (level > loggingLevel)
            return;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].logArbitrary(level, msg);
        }
    }

    /**
     * Logs out statistics to result file with specified severity.
     * <p>This is a general-purpose way to log out numeric statistics.  We accept
     * both a long and a double to allow users to save whatever kind of numbers
     * they need to, with the simplest API.  The actual meanings of the numbers
     * are dependent on the implementer.</p>
     * @author Shane_Curcuru@lotus.com
     * @param level severity of message.
     * @param lVal statistic in long format.
     * @param dVal statistic in doubleformat.
     * @param msg comment to log out.
     */
    public void logStatistic(int level, long lVal, double dVal, String msg)
    {

        if (level > loggingLevel)
            return;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].logStatistic(level, lVal, dVal, msg);
        }
    }

    /**
     * Logs out a element to results with specified severity.
     * This method is primarily for reporters that output to fixed
     * structures, like files, XML data, or databases.
     * @author Shane_Curcuru@lotus.com
     * @param level severity of message.
     * @param element name of enclosing element
     * @param attrs hash of name=value attributes
     * @param msg Object to log out; up to reporters to handle
     * processing of this; usually logs just .toString().
     */
    public void logElement(int level, String element, Hashtable attrs,
                           Object msg)
    {

        if (level > loggingLevel)
            return;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].logElement(level, element, attrs, msg);
        }
    }

    /**
     * Logs out Throwable.toString() and a stack trace of the 
     * Throwable with the specified severity.
     * <p>Works in conjuntion with {@link #setLoggingLevel(int)}; 
     * only outputs messages that are more severe than the current 
     * logging level.</p>
     * <p>This uses logArbitrary to log out your msg - message, 
     * a newline, throwable.toString(), a newline,
     * and then throwable.printStackTrace().</p>
     * <p>Note that this does not imply a failure or problem in 
     * a test in any way: many tests may want to verify that 
     * certain exceptions are thrown, etc.</p>
     * @author Shane_Curcuru@lotus.com
     * @param level severity of message.
     * @param throwable throwable/exception to log out.
     * @param msg description of the throwable.
     */
    public void logThrowable(int level, Throwable throwable, String msg)
    {

        if (level > loggingLevel)
            return;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].logThrowable(level, throwable, msg);
        }
    }

    /**
     * Logs out contents of a Hashtable with specified severity.
     * <p>Works in conjuntion with setLoggingLevel(int); only outputs messages that
     * are more severe than the current logging level.</p>
     * <p>Loggers should store or log the full contents of the hashtable.</p>
     * @author Shane_Curcuru@lotus.com
     * @param level severity of message.
     * @param hash Hashtable to log the contents of.
     * @param msg description of the Hashtable.
     */
    public void logHashtable(int level, Hashtable hash, String msg)
    {
        if (level > loggingLevel)
          return;
        
        // Don't log anyway if level is 10 or less.
        //@todo revisit this decision: I don't like having special
        //  rules like this to exclude output.  On the other hand, 
        //  if the user set loggingLevel this low, they really don't 
        //  want much output coming out, and hashtables are big
        if (loggingLevel <= 10)
            return;

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].logHashtable(level, hash, msg);
        }
    }

    /**
     * Logs out an critical a comment to results; always printed out.
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    public void logCriticalMsg(String msg)
    {
        logMsg(CRITICALMSG, msg);
    }

    // There is no logFailsOnlyMsg(String msg) method

    /**
     * Logs out an error a comment to results.
     * <p>Note that subclassed libraries may choose to override to
     * cause a fail to happen along with printing out the message.</p>
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    public void logErrorMsg(String msg)
    {
        logMsg(ERRORMSG, msg);
    }

    /**
     * Logs out a warning a comment to results.
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    public void logWarningMsg(String msg)
    {
        logMsg(WARNINGMSG, msg);
    }

    /**
     * Logs out an status a comment to results.
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    public void logStatusMsg(String msg)
    {
        logMsg(STATUSMSG, msg);
    }

    /**
     * Logs out an informational a comment to results.
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    public void logInfoMsg(String msg)
    {
        logMsg(INFOMSG, msg);
    }

    /**
     * Logs out an trace a comment to results.
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    public void logTraceMsg(String msg)
    {
        logMsg(TRACEMSG, msg);
    }

    //-----------------------------------------------------
    //-------- Test results reporting check* routines --------
    //-----------------------------------------------------
    // There is no public void checkIncp(String comment) method

    /* EXPERIMENTAL: have duplicate set of check*() methods 
       that all output some form of ID as well as comment. 
       Leave the non-ID taking forms for both simplicity to the 
       end user who doesn't care about IDs as well as for 
       backwards compatibility.
    */

    /**
     * Writes out a Pass record with comment.
     * @author Shane_Curcuru@lotus.com
     * @param comment comment to log with the pass record.
     */
    public void checkPass(String comment)
    {
        checkPass(comment, null);
    }

    /**
     * Writes out an ambiguous record with comment.
     * @author Shane_Curcuru@lotus.com
     * @param comment to log with the ambg record.
     */
    public void checkAmbiguous(String comment)
    {
        checkAmbiguous(comment, null);
    }

    /**
     * Writes out a Fail record with comment.
     * @author Shane_Curcuru@lotus.com
     * @param comment comment to log with the fail record.
     */
    public void checkFail(String comment)
    {
        checkFail(comment, null);
    }
    

    /**
     * Writes out an Error record with comment.
     * @author Shane_Curcuru@lotus.com
     * @param comment comment to log with the error record.
     */
    public void checkErr(String comment)
    {
        checkErr(comment, null);
    }

    /**
     * Writes out a Pass record with comment.
     * A Pass signifies that an individual test point has completed and has
     * been verified to have behaved correctly.
     * <p>If you need to do your own specific comparisons, you can
     * do them in your code and then just call checkPass or checkFail.</p>
     * <p>Derived classes must implement this to <B>both</B> report the
     * results out appropriately <B>and</B> to summate the results, if needed.</p>
     * <p>Pass results are a low priority, except for INCP (incomplete).  Note
     * that if a test never calls check*(), it will have an incomplete result.</p>
     * @author Shane_Curcuru@lotus.com
     * @param comment to log with the pass record.
     * @param ID token to log with the pass record.
     */
    public void checkPass(String comment, String id)
    {

        // Increment our results counters 
        incrementResultCounter(CHECKS, PASS_RESULT);

        // Special: only report it actually if needed
        if (getLoggingLevel() > FAILSONLY)
        {
            for (int i = 0; i < numLoggers; i++)
            {
                loggers[i].checkPass(comment, id);
            }
        }

        caseResult = java.lang.Math.max(PASS_RESULT, caseResult);
    }

    /**
     * Writes out an ambiguous record with comment.
     * <p>Ambiguous results are neither pass nor fail. Different test
     * libraries may have slightly different reasons for using ambg.</p>
     * <p>Derived classes must implement this to <B>both</B> report the
     * results out appropriately <B>and</B> to summate the results, if needed.</p>
     * <p>Ambg results have a middling priority, and take precedence over incomplete and pass.</p>
     * <p>An Ambiguous result may signify that the test point has completed and either
     * appears to have succeded, or that it has produced a result but there is no known
     * 'gold' result to compare it to.</p>
     * @author Shane_Curcuru@lotus.com
     * @param comment to log with the ambg record.
     * @param ID token to log with the pass record.
     */
    public void checkAmbiguous(String comment, String id)
    {

        // Increment our results counters 
        incrementResultCounter(CHECKS, AMBG_RESULT);

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].checkAmbiguous(comment, id);
        }

        caseResult = java.lang.Math.max(AMBG_RESULT, caseResult);
    }

    /**
     * Writes out a Fail record with comment.
     * <p>If you need to do your own specific comparisons, you can
     * do them in your code and then just call checkPass or checkFail.</p>
     * <p>Derived classes must implement this to <B>both</B> report the
     * results out appropriately <B>and</B> to summate the results, if needed.</p>
     * <p>Fail results have a high priority, and take precedence over incomplete, pass, and ambiguous.</p>
     * <p>A Fail signifies that an individual test point has completed and has
     * been verified to have behaved <B>in</B>correctly.</p>
     * @author Shane_Curcuru@lotus.com
     * @param comment to log with the fail record.
     * @param ID token to log with the pass record.
     */
    public void checkFail(String comment, String id)
    {

        // Increment our results counters 
        incrementResultCounter(CHECKS, FAIL_RESULT);

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].checkFail(comment, id);
        }

        caseResult = java.lang.Math.max(FAIL_RESULT, caseResult);
    }

    /**
     * Writes out an Error record with comment.
     * <p>Derived classes must implement this to <B>both</B> report the
     * results out appropriately <B>and</B> to summate the results, if needed.</p>
     * <p>Error results have the highest priority, and take precedence over
     * all other results.</p>
     * <p>An Error signifies that something unusual has gone wrong with the execution
     * of the test at this point - likely something that will require a human to
     * debug to see what really happened.</p>
     * @author Shane_Curcuru@lotus.com
     * @param comment to log with the error record.
     * @param ID token to log with the pass record.
     */
    public void checkErr(String comment, String id)
    {

        // Increment our results counters 
        incrementResultCounter(CHECKS, ERRR_RESULT);

        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].checkErr(comment, id);
        }

        caseResult = java.lang.Math.max(ERRR_RESULT, caseResult);
    }

    //-----------------------------------------------------
    //-------- Simplified Performance Logging - beyond interface Reporter --------
    //-----------------------------------------------------

    /** NEEDSDOC Field DEFAULT_PERFLOGGING_LEVEL          */
    protected final boolean DEFAULT_PERFLOGGING_LEVEL = false;

    /**
     * This determines if performance information is logged out to results.
     * <p>When true, extra performance records are written out to result files.</p>
     * @see #logPerfMsg(java.lang.String, long, java.lang.String)
     */
    protected boolean perfLogging = DEFAULT_PERFLOGGING_LEVEL;

    /**
     * Accessor for perfLogging, determines if we log performance info.
     * @todo add PerfLogging to Reporter interface
     * @return Whether or not we log performance info.
     */
    public boolean getPerfLogging()
    {
        return (perfLogging);
    }

    /**
     * Accessor for perfLogging, determines if we log performance info.
     * @param Whether or not we log performance info.
     *
     * NEEDSDOC @param setPL
     */
    public void setPerfLogging(boolean setPL)
    {
        perfLogging = setPL;
    }

    /**
     * Constants used to mark performance records in output.
     */

    // Note: string representations are explicitly set to all be 
    //       4 characters long to make it simpler to parse results
    public static final String TEST_START = "TSrt";

    /** NEEDSDOC Field TEST_STOP          */
    public static final String TEST_STOP = "TStp";

    /** NEEDSDOC Field CASE_START          */
    public static final String CASE_START = "CSrt";

    /** NEEDSDOC Field CASE_STOP          */
    public static final String CASE_STOP = "CStp";

    /** NEEDSDOC Field USER_TIMER          */
    public static final String USER_TIMER = "UTmr";

    /** NEEDSDOC Field USER_TIMESTAMP          */
    public static final String USER_TIMESTAMP = "UTim";

    /** NEEDSDOC Field USER_MEMORY          */
    public static final String USER_MEMORY = "UMem";

    /** NEEDSDOC Field PERF_SEPARATOR          */
    public static final String PERF_SEPARATOR = ";";

    /**
     * Logs out a performance statistic.
     * <p>Only logs times if perfLogging set to true.</p>
     * <p>As an optimization for record-based Loggers, this is a rather simplistic
     * way to log performance info - however it's sufficient for most purposes.</p>
     * @author Frank Bell
     * @param type type of performance statistic.
     * @param data long value of performance statistic.
     * @param msg comment to log out.
     */
    public void logPerfMsg(String type, long data, String msg)
    {

        if (getPerfLogging())
        {
            double dummy = 0;

            for (int i = 0; i < numLoggers; i++)
            {

                // NEEDSWORK: simply put it at the current loggingLevel we have set
                //            Is there a better way to mesh performance output with the rest?
                loggers[i].logStatistic(loggingLevel, data, dummy,
                                        type + PERF_SEPARATOR + msg);
            }
        }
    }

    /**
     * Captures current time in milliseconds, only if perfLogging.
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    protected Hashtable perfTimers = new Hashtable();

    /**
     * NEEDSDOC Method startTimer 
     *
     *
     * NEEDSDOC @param msg
     */
    public void startTimer(String msg)
    {

        // Note optimization: only capture times if perfLogging
        if ((perfLogging) && (msg != null))
        {
            perfTimers.put(msg, new Long(System.currentTimeMillis()));
        }
    }

    /**
     * Captures current time in milliseconds and logs out difference.
     * Will only log times if perfLogging set to true.
     * <p>Only logs time if it finds a corresponding msg entry that was startTimer'd.</p>
     * @author Shane_Curcuru@lotus.com
     * @param msg comment to log out.
     */
    public void stopTimer(String msg)
    {

        // Capture time immediately to reduce latency
        long stopTime = System.currentTimeMillis();

        // Note optimization: only use times if perfLogging
        if ((perfLogging) && (msg != null))
        {
            Long startTime = (Long) perfTimers.get(msg);

            logPerfMsg(USER_TIMER, (stopTime - startTime.longValue()), msg);
            perfTimers.remove(msg);
        }
    }

    /**
     * Accessor for currently running test case number, read-only.
     * @return current test case number.
     */
    public int getCurrentCaseNum()
    {
        return caseNum;
    }

    /**
     * Accessor for current test case's result, read-only.
     * @return current test case result.
     */
    public int getCurrentCaseResult()
    {
        return caseResult;
    }

    /**
     * Accessor for current test case's description, read-only.
     * @return current test case result.
     */
    public String getCurrentCaseComment()
    {
        return caseComment;
    }

    /**
     * Accessor for overall test file result, read-only.
     * @return test file's overall result.
     */
    public int getCurrentFileResult()
    {
        return testResult;
    }

    /**
     * Utility method to log out overall result counters.  
     *
     * @param count number of this kind of result
     * @param desc description of this kind of result
     */
    protected void logResultsCounter(int count, String desc)
    {

        // Optimization: Only log the kinds of results we have
        if (count > 0)
            logStatistic(loggingLevel, count, 0, desc);
    }

    /** Utility method to log out overall result counters. */
    public void logResultsCounters()
    {

        // NEEDSWORK: what's the best format to display this stuff in?
        // NEEDSWORK: what loggingLevel should we use?
        // NEEDSWORK: temporarily skipping the 'files' since 
        //            we only have tests with one file being run
        // logResultsCounter(incpCount[FILES], "incpCount[FILES]");
        logResultsCounter(incpCount[CASES], "incpCount[CASES]");
        logResultsCounter(incpCount[CHECKS], "incpCount[CHECKS]");

        // logResultsCounter(passCount[FILES], "passCount[FILES]");
        logResultsCounter(passCount[CASES], "passCount[CASES]");
        logResultsCounter(passCount[CHECKS], "passCount[CHECKS]");

        // logResultsCounter(ambgCount[FILES], "ambgCount[FILES]");
        logResultsCounter(ambgCount[CASES], "ambgCount[CASES]");
        logResultsCounter(ambgCount[CHECKS], "ambgCount[CHECKS]");

        // logResultsCounter(failCount[FILES], "failCount[FILES]");
        logResultsCounter(failCount[CASES], "failCount[CASES]");
        logResultsCounter(failCount[CHECKS], "failCount[CHECKS]");

        // logResultsCounter(errrCount[FILES], "errrCount[FILES]");
        logResultsCounter(errrCount[CASES], "errrCount[CASES]");
        logResultsCounter(errrCount[CHECKS], "errrCount[CHECKS]");
    }

    /** 
     * Utility method to store overall result counters. 
     *
     * @return a Hashtable of various results items suitable for
     * passing to logElement as attrs
     */
    protected Hashtable createResultsStatusHash()
    {
        Hashtable resHash = new Hashtable();
        if (incpCount[CASES] > 0)
            resHash.put(INCP + "-cases", new Integer(incpCount[CASES]));
        if (incpCount[CHECKS] > 0)
            resHash.put(INCP + "-checks", new Integer(incpCount[CHECKS]));

        if (passCount[CASES] > 0)
            resHash.put(PASS + "-cases", new Integer(passCount[CASES]));
        if (passCount[CHECKS] > 0)
            resHash.put(PASS + "-checks", new Integer(passCount[CHECKS]));

        if (ambgCount[CASES] > 0)
            resHash.put(AMBG + "-cases", new Integer(ambgCount[CASES]));
        if (ambgCount[CHECKS] > 0)
            resHash.put(AMBG + "-checks", new Integer(ambgCount[CHECKS]));

        if (failCount[CASES] > 0)
            resHash.put(FAIL + "-cases", new Integer(failCount[CASES]));
        if (failCount[CHECKS] > 0)
            resHash.put(FAIL + "-checks", new Integer(failCount[CHECKS]));

        if (errrCount[CASES] > 0)
            resHash.put(ERRR + "-cases", new Integer(errrCount[CASES]));
        if (errrCount[CHECKS] > 0)
            resHash.put(ERRR + "-checks", new Integer(errrCount[CHECKS]));
        return resHash;
    }

    /** 
     * Utility method to write out overall result counters. 
     * 
     * <p>This writes out both a testsummary element as well as 
     * writing a separate marker file for the test's currently 
     * rolled-up test results.</p>
     *
     * <p>Note if writeFile is true, we do a bunch of additional 
     * processing, including deleting any potential marker 
     * files, along with creating a new marker file.  This section 
     * of code explicitly does file creation and also includes 
     * some basic XML-isms in it.</p>
     * 
     * <p>Marker files look like: [testStat][testName].xml, where 
     * testStat is the actual current status, like 
     * Pass/Fail/Ambg/Errr/Incp, and testName comes from the 
     * currently executing test; this may be overridden by 
		  * setting OPT_SUMMARYFILE.</p>
     *
     * @param writeFile if we should also write out a separate 
     * Passname/Failname marker file as well
     */
    public void writeResultsStatus(boolean writeFile)
    {
        final String DEFAULT_SUMMARY_NAME = "ResultsSummary.xml";
        Hashtable resultsHash = createResultsStatusHash();
        resultsHash.put("desc", testComment);
        resultsHash.put("testName", testName);
        //@todo the actual path in the property below may not necessarily 
        //  either exist or be the correct location vis-a-vis the file
        //  that we're writing out - but it should be close
        resultsHash.put(OPT_LOGFILE, reporterProps.getProperty(OPT_LOGFILE, DEFAULT_SUMMARY_NAME));
        try
        {
            resultsHash.put("baseref", System.getProperty("user.dir"));
        } 
        catch (Exception e) { /* no-op, ignore */ }

        String elementName = "teststatus";
        String overallResult = resultToString(getCurrentFileResult());
        // Ask each of our loggers to report this
        for (int i = 0; i < numLoggers; i++)
        {
            loggers[i].logElement(CRITICALMSG, elementName, resultsHash, overallResult);
        }

        // Only continue if user asked us to
        if (!writeFile)
            return;

        // Now write an actual file out as a marker for enclosing 
        //  harnesses and build environments

        // Calculate the name relative to any logfile we have
        String logFileBase = null;
        try
        {
            // CanonicalPath gives a better path, especially if 
            //  you mix your path separators up
            logFileBase = (new File(reporterProps.getProperty(OPT_LOGFILE, DEFAULT_SUMMARY_NAME))).getCanonicalPath();
        } 
        catch (IOException ioe)
        {
            logFileBase = (new File(reporterProps.getProperty(OPT_LOGFILE, DEFAULT_SUMMARY_NAME))).getAbsolutePath();
        }
        logFileBase = (new File(logFileBase)).getParent();
		 		 // Either use the testName or an optionally set summary name
		 		 String summaryFileBase = reporterProps.getProperty(OPT_SUMMARYFILE, testName + ".xml");
        final File[] summaryFiles = 
        {
            // Note array is ordered; should be re-designed so this doesn't matter
            // Coordinate PASS name with results.marker in build.xml
            // File name rationale: put Pass/Fail/etc first, so they 
            //  all show up together in dir listing; include 
            //  testName so you know where it came from; make it 
            //  .xml since it is an XML file
            new File(logFileBase, INCP + "-" + summaryFileBase),
            new File(logFileBase, PASS + "-" + summaryFileBase),
            new File(logFileBase, AMBG + "-" + summaryFileBase),
            new File(logFileBase, FAIL + "-" + summaryFileBase),
            new File(logFileBase, ERRR + "-" + summaryFileBase)
        };
        // Clean up any pre-existing files that might be confused 
        //  as markers from this testrun
        for (int i = 0; i < summaryFiles.length; i++)
        {
            if (summaryFiles[i].exists())
                summaryFiles[i].delete();
        }

        File summaryFile = null;
        switch (getCurrentFileResult())
        {
            case INCP_RESULT:
                summaryFile = summaryFiles[0];
                break;
            case PASS_RESULT:
                summaryFile = summaryFiles[1];
                break;
            case AMBG_RESULT:
                summaryFile = summaryFiles[2];
                break;
            case FAIL_RESULT:
                summaryFile = summaryFiles[3];
                break;
            case ERRR_RESULT:
                summaryFile = summaryFiles[4];
                break;
            default:
                // Use error case, this should never happen
                summaryFile = summaryFiles[4];
                break;
        }
		 		 resultsHash.put(OPT_SUMMARYFILE, summaryFile.getPath());
        // Now actually write out the summary file
        try
        {
            PrintWriter printWriter = new PrintWriter(new FileWriter(summaryFile));
            // Fake the output of Logger.logElement mostly; except 
            //  we add an XML header so this is a legal XML doc
            printWriter.println("<?xml version=\"1.0\"?>"); 
            printWriter.println("<" + elementName); 
            for (Enumeration keys = resultsHash.keys();
                    keys.hasMoreElements(); /* no increment portion */ )
            {
                Object key = keys.nextElement();
                printWriter.println(key + "=\"" + resultsHash.get(key) + "\"");
            }
            printWriter.println(">"); 
            printWriter.println(overallResult); 
            printWriter.println("</" + elementName + ">"); 
            printWriter.close();
        }
        catch(Exception e)
        {
            logErrorMsg("writeResultsStatus: Can't write: " + summaryFile);
        }
    }

    //-----------------------------------------------------
    //-------- Test results reporting check* routines --------
    //-----------------------------------------------------

    /**
     * Compares actual and expected, and logs the result, pass/fail.
     * The comment you pass is added along with the pass/fail, of course.
     * Currenly, you may pass a pair of any of these simple {type}:
     * <ui>
     * <li>boolean</li>
     * <li>byte</li>
     * <li>short</li>
     * <li>int</li>
     * <li>long</li>
     * <li>float</li>
     * <li>double</li>
     * <li>String</li>
     * </ui>
     * <p>While tests could simply call checkPass(comment), providing these convenience
     * method can save lines of code, since you can replace:</p>
     * <code>if (foo = bar) <BR>
     *           checkPass(comment); <BR>
     *       else <BR>
     *           checkFail(comment);</code>
     * <p>With the much simpler:</p>
     * <code>check(foo, bar, comment);</code>
     * <p>Plus, you can either use or ignore the boolean return value.</p>
     * <p>Note that individual methods checkInt(...), checkLong(...), etc. also exist.
     * These type-independent overriden methods are provided as a convenience to
     * Java-only testwriters.  JavaScript scripts must call the
     * type-specific checkInt(...), checkString(...), etc. methods directly.</p>
     * <p>Note that testwriters are free to ignore the boolean return value.</p>
     * @author Shane_Curcuru@lotus.com
     * @param actual value returned from your test code.
     * @param expected value that test should return to pass.
     * @param comment to log out with result.
     * @return status, true=pass, false otherwise
     * @see #checkPass
     * @see #checkFail
     * @see #checkObject
     */
    public boolean check(boolean actual, boolean expected, String comment)
    {
        return (checkBool(actual, expected, comment));
    }

    /**
     * NEEDSDOC Method check 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (check) @return
     */
    public boolean check(byte actual, byte expected, String comment)
    {
        return (checkByte(actual, expected, comment));
    }

    /**
     * NEEDSDOC Method check 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (check) @return
     */
    public boolean check(short actual, short expected, String comment)
    {
        return (checkShort(actual, expected, comment));
    }

    /**
     * NEEDSDOC Method check 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (check) @return
     */
    public boolean check(int actual, int expected, String comment)
    {
        return (checkInt(actual, expected, comment));
    }

    /**
     * NEEDSDOC Method check 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (check) @return
     */
    public boolean check(long actual, long expected, String comment)
    {
        return (checkLong(actual, expected, comment));
    }

    /**
     * NEEDSDOC Method check 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (check) @return
     */
    public boolean check(float actual, float expected, String comment)
    {
        return (checkFloat(actual, expected, comment));
    }

    /**
     * NEEDSDOC Method check 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (check) @return
     */
    public boolean check(double actual, double expected, String comment)
    {
        return (checkDouble(actual, expected, comment));
    }

    /**
     * NEEDSDOC Method check 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (check) @return
     */
    public boolean check(String actual, String expected, String comment)
    {
        return (checkString(actual, expected, comment));
    }

    // No check(Object, Object, String) currently provided, please call checkObject(...) directly

    /**
     * Compares actual and expected (Object), and logs the result, pass/fail.
     * <p><b>Special note for checkObject:</b></p>
     * <p>Since this takes an object reference and not a primitive type,
     * it works slightly differently than other check{Type} methods.</p>
     * <ui>
     * <li>If both are null, then Pass</li>
     * <li>Else If actual.equals(expected) than Pass</li>
     * <li>Else Fail</li>
     * </ui>
     * @author Shane_Curcuru@lotus.com
     * @param actual Object returned from your test code.
     * @param expected Object that test should return to pass.
     * @param comment to log out with result.
     * @see #checkPass
     * @see #checkFail
     * @see #check
     *
     * NEEDSDOC ($objectName$) @return
     */
    public boolean checkObject(Object actual, Object expected, String comment)
    {

        // Pass if both null, or both valid & equals
        if (actual != null)
        {
            if (actual.equals(expected))
            {
                checkPass(comment);

                return true;
            }
            else
            {
                checkFail(comment);

                return false;
            }
        }
        else
        {  // actual is null, so can't use .equals
            if (expected == null)
            {
                checkPass(comment);

                return true;
            }
            else
            {
                checkFail(comment);

                return false;
            }
        }
    }

    /**
     * NEEDSDOC Method checkBool 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (checkBool) @return
     */
    public boolean checkBool(boolean actual, boolean expected, String comment)
    {

        if (actual == expected)
        {
            checkPass(comment);

            return true;
        }
        else
        {
            checkFail(comment);

            return false;
        }
    }

    /**
     * NEEDSDOC Method checkByte 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (checkByte) @return
     */
    public boolean checkByte(byte actual, byte expected, String comment)
    {

        if (actual == expected)
        {
            checkPass(comment);

            return true;
        }
        else
        {
            checkFail(comment);

            return false;
        }
    }

    /**
     * NEEDSDOC Method checkShort 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (checkShort) @return
     */
    public boolean checkShort(short actual, short expected, String comment)
    {

        if (actual == expected)
        {
            checkPass(comment);

            return true;
        }
        else
        {
            checkFail(comment);

            return false;
        }
    }

    /**
     * NEEDSDOC Method checkInt 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (checkInt) @return
     */
    public boolean checkInt(int actual, int expected, String comment)
    {

        if (actual == expected)
        {
            checkPass(comment);

            return true;
        }
        else
        {
            checkFail(comment);

            return false;
        }
    }

    /**
     * NEEDSDOC Method checkLong 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (checkLong) @return
     */
    public boolean checkLong(long actual, long expected, String comment)
    {

        if (actual == expected)
        {
            checkPass(comment);

            return true;
        }
        else
        {
            checkFail(comment);

            return false;
        }
    }

    /**
     * NEEDSDOC Method checkFloat 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (checkFloat) @return
     */
    public boolean checkFloat(float actual, float expected, String comment)
    {

        if (actual == expected)
        {
            checkPass(comment);

            return true;
        }
        else
        {
            checkFail(comment);

            return false;
        }
    }

    /**
     * NEEDSDOC Method checkDouble 
     *
     *
     * NEEDSDOC @param actual
     * NEEDSDOC @param expected
     * NEEDSDOC @param comment
     *
     * NEEDSDOC (checkDouble) @return
     */
    public boolean checkDouble(double actual, double expected, String comment)
    {

        if (actual == expected)
        {
            checkPass(comment);

            return true;
        }
        else
        {
            checkFail(comment);

            return false;
        }
    }

    /**
     * Compares actual and expected (String), and logs the result, pass/fail.
     * <p><b>Special note for checkString:</b></p>
     * <p>Since this takes a String object and not a primitive type,
     * it works slightly differently than other check{Type} methods.</p>
     * <ui>
     * <li>If both are null, then Pass</li>
     * <li>Else If actual.compareTo(expected) == 0 than Pass</li>
     * <li>Else Fail</li>
     * </ui>
     * @author Shane_Curcuru@lotus.com
     * @param actual String returned from your test code.
     * @param expected String that test should return to pass.
     * @param comment to log out with result.
     * @see #checkPass
     * @see #checkFail
     * @see #checkObject
     *
     * NEEDSDOC ($objectName$) @return
     */
    public boolean checkString(String actual, String expected, String comment)
    {

        // Pass if both null, or both valid & equals
        if (actual != null)
        {

            // .compareTo returns 0 if the strings match lexicographically
            if ((expected != null) && (actual.compareTo(expected) == 0))
            {
                checkPass(comment);

                return true;
            }
            else
            {
                checkFail(comment);

                return false;
            }
        }
        else
        {  // actual is null, so can't use .equals
            if (expected == null)
            {
                checkPass(comment);

                return true;
            }
            else
            {
                checkFail(comment);

                return false;
            }
        }
    }

    /**
     * Uses an external CheckService to Compares actual and expected,
     * and logs the result, pass/fail.
     * <p>CheckServices may be implemented to do custom equivalency
     * checking between complex object types. It is the responsibility
     * of the CheckService to call back into us to report results.</p>
     * @author Shane_Curcuru@lotus.com
     * @param CheckService implementation to use
     *
     * @param service a non-null CheckService implementation for 
     * this type of actual and expected object
     * @param actual Object returned from your test code.
     * @param expected Object that test should return to pass.
     * @param comment to log out with result.
     * @return status true if PASS_RESULT, false otherwise
     * @see #checkPass
     * @see #checkFail
     * @see #check
     */
    public boolean check(CheckService service, Object actual,
                         Object expected, String comment)
    {

        if (service == null)
        {
            checkErr("CheckService null for: " + comment);

            return false;
        }

        if (service.check(this, actual, expected, comment) == PASS_RESULT)
            return true;
        else
            return false;
    }

    /**
     * Uses an external CheckService to Compares actual and expected,
     * and logs the result, pass/fail.
     */
    public boolean check(CheckService service, Object actual,
                         Object expected, String comment, String id)
    {

        if (service == null)
        {
            checkErr("CheckService null for: " + comment);

            return false;
        }

        if (service.check(this, actual, expected, comment, id) == PASS_RESULT)
            return true;
        else
            return false;
    }

    /** Flag to control internal debugging of Reporter; sends extra info to System.out. */
    protected boolean debug = false;

    /**
     * Accessor for internal debugging flag.  
     *
     * NEEDSDOC ($objectName$) @return
     */
    public boolean getDebug()
    {
        return (debug);
    }

    /**
     * Accessor for internal debugging flag.  
     *
     * NEEDSDOC @param setDbg
     */
    public void setDebug(boolean setDbg)
    {

        debug = setDbg;

        debugPrintln("setDebug enabled");  // will only print if setDbg was true
    }

    /**
     * Basic debugging output wrapper for Reporter.  
     *
     * NEEDSDOC @param msg
     */
    public void debugPrintln(String msg)
    {

        if (!debug)
            return;

        // If we have reporters, use them
        if (numLoggers > 0)
            logCriticalMsg("RI.dP: " + msg);

            // Otherwise, just dump to the console
        else
            System.out.println("RI.dP: " + msg);
    }

    /**
     * Utility method to increment result counters.  
     *
     * NEEDSDOC @param ctrOffset
     * NEEDSDOC @param r
     */
    public void incrementResultCounter(int ctrOffset, int r)
    {

        switch (r)
        {
        case INCP_RESULT :
            incpCount[ctrOffset]++;
            break;
        case PASS_RESULT :
            passCount[ctrOffset]++;
            break;
        case AMBG_RESULT :
            ambgCount[ctrOffset]++;
            break;
        case FAIL_RESULT :
            failCount[ctrOffset]++;
            break;
        case ERRR_RESULT :
            errrCount[ctrOffset]++;
            break;
        default :
            ;  // NEEDSWORK: should we report this, or allow users to add their own counters?
        }
    }

    /**
     * Utility method to translate an int result to a string.  
     *
     * NEEDSDOC @param r
     *
     * NEEDSDOC ($objectName$) @return
     */
    public static String resultToString(int r)
    {

        switch (r)
        {
        case INCP_RESULT :
            return (INCP);
        case PASS_RESULT :
            return (PASS);
        case AMBG_RESULT :
            return (AMBG);
        case FAIL_RESULT :
            return (FAIL);
        case ERRR_RESULT :
            return (ERRR);
        default :
            return ("Unkn");  // NEEDSWORK: should have better constant for this
        }
    }
}  // end of class Reporter