View Javadoc

1   package fit;
2   
3   // Copyright (c) 2002 Cunningham & Cunningham, Inc.
4   // Released under the terms of the GNU General Public License version 2 or later.
5   
6   import java.util.*;
7   
8   public class Summary extends Fixture {
9       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 =
21                  tr(
22                      td(key.toString(),
23                      td(summary.get(key).toString(),
24                      null)),
25                  rows(keys));
26              if (key.equals(countsKey)) {
27                  mark (result);
28              }
29              return result;
30          } else {
31              return null;
32          }
33      }
34  
35      protected Parse tr(Parse parts, Parse more) {
36          return new Parse ("tr", null, parts, more);
37      }
38  
39      protected Parse td(String body, Parse more) {
40          return new Parse ("td", info(body), null, more);
41      }
42  
43      protected void mark(Parse row) {
44          // mark summary good/bad without counting beyond here
45          Counts official = counts;
46          counts = new Counts();
47          Parse cell = row.parts.more;
48          if (official.wrong + official.exceptions > 0) {
49              wrong(cell);
50          } else {
51              right(cell);
52          }
53          counts = official;
54      }
55  
56  }