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

Source code

1/*
2 * hgcommons 9
3 * Hammurapi Group Common Library
4 * Copyright (C) 2003 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21 * e-Mail: support@hammurapi.biz
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 * @author Pavel Vlasov
33 * @revision $Revision: 1.1 $
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