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

file stats: | LOC: | 108 |  | Methods: | 10
| NCLOC: | 49 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

ASTModel.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.event.TreeModelEvent;
7 |  | import javax.swing.event.TreeModelListener;
8 |  | import javax.swing.tree.TreeModel;
9 |  | import javax.swing.tree.TreePath;
10 |  | import java.util.Vector;
11 |  |
12 |  |
13 |  | /**
14 |  | * Model for the AST Panel Tree component
15 |  | *
16 |  | * @author Boris Gruschko ( boris at gruschko.org )
17 |  | * @version $Id: ASTModel.java,v 1.9 2006/02/10 14:26:32 tomcopeland Exp $
18 |  | */
19 |  |
20 |  | public class ASTModel
21 |  | implements TreeModel {
22 |  | private SimpleNode root;
23 |  | private Vector listeners = new Vector(1);
24 |  |
25 |  | /**
26 |  | * creates the tree model
27 |  | *
28 |  | * @param root tree's root
29 |  | */
30 | 0 | public ASTModel(SimpleNode root) {
31 | 0 | this.root = root;
32 |  | }
33 |  |
34 |  | /**
35 |  | * @see javax.swing.tree.TreeModel
36 |  | */
37 | 0 | public Object getChild(Object parent, int index) {
38 | 0 | return ((SimpleNode) parent).jjtGetChild(index);
39 |  | }
40 |  |
41 |  | /**
42 |  | * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
43 |  | */
44 | 0 | public int getChildCount(Object parent) {
45 | 0 | return ((SimpleNode) parent).jjtGetNumChildren();
46 |  | }
47 |  |
48 |  | /**
49 |  | * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object,
50 |  | * <p/>
51 |  | * java.lang.Object)
52 |  | */
53 | 0 | public int getIndexOfChild(Object parent, Object child) {
54 | 0 | SimpleNode node = ((SimpleNode) parent);
55 | 0 | for (int i = 0; i < node.jjtGetNumChildren(); i++)
56 | 0 | if (node.jjtGetChild(i).equals(child)) {
57 | 0 | return i;
58 |  | }
59 | 0 | return -1;
60 |  | }
61 |  |
62 |  | /**
63 |  | * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
64 |  | */
65 | 0 | public boolean isLeaf(Object node) {
66 | 0 | return ((SimpleNode) node).jjtGetNumChildren() == 0;
67 |  | }
68 |  |
69 |  | /**
70 |  | * @see javax.swing.tree.TreeModel#getRoot()
71 |  | */
72 | 0 | public Object getRoot() {
73 | 0 | return root;
74 |  | }
75 |  |
76 |  | /**
77 |  | * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath,
78 |  | * <p/>
79 |  | * java.lang.Object)
80 |  | */
81 | 0 | public void valueForPathChanged(TreePath path, Object newValue) {
82 | 0 | throw new UnsupportedOperationException();
83 |  | }
84 |  |
85 |  | /**
86 |  | * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
87 |  | */
88 | 0 | public void addTreeModelListener(TreeModelListener l) {
89 | 0 | listeners.add(l);
90 |  | }
91 |  |
92 |  |
93 |  | /**
94 |  | * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
95 |  | */
96 | 0 | public void removeTreeModelListener(TreeModelListener l) {
97 | 0 | listeners.remove(l);
98 |  | }
99 |  |
100 |  |
101 | 0 | protected void fireTreeModelEvent(TreeModelEvent e) {
102 | 0 | for (int i = 0; i < listeners.size(); i++) {
103 | 0 | ((TreeModelListener) listeners.elementAt(i)).treeNodesChanged(e);
104 |  | }
105 |  | }
106 |  |
107 |  | }
108 |  |