litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package com.temp.shared.utils;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Collect all the Issues/Throwables for all the "Context(s)" from a particular
* "Source"
*
* @author georgs
*/
public class SourceIssues {
private final String source;
private final Map<String, ContextThrowables> contextThrowablesByContext = new HashMap<String, ContextThrowables>();
public SourceIssues(String source, String context, Throwable... throwables) {
this.source = Assert.noEmpty("source", source);
add(context, throwables);
}
public void add(String context, Throwable... throwables) {
context = StringUtils.deNull(context).trim();
ContextThrowables contextThrowables = contextThrowablesByContext.get(context);
if (contextThrowables != null) {
contextThrowables.add(throwables);
} else {
contextThrowables = new ContextThrowables(context, throwables); // Validates that there is at least one Throwable!
contextThrowablesByContext.put(context, contextThrowables);
}
}
public String getSource() {
return source;
}
public boolean hasThrowables() {
return !contextThrowablesByContext.isEmpty();
}
public ContextThrowables[] getContextThrowables() {
ContextThrowables[] throwables = contextThrowablesByContext.values().toArray(new ContextThrowables[contextThrowablesByContext.size()]);
Arrays.sort(throwables);
return throwables;
}
@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
}
public StringBuilder appendTo(StringBuilder sb) {
sb.append("Issues from Source '").append(source).append("':\n");
for (ContextThrowables contextThrowables : getContextThrowables()) {
contextThrowables.appendTo(sb, 1);
}
return sb;
}
/**
* @param stream - note in GWT only println Object & String are implemented
*/
public void dumpToAsHTML(PrintStream stream, boolean fullStackTrace) {
stream.println("<pre>");
stream.println("Issues from Source '" + source + "':");
for (ContextThrowables contextThrowables : getContextThrowables()) {
stream.println("<ul>");
contextThrowables.dumpToAsHTML(stream, fullStackTrace);
stream.println("</ul>");
}
stream.println("</pre>");
}
}
|
Revision |
Author |
Commited |
Message |
626
|
GeorgeS
|
Wed 11 Apr, 2012 19:39:41 +0000 |
|