Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 106 |  | 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 java.util.ArrayList;
5 |  | import java.util.List;
6 |  |
7 |  | import javax.swing.event.TreeModelEvent;
8 |  | import javax.swing.event.TreeModelListener;
9 |  | import javax.swing.tree.TreeModel;
10 |  | import javax.swing.tree.TreePath;
11 |  |
12 |  | import net.sourceforge.pmd.ast.SimpleNode;
13 |  |
14 |  |
15 |  | /**
16 |  | * Model for the AST Panel Tree component
17 |  | *
18 |  | * @author Boris Gruschko ( boris at gruschko.org )
19 |  | * @version $Id: ASTModel.java,v 1.11 2006/10/20 02:40:14 hooperbloob Exp $
20 |  | */
21 |  |
22 |  | public class ASTModel implements TreeModel {
23 |  |
24 |  | private SimpleNode root;
25 |  | private List listeners = new ArrayList(1);
26 |  |
27 |  | /**
28 |  | * creates the tree model
29 |  | *
30 |  | * @param root tree's root
31 |  | */
32 | 0 | public ASTModel(SimpleNode root) {
33 | 0 | this.root = root;
34 |  | }
35 |  |
36 |  | /**
37 |  | * @see javax.swing.tree.TreeModel
38 |  | */
39 | 0 | public Object getChild(Object parent, int index) {
40 | 0 | return ((SimpleNode) parent).jjtGetChild(index);
41 |  | }
42 |  |
43 |  | /**
44 |  | * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
45 |  | */
46 | 0 | public int getChildCount(Object parent) {
47 | 0 | return ((SimpleNode) parent).jjtGetNumChildren();
48 |  | }
49 |  |
50 |  | /**
51 |  | * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object,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,java.lang.Object)
78 |  | */
79 | 0 | public void valueForPathChanged(TreePath path, Object newValue) {
80 | 0 | throw new UnsupportedOperationException();
81 |  | }
82 |  |
83 |  | /**
84 |  | * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
85 |  | */
86 | 0 | public void addTreeModelListener(TreeModelListener l) {
87 | 0 | listeners.add(l);
88 |  | }
89 |  |
90 |  |
91 |  | /**
92 |  | * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
93 |  | */
94 | 0 | public void removeTreeModelListener(TreeModelListener l) {
95 | 0 | listeners.remove(l);
96 |  | }
97 |  |
98 |  |
99 | 0 | protected void fireTreeModelEvent(TreeModelEvent e) {
100 | 0 | for (int i = 0; i < listeners.size(); i++) {
101 | 0 | ((TreeModelListener) listeners.get(i)).treeNodesChanged(e);
102 |  | }
103 |  | }
104 |  |
105 |  | }
106 |  |