ICoverageNode.java
1/*******************************************************************************
2 * Copyright (c) 2009 Mountainminds GmbH & Co. KG and others
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 * Marc R. Hoffmann - initial API and implementation
10 *
11 * $Id: $
12 *******************************************************************************/
13package org.jacoco.core.analysis;
14
15/**
16 * Interface for hierarchical coverage data nodes with different coverage
17 * counters.
18 *
19 * @author Marc R. Hoffmann
20 * @version $Revision: $
21 */
22public interface ICoverageNode {
23
24 /**
25 * Type of a Java element represented by a {@link ICoverageNode} instance.
26 */
27 public enum ElementType {
28
29 /** Method */
30 METHOD,
31
32 /** Class */
33 CLASS,
34
35 /** Source File */
36 SOURCEFILE,
37
38 /** Java Package */
39 PACKAGE,
40
41 /** Bundle of Packages */
42 BUNDLE,
43
44 /** Logical Group of Bundles */
45 GROUP,
46
47 /** Coverage Session */
48 SESSION
49
50 }
51
52 /**
53 * Parameter type for generic counter access.
54 */
55 public enum CounterEntity {
56
57 /** Counter for instructions */
58 INSTRUCTION,
59
60 /** Counter for basic blocks */
61 BLOCK,
62
63 /** Counter for source lines */
64 LINE,
65
66 /** Counter for methods */
67 METHOD,
68
69 /** Counter for classes */
70 CLASS
71 }
72
73 /**
74 * Returns the type of element represented by this node.
75 *
76 * @return type of this node
77 */
78 public abstract ElementType getElementType();
79
80 /**
81 * Returns the name of this node.
82 *
83 * @return name of this node
84 */
85 public String getName();
86
87 /**
88 * Returns the counter for byte code instructions.
89 *
90 * @return counter for instructions
91 */
92 public abstract ICounter getInstructionCounter();
93
94 /**
95 * Returns the counter for blocks.
96 *
97 * @return counter for blocks
98 */
99 public ICounter getBlockCounter();
100
101 /**
102 * Returns the counter for lines.
103 *
104 * @return counter for lines
105 */
106 public ICounter getLineCounter();
107
108 /**
109 * Returns the counter for methods.
110 *
111 * @return counter for methods
112 */
113 public ICounter getMethodCounter();
114
115 /**
116 * Returns the counter for classes.
117 *
118 * @return counter for classes
119 */
120 public ICounter getClassCounter();
121
122 /**
123 * Generic access to the the counters.
124 *
125 * @param entity
126 * entity we're we want to have the counter for
127 * @return counter for the given entity
128 */
129 public ICounter getCounter(CounterEntity entity);
130
131 /**
132 * Returns the line coverage information if this node represents a source
133 * file or a part of a source file.
134 *
135 * @return line coverage or <code>null</code>
136 */
137 public ILines getLines();
138
139 /**
140 * Creates a plain copy of this node. While {@link ICoverageNode}
141 * implementations may contain heavy data structures, the copy returned by
142 * this method is reduced to the counters only. This helps tp save memory
143 * while processing huge structures.
144 *
145 * @return copy with counters only
146 */
147 public ICoverageNode getPlainCopy();
148
149}