1/*******************************************************************************
2 * Copyright (c) 2009, 2018 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.report;
13
14import java.io.IOException;
15
16import org.jacoco.core.analysis.IBundleCoverage;
17
18/**
19 * Output-Interface for hierarchical report structures. To allow sequential
20 * processing and save memory the group structure has to be traversed in a
21 * "deep first" fashion. The interface is implemented by the report formatters
22 * and can be used to emit coverage report structures.
23 *
24 * The following constraints apply in using {@link IReportGroupVisitor} instances:
25 *
26 * <ul>
27 * <li>A visitor instance can be used to either submit bundles (
28 * {@link #visitBundle(IBundleCoverage, ISourceFileLocator)}) or groups
29 * {@link #visitGroup(String)}). Bundles and groups are not allowed for the same
30 * visitor.</li>
31 * <li>When creating nested groups with {@link #visitGroup(String)} the
32 * hierarchy has to be processed in a "deep first" manner.</li>
33 * </ul>
34 */
35public interface IReportGroupVisitor {
36
37	/**
38	 * Called to add a bundle to the the report.
39	 *
40	 * @param bundle
41	 *            a bundle to include in the report
42	 * @param locator
43	 *            source locator for this bundle
44	 * @throws IOException
45	 *             in case of IO problems with the report writer
46	 */
47	void visitBundle(IBundleCoverage bundle, ISourceFileLocator locator)
48			throws IOException;
49
50	/**
51	 * Called to add a new group to the report. The returned
52	 * {@link IReportGroupVisitor} instance can be used to add nested bundles or
53	 * groups. The content of the group has to be completed before this or any
54	 * parent visitor can be used again ("deep first").
55	 *
56	 * @param name
57	 *            name of the group
58	 * @return visitor for the group's content
59	 * @throws IOException
60	 *             in case of IO problems with the report writer
61	 */
62	IReportGroupVisitor visitGroup(String name) throws IOException;
63
64}
65