aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.report/src/org/jacoco/report/IReportGroupVisitor.java
blob: 50feda3ccd6d037cf29f901c1be81b7decba9b3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
 * Copyright (c) 2009, 2023 Mountainminds GmbH & Co. KG and Contributors
 * This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Marc R. Hoffmann - initial API and implementation
 *
 *******************************************************************************/
package org.jacoco.report;

import java.io.IOException;

import org.jacoco.core.analysis.IBundleCoverage;

/**
 * Output-Interface for hierarchical report structures. To allow sequential
 * processing and save memory the group structure has to be traversed in a "deep
 * first" fashion. The interface is implemented by the report formatters and can
 * be used to emit coverage report structures.
 *
 * The following constraints apply in using {@link IReportGroupVisitor}
 * instances:
 *
 * <ul>
 * <li>A visitor instance can be used to either submit bundles (
 * {@link #visitBundle(IBundleCoverage, ISourceFileLocator)}) or groups
 * {@link #visitGroup(String)}). Bundles and groups are not allowed for the same
 * visitor.</li>
 * <li>When creating nested groups with {@link #visitGroup(String)} the
 * hierarchy has to be processed in a "deep first" manner.</li>
 * </ul>
 */
public interface IReportGroupVisitor {

	/**
	 * Called to add a bundle to the report.
	 *
	 * @param bundle
	 *            a bundle to include in the report
	 * @param locator
	 *            source locator for this bundle
	 * @throws IOException
	 *             in case of IO problems with the report writer
	 */
	void visitBundle(IBundleCoverage bundle, ISourceFileLocator locator)
			throws IOException;

	/**
	 * Called to add a new group to the report. The returned
	 * {@link IReportGroupVisitor} instance can be used to add nested bundles or
	 * groups. The content of the group has to be completed before this or any
	 * parent visitor can be used again ("deep first").
	 *
	 * @param name
	 *            name of the group
	 * @return visitor for the group's content
	 * @throws IOException
	 *             in case of IO problems with the report writer
	 */
	IReportGroupVisitor visitGroup(String name) throws IOException;

}