• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2009, 2018 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  *******************************************************************************/
12 package org.jacoco.report.internal.html.table;
13 
14 import java.io.IOException;
15 import java.util.Comparator;
16 import java.util.List;
17 
18 import org.jacoco.core.analysis.ICoverageNode;
19 import org.jacoco.report.internal.ReportOutputFolder;
20 import org.jacoco.report.internal.html.HTMLElement;
21 import 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  */
27 public 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 
init(final List<? extends ITableItem> items, final ICoverageNode total)35 	public boolean init(final List<? extends ITableItem> items,
36 			final ICoverageNode total) {
37 		return true;
38 	}
39 
footer(final HTMLElement td, final ICoverageNode total, final Resources resources, final ReportOutputFolder base)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 
item(final HTMLElement td, final ITableItem item, final Resources resources, final ReportOutputFolder base)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 
getComparator()52 	public Comparator<ITableItem> getComparator() {
53 		return COMPARATOR;
54 	}
55 
56 }
57