|
1 |
| package net.sourceforge.pmd.dfa.report; |
|
2 |
| |
|
3 |
| import java.util.ArrayList; |
|
4 |
| import java.util.List; |
|
5 |
| |
|
6 |
| public abstract class AbstractReportNode { |
|
7 |
| private List childNodes = new ArrayList(); |
|
8 |
| private AbstractReportNode parentNode = null; |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| private int numberOfViolations; |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| public abstract boolean equalsNode(AbstractReportNode arg0); |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
0
| public AbstractReportNode getFirstChild() {
|
|
25 |
0
| if (this.isLeaf()) {
|
|
26 |
0
| return null;
|
|
27 |
| } |
|
28 |
0
| return (AbstractReportNode) this.childNodes.get(0);
|
|
29 |
| } |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
0
| public AbstractReportNode getNextSibling() {
|
|
35 |
0
| if (this.parentNode == null) {
|
|
36 |
0
| return null;
|
|
37 |
| } |
|
38 |
0
| int index = this.parentNode.getChildIndex(this);
|
|
39 |
0
| if (index < 0) {
|
|
40 |
0
| return null;
|
|
41 |
| } |
|
42 |
0
| if (index >= this.parentNode.childNodes.size() - 1) {
|
|
43 |
0
| return null;
|
|
44 |
| } |
|
45 |
0
| return (AbstractReportNode) this.parentNode.childNodes.get(index + 1);
|
|
46 |
| } |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
0
| private int getChildIndex(AbstractReportNode child) {
|
|
52 |
0
| for (int i = 0; i < this.childNodes.size(); i++) {
|
|
53 |
0
| if (this.childNodes.get(i).equals(child)) {
|
|
54 |
0
| return i;
|
|
55 |
| } |
|
56 |
| } |
|
57 |
0
| return -1;
|
|
58 |
| } |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
1303
| public void addFirst(AbstractReportNode child) {
|
|
64 |
1303
| this.childNodes.add(0, child);
|
|
65 |
1303
| child.parentNode = this;
|
|
66 |
| } |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
2868
| public void add(AbstractReportNode child) {
|
|
72 |
2868
| this.childNodes.add(child);
|
|
73 |
2868
| child.parentNode = this;
|
|
74 |
| } |
|
75 |
| |
|
76 |
8
| public void addNumberOfViolation(int number) {
|
|
77 |
8
| this.numberOfViolations += number;
|
|
78 |
| } |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
14
| public int getNumberOfViolations() {
|
|
84 |
14
| return numberOfViolations;
|
|
85 |
| } |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
12
| public void childrenAccept(ReportVisitor visitor) {
|
|
90 |
12
| for (int i = 0; i < childNodes.size(); i++) {
|
|
91 |
8
| AbstractReportNode node = (AbstractReportNode) childNodes.get(i);
|
|
92 |
8
| node.accept(visitor);
|
|
93 |
| } |
|
94 |
| } |
|
95 |
| |
|
96 |
12
| public void accept(ReportVisitor visitor) {
|
|
97 |
12
| visitor.visit(this);
|
|
98 |
| } |
|
99 |
| |
|
100 |
57441
| public AbstractReportNode getChildAt(int arg0) {
|
|
101 |
57441
| if (arg0 >= 0 && arg0 <= this.childNodes.size() - 1) {
|
|
102 |
57441
| return (AbstractReportNode) this.childNodes.get(arg0);
|
|
103 |
| } |
|
104 |
0
| return null;
|
|
105 |
| } |
|
106 |
| |
|
107 |
61612
| public int getChildCount() {
|
|
108 |
61612
| return this.childNodes.size();
|
|
109 |
| } |
|
110 |
| |
|
111 |
38
| public AbstractReportNode getParent() {
|
|
112 |
38
| return this.parentNode;
|
|
113 |
| } |
|
114 |
| |
|
115 |
0
| public boolean isLeaf() {
|
|
116 |
0
| return this.childNodes.isEmpty();
|
|
117 |
| } |
|
118 |
| |
|
119 |
| } |