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

file stats: | LOC: | 118 |  | Methods: | 13
| NCLOC: | 73 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

AbstractReportNode.java

6.2%

22.6%

30.8%

20%

1 |  | package net.sourceforge.pmd.dfa.report;
2 |  |
3 |  | import java.util.ArrayList;
4 |  |
5 |  | public abstract class AbstractReportNode {
6 |  | private ArrayList childNodes = new ArrayList();
7 |  | private AbstractReportNode parentNode = null;
8 |  |
9 |  | /*
10 |  | * Number of all RuleViolations down to this node. At the moment it will
11 |  | * only be calculated by running the ReportHTMLPrintVisitor.
12 |  | * */
13 |  | private int numberOfViolations;
14 |  |
15 |  | /**
16 |  | * Should compare to nodes of the tree.
17 |  | */
18 |  | public abstract boolean equalsNode(AbstractReportNode arg0);
19 |  |
20 |  | /**
21 |  | * @return null If there isn't any child.
22 |  | */
23 | 0 | public AbstractReportNode getFirstChild() {
24 | 0 | if (this.isLeaf()) {
25 | 0 | return null;
26 |  | }
27 | 0 | return (AbstractReportNode) this.childNodes.get(0);
28 |  | }
29 |  |
30 |  | /**
31 |  | * @return null If there isn't any sibling.
32 |  | */
33 | 0 | public AbstractReportNode getNextSibling() {
34 | 0 | if (this.parentNode == null) {
35 | 0 | return null;
36 |  | }
37 | 0 | int index = this.parentNode.getChildIndex(this);
38 | 0 | if (index < 0) {
39 | 0 | return null;
40 |  | }
41 | 0 | if (index >= this.parentNode.childNodes.size() - 1) {
42 | 0 | return null;
43 |  | }
44 | 0 | return (AbstractReportNode) this.parentNode.childNodes.get(index + 1);
45 |  | }
46 |  |
47 |  | /**
48 |  | * @return index The index of the x-th child of his parent.
49 |  | */
50 | 0 | private int getChildIndex(AbstractReportNode child) {
51 | 0 | for (int i = 0; i < this.childNodes.size(); i++) {
52 | 0 | if (this.childNodes.get(i).equals(child)) {
53 | 0 | return i;
54 |  | }
55 |  | }
56 | 0 | return -1;
57 |  | }
58 |  |
59 |  | /**
60 |  | * Adds the child in front of any other childs.
61 |  | */
62 | 1092 | public void addFirst(AbstractReportNode child) {
63 | 1092 | this.childNodes.add(0, child);
64 | 1092 | child.parentNode = this;
65 |  | }
66 |  |
67 |  | /**
68 |  | * Adds the child at the end.
69 |  | */
70 | 2651 | public void add(AbstractReportNode child) {
71 | 2651 | this.childNodes.add(child);
72 | 2651 | child.parentNode = this;
73 |  | }
74 |  |
75 | 0 | public void addNumberOfViolation(int number) {
76 | 0 | this.numberOfViolations += number;
77 |  | }
78 |  |
79 |  | /**
80 |  | * @return The number of all violations downside the node.
81 |  | */
82 | 0 | public int getNumberOfViolations() {
83 | 0 | return numberOfViolations;
84 |  | }
85 |  |
86 |  | // ----------------------------------------------------------------------------
87 |  | // visitor methods
88 | 0 | public void childrenAccept(ReportVisitor visitor) {
89 | 0 | for (int i = 0; i < childNodes.size(); i++) {
90 | 0 | AbstractReportNode node = (AbstractReportNode) childNodes.get(i);
91 | 0 | node.accept(visitor);
92 |  | }
93 |  | }
94 |  |
95 | 0 | public void accept(ReportVisitor visitor) {
96 | 0 | visitor.visit(this);
97 |  | }
98 |  |
99 | 46078 | public AbstractReportNode getChildAt(int arg0) {
100 | 46078 | if (arg0 >= 0 && arg0 <= this.childNodes.size() - 1) {
101 | 46078 | return (AbstractReportNode) this.childNodes.get(arg0);
102 |  | }
103 | 0 | return null;
104 |  | }
105 |  |
106 | 49821 | public int getChildCount() {
107 | 49821 | return this.childNodes.size();
108 |  | }
109 |  |
110 | 0 | public AbstractReportNode getParent() {
111 | 0 | return this.parentNode;
112 |  | }
113 |  |
114 | 0 | public boolean isLeaf() {
115 | 0 | return this.childNodes.isEmpty();
116 |  | }
117 |  |
118 |  | }