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