LabelColumn.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 *    Marc R. Hoffmann - initial API and implementation
   10 *    
   11 * $Id: $
   12 *******************************************************************************/
   13package org.jacoco.report.html;
   14
   15import java.io.IOException;
   16import java.util.List;
   17
   18import org.jacoco.core.analysis.ICoverageNode;
   19import org.jacoco.report.ReportOutputFolder;
   20import org.jacoco.report.html.resources.Resources;
   21
   22/**
   23 * Column for the item label. The implementation is stateless, instances might
   24 * be used in parallel.
   25 * 
   26 * @see ICoverageTableItem#getLabel()
   27 * @see ICoverageTableItem#getLink(org.jacoco.report.ReportOutputFolder)
   28 * @author Marc R. Hoffmann
   29 * @version $Revision: $
   30 */
   31public class LabelColumn implements ICoverageTableColumn {
   32
   33    public void init(final List<ICoverageTableItem> items,
   34            final ICoverageNode total) {
   35    }
   36
   37    public void header(final HTMLElement tr, final Resources resources,
   38            final ReportOutputFolder base) throws IOException {
   39        tr.td().text("Element");
   40    }
   41
   42    public void footer(final HTMLElement tr, final ICoverageNode total,
   43            final Resources resources, final ReportOutputFolder base)
   44            throws IOException {
   45        tr.td().text("Total");
   46    }
   47
   48    public void item(final HTMLElement tr, final ICoverageTableItem item,
   49            final Resources resources, final ReportOutputFolder base)
   50            throws IOException {
   51        final String style = Resources.getElementStyle(item.getNode()
   52                .getElementType());
   53        final String link = item.getLink(base);
   54        final String label = item.getLabel();
   55        if (link == null) {
   56            tr.td().span(style).text(label);
   57        } else {
   58            tr.td().a(link, style).text(label);
   59        }
   60    }
   61
   62}