PrimitivesVisualizer.java
biz/hammurapi/swing/PrimitivesVisualizer.java
Violations
Inspector |
Message |
Severity |
Location |
Java Inspector 048 |
Copyrights information should be present in each file. |
1 |
|
Java Inspector 089 |
Type is not documented |
2 |
35:1
|
Java Inspector 089 |
Undocumented constructor |
2 |
40:17
|
Java Inspector 089 |
Undocumented method |
2 |
45:17
|
Java Inspector 089 |
Undocumented method |
2 |
54:17
|
Java Inspector 089 |
Undocumented method |
2 |
60:9
|
Java Inspector 089 |
Undocumented method |
2 |
63:25
|
Java Inspector 089 |
Undocumented method |
2 |
70:9
|
Java Inspector 089 |
Undocumented method |
2 |
73:25
|
Java Inspector 089 |
Undocumented method |
2 |
80:9
|
Java Inspector 089 |
Undocumented method |
2 |
83:25
|
Java Inspector 089 |
Undocumented method |
2 |
90:9
|
Java Inspector 089 |
Undocumented method |
2 |
93:25
|
Java Inspector 025 |
Avoid hardwired numeric literals. Allowed literals: [1, -1, 0] |
3 |
46:70
|
Java Inspector 026 |
Avoid hardwired string literals. Allowed literals: [] |
3 |
41:44
|
Java Inspector 026 |
Avoid hardwired string literals. Allowed literals: [] |
3 |
41:72
|
Java Inspector 026 |
Avoid hardwired string literals. Allowed literals: [] |
3 |
47:63
|
Java Inspector 026 |
Avoid hardwired string literals. Allowed literals: [] |
3 |
47:71
|
Java Inspector 054 |
Discourage usage of instance variables like a, j by enforcing minimal variable name length (3). |
3 |
38: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.swing;
24
25import java.util.List;
26
27import javax.swing.table.DefaultTableModel;
28import javax.swing.table.TableModel;
29import javax.swing.tree.TreeNode;
30
31
32
33
34
35public class PrimitivesVisualizer {
36
37 private static class PrimitiveVisualizable extends LazyTreeNodeTableVisualizable {
38 Object o;
39
40 public PrimitiveVisualizable(TreeNode parent, String name, Object o) {
41 super(parent, name+" ["+o.getClass().getName()+"] "+o, EMPTY_LIST);
42 this.o = o;
43 }
44
45 public TableModel toTable() {
46 DefaultTableModel tm=new DefaultTableModel(1,2);
47 tm.setColumnIdentifiers(new String[] {"Type", "Value"});
48 tm.setValueAt(o.getClass().getName(), 0, 0);
49 tm.setValueAt(o, 0, 1);
50
51 return tm;
52 }
53
54 protected List loadChildren() {
55 return EMPTY_LIST;
56 }
57
58 }
59
60 public Visualizable convert(final String o) {
61 return new Visualizable() {
62
63 public TreeNode toTreeNode(TreeNode parent, String title) {
64 return new PrimitiveVisualizable(parent, title, o);
65 }
66
67 };
68 }
69
70 public Visualizable convert(final Number o) {
71 return new Visualizable() {
72
73 public TreeNode toTreeNode(TreeNode parent, String title) {
74 return new PrimitiveVisualizable(parent, title, o);
75 }
76
77 };
78 }
79
80 public Visualizable convert(final Boolean o) {
81 return new Visualizable() {
82
83 public TreeNode toTreeNode(TreeNode parent, String title) {
84 return new PrimitiveVisualizable(parent, title, o);
85 }
86
87 };
88 }
89
90 public Visualizable convert(final Character o) {
91 return new Visualizable() {
92
93 public TreeNode toTreeNode(TreeNode parent, String title) {
94 return new PrimitiveVisualizable(parent, title, o);
95 }
96
97 };
98 }
99}
100