MethodItem.java revision 398ee59bebad6835dab57b60157eff16d511709e
1/******************************************************************************* 2 * Copyright (c) 2009, 2015 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.page; 13 14import org.jacoco.core.analysis.ICoverageNode; 15import org.jacoco.core.analysis.IMethodCoverage; 16import org.jacoco.core.analysis.ISourceNode; 17import org.jacoco.report.internal.ReportOutputFolder; 18import org.jacoco.report.internal.html.ILinkable; 19import org.jacoco.report.internal.html.resources.Styles; 20import org.jacoco.report.internal.html.table.ITableItem; 21 22/** 23 * Table items representing a method. 24 */ 25final class MethodItem implements ITableItem { 26 27 private final IMethodCoverage node; 28 29 private final String label; 30 31 private final ILinkable sourcePage; 32 33 MethodItem(final IMethodCoverage node, final String label, 34 final ILinkable sourcePage) { 35 this.node = node; 36 this.label = label; 37 this.sourcePage = sourcePage; 38 } 39 40 public String getLinkLabel() { 41 return label; 42 } 43 44 public String getLinkStyle() { 45 return Styles.EL_METHOD; 46 } 47 48 public String getLink(final ReportOutputFolder base) { 49 if (sourcePage == null) { 50 return null; 51 } 52 final String link = sourcePage.getLink(base); 53 final int first = node.getFirstLine(); 54 return first != ISourceNode.UNKNOWN_LINE ? link + "#L" + first : link; 55 } 56 57 public ICoverageNode getNode() { 58 return node; 59 } 60 61} 62