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