• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2009, 2015 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  *******************************************************************************/
12 package org.jacoco.core.internal.instr;
13 
14 import org.jacoco.core.internal.flow.ClassProbesVisitor;
15 import org.jacoco.core.internal.flow.MethodProbesVisitor;
16 
17 /**
18  * Internal class to remember the total number of probes required for a class.
19  */
20 class ProbeCounter extends ClassProbesVisitor {
21 
22 	private int count;
23 	private boolean methods;
24 
ProbeCounter()25 	ProbeCounter() {
26 		count = 0;
27 		methods = false;
28 	}
29 
30 	@Override
visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions)31 	public MethodProbesVisitor visitMethod(final int access, final String name,
32 			final String desc, final String signature, final String[] exceptions) {
33 		if (!"<clinit>".equals(name)) {
34 			methods = true;
35 		}
36 		return null;
37 	}
38 
39 	@Override
visitTotalProbeCount(final int count)40 	public void visitTotalProbeCount(final int count) {
41 		this.count = count;
42 	}
43 
getCount()44 	int getCount() {
45 		return count;
46 	}
47 
48 	/**
49 	 * @return <code>true</code> if the class has other methods than a static
50 	 *         initializer
51 	 */
hasMethods()52 	boolean hasMethods() {
53 		return methods;
54 	}
55 
56 }
57