blob: d1b4784acda09f6236d5336a089f5f4bba757ea0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*******************************************************************************
* Copyright (c) 2009 STMicroelectronics.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.model;
import java.util.LinkedList;
public abstract class AbstractTreeElement implements TreeElement{
/**
*
*/
private static final long serialVersionUID = -4911602250295116203L;
private final TreeElement parent;
private final LinkedList<TreeElement> children = new LinkedList<>();
private final String name;
private final int totalLines;
private final int executedLines;
private final int instrumentedLines;
public AbstractTreeElement(TreeElement parent, String name, int totalLines,
int executedLines, int instrumentedLines) {
this.parent = parent;
this.name = name;
this.totalLines = totalLines;
this.executedLines = executedLines;
this.instrumentedLines = instrumentedLines;
}
@Override
public TreeElement getParent() {
return parent;
}
@Override
public boolean hasChildren() {
return (children.size()>0);
}
@Override
public LinkedList<? extends TreeElement> getChildren() {
return children;
}
@Override
public String getName() {
return name;
}
@Override
public TreeElement getRoot() {
if (parent == null) {
return this;
}
return parent.getRoot();
}
@Override
public int getExecutedLines() {
return executedLines;
}
@Override
public int getInstrumentedLines() {
return instrumentedLines;
}
@Override
public float getCoveragePercentage() {
if (instrumentedLines !=0 ) {
return (100.f*executedLines)/(instrumentedLines);
}
else return 0;
}
public void addChild(TreeElement child){
children.add(child);
}
@Override
public int getTotalLines() {
return totalLines;
}
}
|