01: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
02: // Released under the terms of the GNU General Public License version 2 or later.
03:
04: package eg;
05:
06: import fit.*;
07: import java.util.*;
08:
09: public class AllCombinations extends AllFiles {
10:
11: protected List lists = new ArrayList();
12: protected Parse row;
13: protected int caseNumber = 1;
14:
15: public void doTable(Parse table) {
16: row = table.parts.last();
17: super .doTable(table);
18: combinations();
19: }
20:
21: protected void doRow(Parse row, List files) {
22: lists.add(files);
23: }
24:
25: protected void combinations() {
26: combinations(0, new ArrayList(lists));
27: }
28:
29: protected void combinations(int index, List combination) {
30: if (index == lists.size()) {
31: doCase(combination);
32: } else {
33: List files = (List) lists.get(index);
34: for (Iterator i = files.iterator(); i.hasNext();) {
35: combination.set(index, i.next());
36: combinations(index + 1, combination);
37: }
38: }
39: }
40:
41: protected void doCase(List combination) {
42: Parse number = tr(td("#" + caseNumber++, null), null);
43: number.leaf().addToTag(" colspan=2");
44: row.last().more = number;
45: super.doRow(number, combination);
46: }
47: }
|