CsvGroupHandler.java
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 * Brock Janiczak - initial API and implementation
10 *
11 * $Id: $
12 *******************************************************************************/
13package org.jacoco.report.csv;
14
15import static java.lang.String.format;
16
17import java.io.IOException;
18
19import org.jacoco.core.analysis.ICoverageNode;
20import org.jacoco.core.analysis.ICoverageNode.ElementType;
21import org.jacoco.report.IReportVisitor;
22import org.jacoco.report.ISourceFileLocator;
23
24/**
25 * Report visitor that handles coverage information for groups.
26 *
27 * @author Brock Janiczak
28 * @version $Revision: $
29 */
30class CsvGroupHandler implements IReportVisitor {
31
32 private final ClassRowWriter writer;
33
34 private final String groupName;
35
36 public CsvGroupHandler(final ClassRowWriter writer, final String groupName) {
37 this.writer = writer;
38 this.groupName = groupName;
39 }
40
41 public IReportVisitor visitChild(final ICoverageNode node)
42 throws IOException {
43 final ElementType type = node.getElementType();
44 switch (type) {
45 case PACKAGE:
46 return new CsvPackageHandler(writer, groupName, node.getName());
47 case GROUP:
48 case BUNDLE:
49 return new CsvGroupHandler(writer, groupName + "/" + node.getName());
50 }
51 throw new IllegalStateException(format("Unexpected child node %s.",
52 type));
53 }
54
55 public void visitEnd(final ISourceFileLocator sourceFileLocator)
56 throws IOException {
57 }
58
59}