BundleColumn.java

    1/*******************************************************************************
    2 * Copyright (c) 2009 Mountainminds GmbH & Co. KG and others
    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 java.io.IOException;
   16
   17import org.jacoco.core.analysis.ICoverageNode;
   18import org.jacoco.core.analysis.ICoverageNode.ElementType;
   19import org.jacoco.report.IReportVisitor;
   20import org.jacoco.report.ISourceFileLocator;
   21
   22/**
   23 * Column containing the bundle name
   24 * 
   25 * @author Brock Janiczak
   26 * @version $Revision: $
   27 */
   28public class BundleColumn implements IReportVisitor, ICsvColumn {
   29
   30    private final ICsvColumn parent;
   31    private final CsvReportFile reportFile;
   32    private final String bundleName;
   33
   34    /**
   35     * Creates a new Bundle Column for the report
   36     * 
   37     * @param reportFile
   38     *            CSV Report context
   39     * @param parent
   40     *            parent element
   41     * @param node
   42     *            {@link ElementType#BUNDLE} coverage node
   43     */
   44    public BundleColumn(final CsvReportFile reportFile,
   45            final ICsvColumn parent, final ICoverageNode node) {
   46        this.reportFile = reportFile;
   47        this.parent = parent;
   48        this.bundleName = node.getName();
   49    }
   50
   51    public IReportVisitor visitChild(final ICoverageNode node)
   52            throws IOException {
   53        return new PackageColumn(reportFile, this, node);
   54    }
   55
   56    public void visitEnd(final ISourceFileLocator sourceFileLocator)
   57            throws IOException {
   58    }
   59
   60    public void writeContents(final DelimitedWriter writer) throws IOException {
   61        parent.writeContents(writer);
   62        writer.write(bundleName);
   63    }
   64
   65}