01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: */
19: package de.schlund.pfixxml.targets;
20:
21: import java.util.ArrayList;
22: import java.util.HashMap;
23: import java.util.Iterator;
24:
25: public class TargetGenerationReport {
26: private final HashMap<String, ArrayList<Exception>> hash;
27:
28: public TargetGenerationReport() {
29: this .hash = new HashMap<String, ArrayList<Exception>>();
30: }
31:
32: public void addError(Exception e, String project) {
33: if (hash.get(project) == null) {
34: ArrayList<Exception> list = new ArrayList<Exception>();
35: list.add(e);
36: hash.put(project, list);
37: } else {
38: hash.get(project).add(e);
39: }
40: }
41:
42: public String toString() {
43: StringBuffer buf = new StringBuffer(255);
44: String prod_break = "'============================================================================================'\n";
45: String ex_break = "|----------------------------------------------------------------------------------\n";
46: if (hash.isEmpty()) {
47: StringBuffer sb = new StringBuffer();
48: sb.append(prod_break);
49: sb.append("| No exceptions\n");
50: sb.append(prod_break);
51: return sb.toString();
52: }
53: Iterator<String> iter = hash.keySet().iterator();
54: while (iter.hasNext()) {
55: String key = iter.next();
56: buf.append(prod_break);
57: buf.append("| Project: ").append(key).append("\n");
58: ArrayList<Exception> exs = hash.get(key);
59: buf.append("| Exceptions: ").append("\n");
60: for (int i = 0; i < exs.size(); i++) {
61: TargetGenerationException tgex = (TargetGenerationException) exs
62: .get(i);
63: String str = tgex.toStringRepresentation();
64: buf.append(str);
65: if (exs.size() - 1 > i)
66: buf.append(ex_break);
67: }
68: buf.append(prod_break);
69: }
70: return buf.toString();
71: }
72: }
|