~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/model/AbstractTreeElement.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 *    Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.gcov.model;
 
12
 
 
13
import java.util.LinkedList;
 
14
 
 
15
public abstract class AbstractTreeElement implements TreeElement{
 
16
 
 
17
        /**
 
18
         * 
 
19
         */
 
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;
 
27
        
 
28
        public AbstractTreeElement(TreeElement parent, String name, int totalLines,
 
29
                        int executedLines, int instrumentedLines) {
 
30
                this.parent = parent;
 
31
                this.name = name;
 
32
                this.totalLines = totalLines;
 
33
                this.executedLines = executedLines;
 
34
                this.instrumentedLines = instrumentedLines;
 
35
        }
 
36
        
 
37
        public TreeElement getParent() {
 
38
                return parent;
 
39
        }
 
40
        
 
41
        public boolean hasChildren() {
 
42
                return (children.size()>0);
 
43
        }
 
44
 
 
45
        public LinkedList<? extends TreeElement> getChildren() {
 
46
                return children;
 
47
        }
 
48
 
 
49
        public String getName() {
 
50
                return name;
 
51
        }
 
52
        
 
53
        public TreeElement getRoot() {
 
54
                if (parent == null) return this;
 
55
                return parent.getRoot();
 
56
        }
 
57
 
 
58
        public int getExecutedLines() {
 
59
                return executedLines;
 
60
        }
 
61
        
 
62
        public int getInstrumentedLines() {
 
63
                return instrumentedLines;
 
64
        }
 
65
 
 
66
        public float getCoveragePercentage() {
 
67
                 if (instrumentedLines !=0 )
 
68
                        return (100.f*executedLines)/(instrumentedLines);
 
69
                else return 0;
 
70
        }
 
71
 
 
72
        public void addChild(TreeElement child){
 
73
                children.add(child);
 
74
        }
 
75
        
 
76
        public int getTotalLines() {
 
77
                return totalLines;
 
78
        }
 
79
}
 
 
b'\\ No newline at end of file'