01: package com.avaje.util.codegen;
02:
03: import java.util.ArrayList;
04:
05: public class GenerateLog {
06:
07: ArrayList log = new ArrayList();
08:
09: ArrayList lookups = new ArrayList();
10:
11: ArrayList intersections = new ArrayList();
12:
13: ArrayList hairys = new ArrayList();
14:
15: String newLine = "\n";
16:
17: public String summary(boolean withAll) {
18:
19: StringBuffer sb = new StringBuffer();
20: sb.append(newLine);
21:
22: if (withAll) {
23: summary("Matched:", sb, log);
24: }
25:
26: summary("Lookup:", sb, lookups);
27: summary("Hairy:", sb, hairys);
28: summary("Intersection:", sb, intersections);
29:
30: return sb.toString();
31: }
32:
33: private void summary(String title, StringBuffer sb, ArrayList list) {
34:
35: sb.append(newLine + title + newLine);
36: sb.append("-------------------------------------" + newLine);
37:
38: for (int i = 0; i < list.size(); i++) {
39: sb.append(list.get(i).toString() + newLine);
40: }
41: }
42:
43: public void add(GenerateInfo info) {
44: log.add(new Entry(info));
45: }
46:
47: public void addLookup(GenerateInfo info) {
48: lookups.add(new Entry(info));
49: }
50:
51: public void addHairy(GenerateInfo info) {
52: hairys.add(new Entry(info));
53: }
54:
55: public void addIntersection(GenerateInfo info) {
56: intersections.add(new Entry(info));
57: }
58:
59: class Entry {
60:
61: GenerateInfo info;
62:
63: Entry(GenerateInfo info) {
64: this .info = info;
65: }
66:
67: public String toString() {
68: return info.toString();
69: }
70: }
71: }
|