1
/*******************************************************************************
2
* Copyright (c) 2009 STMicroelectronics.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.linuxtools.internal.gcov.model;
13
import java.util.LinkedList;
15
public abstract class AbstractTreeElement implements TreeElement{
20
private static final long serialVersionUID = -4911602250295116203L;
21
private final TreeElement parent;
22
private final LinkedList<TreeElement> children = new LinkedList<TreeElement>();
23
private final String name;
24
private final int totalLines;
25
private final int executedLines;
26
private final int instrumentedLines;
28
public AbstractTreeElement(TreeElement parent, String name, int totalLines,
29
int executedLines, int instrumentedLines) {
32
this.totalLines = totalLines;
33
this.executedLines = executedLines;
34
this.instrumentedLines = instrumentedLines;
37
public TreeElement getParent() {
41
public boolean hasChildren() {
42
return (children.size()>0);
45
public LinkedList<? extends TreeElement> getChildren() {
49
public String getName() {
53
public TreeElement getRoot() {
54
if (parent == null) return this;
55
return parent.getRoot();
58
public int getExecutedLines() {
62
public int getInstrumentedLines() {
63
return instrumentedLines;
66
public float getCoveragePercentage() {
67
if (instrumentedLines !=0 )
68
return (100.f*executedLines)/(instrumentedLines);
72
public void addChild(TreeElement child){
76
public int getTotalLines() {
b'\\ No newline at end of file'