01: package fit;
02:
03: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
04: // Released under the terms of the GNU General Public License version 2 or later.
05:
06: import java.util.*;
07:
08: public class Summary extends Fixture {
09: public static String countsKey = "counts";
10:
11: public void doTable(Parse table) {
12: summary.put(countsKey, counts());
13: SortedSet keys = new TreeSet(summary.keySet());
14: table.parts.more = rows(keys.iterator());
15: }
16:
17: protected Parse rows(Iterator keys) {
18: if (keys.hasNext()) {
19: Object key = keys.next();
20: Parse result = tr(td(key.toString(), td(summary.get(key)
21: .toString(), null)), rows(keys));
22: if (key.equals(countsKey)) {
23: mark(result);
24: }
25: return result;
26: } else {
27: return null;
28: }
29: }
30:
31: protected Parse tr(Parse parts, Parse more) {
32: return new Parse("tr", null, parts, more);
33: }
34:
35: protected Parse td(String body, Parse more) {
36: return new Parse("td", info(body), null, more);
37: }
38:
39: protected void mark(Parse row) {
40: // mark summary good/bad without counting beyond here
41: Counts official = counts;
42: counts = new Counts();
43: Parse cell = row.parts.more;
44: if (official.wrong + official.exceptions > 0) {
45: wrong(cell);
46: } else {
47: right(cell);
48: }
49: counts = official;
50: }
51:
52: }
|