AccumulatingVisitorExceptionSink.java
biz/hammurapi/util/AccumulatingVisitorExceptionSink.java
Violations
Inspector |
Message |
Severity |
Location |
Java Inspector 048 |
Copyrights information should be present in each file. |
1 |
|
Java Inspector 058 |
Make inner classes "private" |
1 |
38:9
|
Java Inspector 068 |
Do not use System.out and System.err to output logging messages. Use loggers instead. |
2 |
87:43
|
Java Inspector 068 |
Do not use System.out and System.err to output logging messages. Use loggers instead. |
2 |
88:43
|
Java Inspector 068 |
Do not use System.out and System.err to output logging messages. Use loggers instead. |
2 |
89:43
|
Java Inspector 089 |
Type is not documented |
2 |
35:1
|
Java Inspector 089 |
Non-private, non-local types shall be documented |
2 |
38:9
|
Java Inspector 089 |
Undocumented method |
2 |
51:17
|
Java Inspector 089 |
Undocumented method |
2 |
55:17
|
Java Inspector 089 |
Undocumented method |
2 |
59:17
|
Java Inspector 089 |
Undocumented method |
2 |
63:17
|
Java Inspector 089 |
Undocumented method |
2 |
68:9
|
Java Inspector 089 |
Undocumented method |
2 |
72:9
|
Java Inspector 089 |
Undocumented method |
2 |
76:9
|
Java Inspector 026 |
Avoid hardwired string literals. Allowed literals: [] |
3 |
87:44
|
Java Inspector 026 |
Avoid hardwired string literals. Allowed literals: [] |
3 |
88:44
|
Java Inspector 026 |
Avoid hardwired string literals. Allowed literals: [] |
3 |
89:44
|
Java Inspector 051 |
It is good practice to call in any case super() in a constructor. |
3 |
44:17
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23package biz.hammurapi.util;
24
25import java.lang.reflect.Method;
26import java.util.Collections;
27import java.util.Iterator;
28import java.util.LinkedList;
29import java.util.List;
30
31
32
33
34
35public class AccumulatingVisitorExceptionSink implements VisitorExceptionSink {
36 private List exceptions=new LinkedList();
37
38 public class Entry {
39 private Object visitor;
40 private Exception exception;
41 private Object visitee;
42 private Method method;
43
44 Entry(Object visitor, Method method, Object visitee, Exception exception) {
45 this.visitor = visitor;
46 this.exception = exception;
47 this.visitee = visitee;
48 this.method = method;
49 }
50
51 public Exception getException() {
52 return exception;
53 }
54
55 public Method getMethod() {
56 return method;
57 }
58
59 public Object getVisitee() {
60 return visitee;
61 }
62
63 public Object getVisitor() {
64 return visitor;
65 }
66 }
67
68 public void consume(DispatchingVisitor dispatcher, Object visitor, Method method, Object visitee, Exception e) {
69 exceptions.add(new Entry(visitor, method, visitee, e));
70 }
71
72 public synchronized List getExceptions() {
73 return Collections.unmodifiableList(exceptions);
74 }
75
76 public synchronized void reset() {
77 exceptions.clear();
78 }
79
80
81
82
83 public synchronized void dump() {
84 Iterator it=exceptions.iterator();
85 while (it.hasNext()) {
86 Entry entry=(Entry) it.next();
87 System.err.println("Visitor: "+entry.getVisitor());
88 System.err.println("Method: "+entry.getMethod());
89 System.err.println("Visitee: "+entry.getVisitee());
90 entry.getException().printStackTrace();
91 }
92 }
93}
94