Clover coverage report - PMD - 3.7
Coverage timestamp: Wed May 31 2006 09:25:59 EDT

file stats: | LOC: | 126 |  | Methods: | 11
| NCLOC: | 56 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

SimpleNodeTreeNodeAdapter.java

0%

0%

0%

0%

1 |  | package net.sourceforge.pmd.util.viewer.model;
2 |  |
3 |  |
4 |  | import net.sourceforge.pmd.ast.SimpleNode;
5 |  |
6 |  | import javax.swing.tree.TreeNode;
7 |  | import java.util.ArrayList;
8 |  | import java.util.Collections;
9 |  | import java.util.Enumeration;
10 |  | import java.util.List;
11 |  |
12 |  |
13 |  | /**
14 |  | * provides the adapter for the tree model
15 |  | *
16 |  | * @author Boris Gruschko ( boris at gruschko.org )
17 |  | * @version $Id: SimpleNodeTreeNodeAdapter.java,v 1.9 2006/02/10 14:26:32 tomcopeland Exp $
18 |  | */
19 |  |
20 |  | public class SimpleNodeTreeNodeAdapter
21 |  | implements TreeNode {
22 |  | private SimpleNode node;
23 |  | private List children;
24 |  | private SimpleNodeTreeNodeAdapter parent;
25 |  |
26 |  | /**
27 |  | * constructs the node
28 |  | *
29 |  | * @param node underlying AST's node
30 |  | */
31 | 0 | public SimpleNodeTreeNodeAdapter(SimpleNodeTreeNodeAdapter parent, SimpleNode node) {
32 | 0 | this.parent = parent;
33 | 0 | this.node = node;
34 |  | }
35 |  |
36 |  | /**
37 |  | * retrieves the underlying node
38 |  | *
39 |  | * @return AST node
40 |  | */
41 | 0 | public SimpleNode getSimpleNode() {
42 | 0 | return node;
43 |  | }
44 |  |
45 |  |
46 |  | /**
47 |  | * @see javax.swing.tree.TreeNode#getChildAt(int)
48 |  | */
49 | 0 | public TreeNode getChildAt(int childIndex) {
50 | 0 | checkChildren();
51 | 0 | return (TreeNode) children.get(childIndex);
52 |  | }
53 |  |
54 |  |
55 |  | /**
56 |  | * @see javax.swing.tree.TreeNode#getChildCount()
57 |  | */
58 | 0 | public int getChildCount() {
59 | 0 | checkChildren();
60 | 0 | return children.size();
61 |  | }
62 |  |
63 |  |
64 |  | /**
65 |  | * @see javax.swing.tree.TreeNode#getParent()
66 |  | */
67 | 0 | public TreeNode getParent() {
68 | 0 | return parent;
69 |  | }
70 |  |
71 |  | /**
72 |  | * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
73 |  | */
74 | 0 | public int getIndex(TreeNode node) {
75 | 0 | checkChildren();
76 | 0 | return children.indexOf(node);
77 |  | }
78 |  |
79 |  |
80 |  | /**
81 |  | * @see javax.swing.tree.TreeNode#getAllowsChildren()
82 |  | */
83 | 0 | public boolean getAllowsChildren() {
84 | 0 | return true;
85 |  | }
86 |  |
87 |  |
88 |  | /**
89 |  | * @see javax.swing.tree.TreeNode#isLeaf()
90 |  | */
91 |  |
92 | 0 | public boolean isLeaf() {
93 | 0 | checkChildren();
94 | 0 | return children.size() == 0;
95 |  | }
96 |  |
97 |  |
98 |  | /**
99 |  | * @see javax.swing.tree.TreeNode#children()
100 |  | */
101 |  |
102 | 0 | public Enumeration children() {
103 | 0 | return Collections.enumeration(children);
104 |  | }
105 |  |
106 |  |
107 |  | /**
108 |  | * checks the children and creates them if neccessary
109 |  | */
110 | 0 | private void checkChildren() {
111 | 0 | if (children == null) {
112 | 0 | children = new ArrayList(node.jjtGetNumChildren());
113 | 0 | for (int i = 0; i < node.jjtGetNumChildren(); i++) {
114 | 0 | children.add(new SimpleNodeTreeNodeAdapter(this, (SimpleNode) node.jjtGetChild(i)));
115 |  | }
116 |  | }
117 |  | }
118 |  |
119 |  | /**
120 |  | * @see java.lang.Object#toString()
121 |  | */
122 | 0 | public String toString() {
123 | 0 | return node.toString();
124 |  | }
125 |  | }
126 |  |