LabelColumn.java revision 34cd880f4e52a32b9f88ed4ea687b8f3f892395b
1/*******************************************************************************
2 * Copyright (c) 2009, 2017 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.internal.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.internal.ReportOutputFolder;
20import org.jacoco.report.internal.html.HTMLElement;
21import org.jacoco.report.internal.html.resources.Resources;
22
23/**
24 * Column for the item label. The implementation is stateless, instances might
25 * be used in parallel.
26 */
27public class LabelColumn implements IColumnRenderer {
28
29	private static final Comparator<ITableItem> COMPARATOR = new Comparator<ITableItem>() {
30		public int compare(final ITableItem i1, final ITableItem i2) {
31			return i1.getLinkLabel().compareToIgnoreCase(i2.getLinkLabel());
32		}
33	};
34
35	public boolean init(final List<? extends ITableItem> items,
36			final ICoverageNode total) {
37		return true;
38	}
39
40	public void footer(final HTMLElement td, final ICoverageNode total,
41			final Resources resources, final ReportOutputFolder base)
42			throws IOException {
43		td.text("Total");
44	}
45
46	public void item(final HTMLElement td, final ITableItem item,
47			final Resources resources, final ReportOutputFolder base)
48			throws IOException {
49		td.a(item, base);
50	}
51
52	public Comparator<ITableItem> getComparator() {
53		return COMPARATOR;
54	}
55
56}
57