ICoverageNode.java revision d7d2f75c3b74ac589b61c8d3f3a23603fd33828d
1/*******************************************************************************
2 * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors
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	}
48
49	/**
50	 * Parameter type for generic counter access.
51	 */
52	public enum CounterEntity {
53
54		/** Counter for instructions */
55		INSTRUCTION,
56
57		/** Counter for basic blocks */
58		BLOCK,
59
60		/** Counter for source lines */
61		LINE,
62
63		/** Counter for methods */
64		METHOD,
65
66		/** Counter for classes */
67		CLASS
68	}
69
70	/**
71	 * Returns the type of element represented by this node.
72	 *
73	 * @return type of this node
74	 */
75	public abstract ElementType getElementType();
76
77	/**
78	 * Returns the name of this node.
79	 *
80	 * @return name of this node
81	 */
82	public String getName();
83
84	/**
85	 * Returns the counter for byte code instructions.
86	 *
87	 * @return counter for instructions
88	 */
89	public abstract ICounter getInstructionCounter();
90
91	/**
92	 * Returns the counter for blocks.
93	 *
94	 * @return counter for blocks
95	 */
96	public ICounter getBlockCounter();
97
98	/**
99	 * Returns the counter for lines.
100	 *
101	 * @return counter for lines
102	 */
103	public ICounter getLineCounter();
104
105	/**
106	 * Returns the counter for methods.
107	 *
108	 * @return counter for methods
109	 */
110	public ICounter getMethodCounter();
111
112	/**
113	 * Returns the counter for classes.
114	 *
115	 * @return counter for classes
116	 */
117	public ICounter getClassCounter();
118
119	/**
120	 * Generic access to the the counters.
121	 *
122	 * @param entity
123	 *            entity we're we want to have the counter for
124	 * @return counter for the given entity
125	 */
126	public ICounter getCounter(CounterEntity entity);
127
128	/**
129	 * Returns the line coverage information if this node represents a source
130	 * file or a part of a source file.
131	 *
132	 * @return line coverage or <code>null</code>
133	 */
134	public ILines getLines();
135
136	/**
137	 * Creates a plain copy of this node. While {@link ICoverageNode}
138	 * implementations may contain heavy data structures, the copy returned by
139	 * this method is reduced to the counters only. This helps tp save memory
140	 * while processing huge structures.
141	 *
142	 * @return copy with counters only
143	 */
144	public ICoverageNode getPlainCopy();
145
146}