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 *******************************************************************************/
   12package org.jacoco.report.html.table;
   13
   14import java.io.IOException;
   15import java.util.Comparator;
   16import java.util.List;
   17
   18import org.jacoco.core.analysis.ICoverageNode;
   19import org.jacoco.report.ReportOutputFolder;
   20import org.jacoco.report.html.HTMLElement;
   21import org.jacoco.report.html.resources.Resources;
   22
   23/**
   24 * Column for the item label. The implementation is stateless, instances might
   25 * be used in parallel.
   26 * 
   27 * @author Marc R. Hoffmann
   28 * @version 0.4.1.20101007204400
   29 */
   30public class LabelColumn implements IColumnRenderer {
   31
   32    private static final Comparator<ITableItem> comparator = new Comparator<ITableItem>() {
   33        public int compare(final ITableItem i1, final ITableItem i2) {
   34            return i1.getLinkLabel().toLowerCase()
   35                    .compareTo(i2.getLinkLabel().toLowerCase());
   36        }
   37    };
   38
   39    public boolean init(final List<? extends ITableItem> items,
   40            final ICoverageNode total) {
   41        return true;
   42    }
   43
   44    public void footer(final HTMLElement td, final ICoverageNode total,
   45            final Resources resources, final ReportOutputFolder base)
   46            throws IOException {
   47        td.text("Total");
   48    }
   49
   50    public void item(final HTMLElement td, final ITableItem item,
   51            final Resources resources, final ReportOutputFolder base)
   52            throws IOException {
   53        td.a(item, base);
   54    }
   55
   56    public Comparator<ITableItem> getComparator() {
   57        return comparator;
   58    }
   59
   60}