aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.report/src
diff options
context:
space:
mode:
Diffstat (limited to 'org.jacoco.report/src')
-rw-r--r--org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java112
-rw-r--r--org.jacoco.report/src/org/jacoco/report/FileMultiReportOutput.java106
-rw-r--r--org.jacoco.report/src/org/jacoco/report/ILanguageNames.java140
-rw-r--r--org.jacoco.report/src/org/jacoco/report/IMultiReportOutput.java84
-rw-r--r--org.jacoco.report/src/org/jacoco/report/IReportGroupVisitor.java128
-rw-r--r--org.jacoco.report/src/org/jacoco/report/IReportVisitor.java104
-rw-r--r--org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java88
-rw-r--r--org.jacoco.report/src/org/jacoco/report/InputStreamSourceFileLocator.java162
-rw-r--r--org.jacoco.report/src/org/jacoco/report/JavaNames.java230
-rw-r--r--org.jacoco.report/src/org/jacoco/report/MultiReportVisitor.java162
-rw-r--r--org.jacoco.report/src/org/jacoco/report/MultiSourceFileLocator.java136
-rw-r--r--org.jacoco.report/src/org/jacoco/report/csv/CSVFormatter.java198
-rw-r--r--org.jacoco.report/src/org/jacoco/report/csv/CSVGroupHandler.java118
-rw-r--r--org.jacoco.report/src/org/jacoco/report/csv/ClassRowWriter.java184
-rw-r--r--org.jacoco.report/src/org/jacoco/report/csv/DelimitedWriter.java340
-rw-r--r--org.jacoco.report/src/org/jacoco/report/html/HTMLFormatter.java476
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/AbstractGroupVisitor.java204
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/NormalizedFileNames.java180
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/ReportOutputFolder.java252
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/HTMLDocument.java194
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/HTMLElement.java792
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/HTMLGroupVisitor.java172
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java162
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java160
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java158
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java94
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java122
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java140
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java202
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java344
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java308
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java170
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java262
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java156
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/resources/Resources.java272
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/resources/Styles.java240
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/resources/report.css472
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/BarColumn.java218
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/CounterColumn.java322
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/IColumnRenderer.java164
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/ITableItem.java58
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/LabelColumn.java112
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/PercentageColumn.java180
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/Table.java390
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/table/TableItemComparator.java64
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/xml/XMLCoverageWriter.java308
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/xml/XMLDocument.java222
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/xml/XMLElement.java524
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/xml/XMLGroupVisitor.java140
-rw-r--r--org.jacoco.report/src/org/jacoco/report/xml/XMLFormatter.java220
-rw-r--r--org.jacoco.report/src/org/jacoco/report/xml/report.dtd166
51 files changed, 5456 insertions, 5456 deletions
diff --git a/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java b/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java
index 6ab9dab8..6cac0da0 100644
--- a/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java
+++ b/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java
@@ -1,56 +1,56 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Locator for source files that picks source files from a given directory in
- * the file system.
- */
-public class DirectorySourceFileLocator extends InputStreamSourceFileLocator {
-
- private final File directory;
-
- /**
- * Creates a new locator that searches for source files in the given
- * directory.
- *
- * @param directory
- * directory to search for source file
- * @param encoding
- * encoding of the source files, <code>null</code> for platform
- * default encoding
- * @param tabWidth
- * tab width in source files as number of blanks
- *
- */
- public DirectorySourceFileLocator(final File directory,
- final String encoding, final int tabWidth) {
- super(encoding, tabWidth);
- this.directory = directory;
- }
-
- @Override
- protected InputStream getSourceStream(final String path) throws IOException {
- final File file = new File(directory, path);
- if (file.exists()) {
- return new FileInputStream(file);
- } else {
- return null;
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Locator for source files that picks source files from a given directory in
+ * the file system.
+ */
+public class DirectorySourceFileLocator extends InputStreamSourceFileLocator {
+
+ private final File directory;
+
+ /**
+ * Creates a new locator that searches for source files in the given
+ * directory.
+ *
+ * @param directory
+ * directory to search for source file
+ * @param encoding
+ * encoding of the source files, <code>null</code> for platform
+ * default encoding
+ * @param tabWidth
+ * tab width in source files as number of blanks
+ *
+ */
+ public DirectorySourceFileLocator(final File directory,
+ final String encoding, final int tabWidth) {
+ super(encoding, tabWidth);
+ this.directory = directory;
+ }
+
+ @Override
+ protected InputStream getSourceStream(final String path) throws IOException {
+ final File file = new File(directory, path);
+ if (file.exists()) {
+ return new FileInputStream(file);
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/FileMultiReportOutput.java b/org.jacoco.report/src/org/jacoco/report/FileMultiReportOutput.java
index 08faffac..eaecc793 100644
--- a/org.jacoco.report/src/org/jacoco/report/FileMultiReportOutput.java
+++ b/org.jacoco.report/src/org/jacoco/report/FileMultiReportOutput.java
@@ -1,53 +1,53 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import static java.lang.String.format;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Implementation of {@link IMultiReportOutput} that writes files directly to a
- * given directory.
- */
-public class FileMultiReportOutput implements IMultiReportOutput {
-
- private final File basedir;
-
- /**
- * Creates a new instance for document output in the given base directory.
- *
- * @param basedir
- */
- public FileMultiReportOutput(final File basedir) {
- this.basedir = basedir;
- }
-
- public OutputStream createFile(final String path) throws IOException {
- final File file = new File(basedir, path);
- final File parent = file.getParentFile();
- parent.mkdirs();
- if (!parent.isDirectory()) {
- throw new IOException(format("Can't create directory %s.", parent));
- }
- return new BufferedOutputStream(new FileOutputStream(file));
- }
-
- public void close() throws IOException {
- // nothing to do here
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import static java.lang.String.format;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Implementation of {@link IMultiReportOutput} that writes files directly to a
+ * given directory.
+ */
+public class FileMultiReportOutput implements IMultiReportOutput {
+
+ private final File basedir;
+
+ /**
+ * Creates a new instance for document output in the given base directory.
+ *
+ * @param basedir
+ */
+ public FileMultiReportOutput(final File basedir) {
+ this.basedir = basedir;
+ }
+
+ public OutputStream createFile(final String path) throws IOException {
+ final File file = new File(basedir, path);
+ final File parent = file.getParentFile();
+ parent.mkdirs();
+ if (!parent.isDirectory()) {
+ throw new IOException(format("Can't create directory %s.", parent));
+ }
+ return new BufferedOutputStream(new FileOutputStream(file));
+ }
+
+ public void close() throws IOException {
+ // nothing to do here
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/ILanguageNames.java b/org.jacoco.report/src/org/jacoco/report/ILanguageNames.java
index e82af4b0..79387390 100644
--- a/org.jacoco.report/src/org/jacoco/report/ILanguageNames.java
+++ b/org.jacoco.report/src/org/jacoco/report/ILanguageNames.java
@@ -1,70 +1,70 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-/**
- * Interface to create programming language specific names from VM names.
- */
-public interface ILanguageNames {
-
- /**
- * Calculates the language specific name of a package.
- *
- * @param vmname
- * vm name of a package
- * @return language specific notation for the package
- */
- public String getPackageName(String vmname);
-
- /**
- * Calculates the language specific name of a class.
- *
- * @param vmname
- * vm name of a class
- * @param vmsignature
- * vm signature of the class (may be <code>null</code>)
- * @param vmsuperclass
- * vm name of the superclass of the class (may be
- * <code>null</code>)
- * @param vminterfaces
- * vm names of interfaces of the class (may be <code>null</code>)
- * @return language specific notation of the class
- */
- public String getClassName(String vmname, String vmsignature,
- String vmsuperclass, String[] vminterfaces);
-
- /**
- * Calculates the language specific qualified name of a class.
- *
- * @param vmname
- * vm name of a class
- * @return language specific qualified notation of the class
- */
- public String getQualifiedClassName(String vmname);
-
- /**
- * Calculates the language specific name of a method.
- *
- * @param vmclassname
- * vm name of a containing class
- * @param vmmethodname
- * vm name of the method
- * @param vmdesc
- * vm parameter description of the method
- * @param vmsignature
- * vm signature of the method (may be <code>null</code>)
- * @return language specific notation for the method
- */
- public String getMethodName(String vmclassname, String vmmethodname,
- String vmdesc, String vmsignature);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+/**
+ * Interface to create programming language specific names from VM names.
+ */
+public interface ILanguageNames {
+
+ /**
+ * Calculates the language specific name of a package.
+ *
+ * @param vmname
+ * vm name of a package
+ * @return language specific notation for the package
+ */
+ public String getPackageName(String vmname);
+
+ /**
+ * Calculates the language specific name of a class.
+ *
+ * @param vmname
+ * vm name of a class
+ * @param vmsignature
+ * vm signature of the class (may be <code>null</code>)
+ * @param vmsuperclass
+ * vm name of the superclass of the class (may be
+ * <code>null</code>)
+ * @param vminterfaces
+ * vm names of interfaces of the class (may be <code>null</code>)
+ * @return language specific notation of the class
+ */
+ public String getClassName(String vmname, String vmsignature,
+ String vmsuperclass, String[] vminterfaces);
+
+ /**
+ * Calculates the language specific qualified name of a class.
+ *
+ * @param vmname
+ * vm name of a class
+ * @return language specific qualified notation of the class
+ */
+ public String getQualifiedClassName(String vmname);
+
+ /**
+ * Calculates the language specific name of a method.
+ *
+ * @param vmclassname
+ * vm name of a containing class
+ * @param vmmethodname
+ * vm name of the method
+ * @param vmdesc
+ * vm parameter description of the method
+ * @param vmsignature
+ * vm signature of the method (may be <code>null</code>)
+ * @return language specific notation for the method
+ */
+ public String getMethodName(String vmclassname, String vmmethodname,
+ String vmdesc, String vmsignature);
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/IMultiReportOutput.java b/org.jacoco.report/src/org/jacoco/report/IMultiReportOutput.java
index 36f9cc91..5f64e537 100644
--- a/org.jacoco.report/src/org/jacoco/report/IMultiReportOutput.java
+++ b/org.jacoco.report/src/org/jacoco/report/IMultiReportOutput.java
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Interface to emit multiple binary files.
- */
-public interface IMultiReportOutput {
-
- /**
- * Creates a file at the given local path. The returned {@link OutputStream}
- * has to be closed before the next document is created.
- *
- * @param path
- * local path to the new document
- * @return output for the content
- * @throws IOException
- * if the creation fails
- */
- public OutputStream createFile(String path) throws IOException;
-
- /**
- * Closes the underlying resource container.
- *
- * @throws IOException
- * if closing fails
- */
- public void close() throws IOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Interface to emit multiple binary files.
+ */
+public interface IMultiReportOutput {
+
+ /**
+ * Creates a file at the given local path. The returned {@link OutputStream}
+ * has to be closed before the next document is created.
+ *
+ * @param path
+ * local path to the new document
+ * @return output for the content
+ * @throws IOException
+ * if the creation fails
+ */
+ public OutputStream createFile(String path) throws IOException;
+
+ /**
+ * Closes the underlying resource container.
+ *
+ * @throws IOException
+ * if closing fails
+ */
+ public void close() throws IOException;
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/IReportGroupVisitor.java b/org.jacoco.report/src/org/jacoco/report/IReportGroupVisitor.java
index 9bfcfde5..4b322242 100644
--- a/org.jacoco.report/src/org/jacoco/report/IReportGroupVisitor.java
+++ b/org.jacoco.report/src/org/jacoco/report/IReportGroupVisitor.java
@@ -1,64 +1,64 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-
-/**
- * Output-Interface for hierarchical report structures. To allow sequential
- * processing and save memory the group structure has to be traversed in a
- * "deep first" fashion. The interface is implemented by the report formatters
- * and can be used to emit coverage report structures.
- *
- * The following constraints apply in using {@link IReportGroupVisitor} instances:
- *
- * <ul>
- * <li>A visitor instance can be used to either submit bundles (
- * {@link #visitBundle(IBundleCoverage, ISourceFileLocator)}) or groups
- * {@link #visitGroup(String)}). Bundles and groups are not allowed for the same
- * visitor.</li>
- * <li>When creating nested groups with {@link #visitGroup(String)} the
- * hierarchy has to be processed in a "deep first" manner.</li>
- * </ul>
- */
-public interface IReportGroupVisitor {
-
- /**
- * Called to add a bundle to the the report.
- *
- * @param bundle
- * a bundle to include in the report
- * @param locator
- * source locator for this bundle
- * @throws IOException
- * in case of IO problems with the report writer
- */
- void visitBundle(IBundleCoverage bundle, ISourceFileLocator locator)
- throws IOException;
-
- /**
- * Called to add a new group to the report. The returned
- * {@link IReportGroupVisitor} instance can be used to add nested bundles or
- * groups. The content of the group has to be completed before this or any
- * parent visitor can be used again ("deep first").
- *
- * @param name
- * name of the group
- * @return visitor for the group's content
- * @throws IOException
- * in case of IO problems with the report writer
- */
- IReportGroupVisitor visitGroup(String name) throws IOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+
+/**
+ * Output-Interface for hierarchical report structures. To allow sequential
+ * processing and save memory the group structure has to be traversed in a
+ * "deep first" fashion. The interface is implemented by the report formatters
+ * and can be used to emit coverage report structures.
+ *
+ * The following constraints apply in using {@link IReportGroupVisitor} instances:
+ *
+ * <ul>
+ * <li>A visitor instance can be used to either submit bundles (
+ * {@link #visitBundle(IBundleCoverage, ISourceFileLocator)}) or groups
+ * {@link #visitGroup(String)}). Bundles and groups are not allowed for the same
+ * visitor.</li>
+ * <li>When creating nested groups with {@link #visitGroup(String)} the
+ * hierarchy has to be processed in a "deep first" manner.</li>
+ * </ul>
+ */
+public interface IReportGroupVisitor {
+
+ /**
+ * Called to add a bundle to the the report.
+ *
+ * @param bundle
+ * a bundle to include in the report
+ * @param locator
+ * source locator for this bundle
+ * @throws IOException
+ * in case of IO problems with the report writer
+ */
+ void visitBundle(IBundleCoverage bundle, ISourceFileLocator locator)
+ throws IOException;
+
+ /**
+ * Called to add a new group to the report. The returned
+ * {@link IReportGroupVisitor} instance can be used to add nested bundles or
+ * groups. The content of the group has to be completed before this or any
+ * parent visitor can be used again ("deep first").
+ *
+ * @param name
+ * name of the group
+ * @return visitor for the group's content
+ * @throws IOException
+ * in case of IO problems with the report writer
+ */
+ IReportGroupVisitor visitGroup(String name) throws IOException;
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/IReportVisitor.java b/org.jacoco.report/src/org/jacoco/report/IReportVisitor.java
index f288d591..5fe4bf0e 100644
--- a/org.jacoco.report/src/org/jacoco/report/IReportVisitor.java
+++ b/org.jacoco.report/src/org/jacoco/report/IReportVisitor.java
@@ -1,52 +1,52 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
-import org.jacoco.core.data.ExecutionData;
-import org.jacoco.core.data.SessionInfo;
-
-/**
- * Interface for all implementations to retrieve structured report data. Unlike
- * nested {@link IReportGroupVisitor} instances the root visitor accepts exactly one
- * bundle or group.
- */
-public interface IReportVisitor extends IReportGroupVisitor {
-
- /**
- * Initializes the report with global information. This method has to be
- * called before any other method can be called.
- *
- * @param sessionInfos
- * list of chronological ordered {@link SessionInfo} objects
- * where execution data has been collected for this report.
- * @param executionData
- * collection of all {@link ExecutionData} objects that are
- * considered for this report
- * @throws IOException
- * in case of IO problems with the report writer
- */
- public void visitInfo(List<SessionInfo> sessionInfos,
- Collection<ExecutionData> executionData) throws IOException;
-
- /**
- * Has to be called after all report data has been emitted.
- *
- * @throws IOException
- * in case of IO problems with the report writer
- */
- public void visitEnd() throws IOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import org.jacoco.core.data.ExecutionData;
+import org.jacoco.core.data.SessionInfo;
+
+/**
+ * Interface for all implementations to retrieve structured report data. Unlike
+ * nested {@link IReportGroupVisitor} instances the root visitor accepts exactly one
+ * bundle or group.
+ */
+public interface IReportVisitor extends IReportGroupVisitor {
+
+ /**
+ * Initializes the report with global information. This method has to be
+ * called before any other method can be called.
+ *
+ * @param sessionInfos
+ * list of chronological ordered {@link SessionInfo} objects
+ * where execution data has been collected for this report.
+ * @param executionData
+ * collection of all {@link ExecutionData} objects that are
+ * considered for this report
+ * @throws IOException
+ * in case of IO problems with the report writer
+ */
+ public void visitInfo(List<SessionInfo> sessionInfos,
+ Collection<ExecutionData> executionData) throws IOException;
+
+ /**
+ * Has to be called after all report data has been emitted.
+ *
+ * @throws IOException
+ * in case of IO problems with the report writer
+ */
+ public void visitEnd() throws IOException;
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java b/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java
index b9a77d01..2730784d 100644
--- a/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java
+++ b/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java
@@ -1,44 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * Interface to look-up source files that will be included with the report.
- */
-public interface ISourceFileLocator {
-
- /**
- * Tries to locate the given source file and opens a reader with the
- * appropriate encoding.
- *
- * @param packageName
- * VM name of the package
- * @param fileName
- * name of the source file
- * @return reader if the file could be located, <code>null</code> otherwise
- * @throws IOException
- * in case of problems while opening the file
- */
- public Reader getSourceFile(String packageName, String fileName)
- throws IOException;
-
- /**
- * Returns number of blank characters that represent a tab in source code.
- *
- * @return tab width as number of blanks
- */
- public int getTabWidth();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * Interface to look-up source files that will be included with the report.
+ */
+public interface ISourceFileLocator {
+
+ /**
+ * Tries to locate the given source file and opens a reader with the
+ * appropriate encoding.
+ *
+ * @param packageName
+ * VM name of the package
+ * @param fileName
+ * name of the source file
+ * @return reader if the file could be located, <code>null</code> otherwise
+ * @throws IOException
+ * in case of problems while opening the file
+ */
+ public Reader getSourceFile(String packageName, String fileName)
+ throws IOException;
+
+ /**
+ * Returns number of blank characters that represent a tab in source code.
+ *
+ * @return tab width as number of blanks
+ */
+ public int getTabWidth();
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/InputStreamSourceFileLocator.java b/org.jacoco.report/src/org/jacoco/report/InputStreamSourceFileLocator.java
index 8dea3611..f9e62f72 100644
--- a/org.jacoco.report/src/org/jacoco/report/InputStreamSourceFileLocator.java
+++ b/org.jacoco.report/src/org/jacoco/report/InputStreamSourceFileLocator.java
@@ -1,81 +1,81 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-/**
- * Abstract base class for {@link ISourceFileLocator} locator implementations
- * based on {@link InputStream}s. It handles the encoding and tab width.
- */
-public abstract class InputStreamSourceFileLocator implements
- ISourceFileLocator {
-
- private final String encoding;
- private final int tabWidth;
-
- /**
- * Creates a new locator with the given specification.
- *
- * @param encoding
- * encoding of the source files, <code>null</code> for platform
- * default encoding
- * @param tabWidth
- * tab width in source files as number of blanks
- *
- */
- protected InputStreamSourceFileLocator(final String encoding,
- final int tabWidth) {
- this.encoding = encoding;
- this.tabWidth = tabWidth;
- }
-
- public Reader getSourceFile(final String packageName, final String fileName)
- throws IOException {
- final InputStream in;
- if (packageName.length() > 0) {
- in = getSourceStream(packageName + "/" + fileName);
- } else {
- in = getSourceStream(fileName);
- }
-
- if (in == null) {
- return null;
- }
-
- if (encoding == null) {
- return new InputStreamReader(in);
- } else {
- return new InputStreamReader(in, encoding);
- }
- }
-
- public int getTabWidth() {
- return tabWidth;
- }
-
- /**
- * Tries to locate the given source file and opens its binary content.
- *
- * @param path
- * local path to the resource
- * @return stream if the file could be located, <code>null</code> otherwise
- * @throws IOException
- * in case of problems while opening the stream
- */
- protected abstract InputStream getSourceStream(String path)
- throws IOException;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+/**
+ * Abstract base class for {@link ISourceFileLocator} locator implementations
+ * based on {@link InputStream}s. It handles the encoding and tab width.
+ */
+public abstract class InputStreamSourceFileLocator implements
+ ISourceFileLocator {
+
+ private final String encoding;
+ private final int tabWidth;
+
+ /**
+ * Creates a new locator with the given specification.
+ *
+ * @param encoding
+ * encoding of the source files, <code>null</code> for platform
+ * default encoding
+ * @param tabWidth
+ * tab width in source files as number of blanks
+ *
+ */
+ protected InputStreamSourceFileLocator(final String encoding,
+ final int tabWidth) {
+ this.encoding = encoding;
+ this.tabWidth = tabWidth;
+ }
+
+ public Reader getSourceFile(final String packageName, final String fileName)
+ throws IOException {
+ final InputStream in;
+ if (packageName.length() > 0) {
+ in = getSourceStream(packageName + "/" + fileName);
+ } else {
+ in = getSourceStream(fileName);
+ }
+
+ if (in == null) {
+ return null;
+ }
+
+ if (encoding == null) {
+ return new InputStreamReader(in);
+ } else {
+ return new InputStreamReader(in, encoding);
+ }
+ }
+
+ public int getTabWidth() {
+ return tabWidth;
+ }
+
+ /**
+ * Tries to locate the given source file and opens its binary content.
+ *
+ * @param path
+ * local path to the resource
+ * @return stream if the file could be located, <code>null</code> otherwise
+ * @throws IOException
+ * in case of problems while opening the stream
+ */
+ protected abstract InputStream getSourceStream(String path)
+ throws IOException;
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/JavaNames.java b/org.jacoco.report/src/org/jacoco/report/JavaNames.java
index 25d216d4..67001a43 100644
--- a/org.jacoco.report/src/org/jacoco/report/JavaNames.java
+++ b/org.jacoco.report/src/org/jacoco/report/JavaNames.java
@@ -1,115 +1,115 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import org.objectweb.asm.Type;
-
-/**
- * Names for the Java language.
- */
-public class JavaNames implements ILanguageNames {
-
- public String getPackageName(final String vmname) {
- if (vmname.length() == 0) {
- return "default";
- }
- return vmname.replace('/', '.');
- }
-
- private String getClassName(final String vmname) {
- final int pos = vmname.lastIndexOf('/');
- final String name = pos == -1 ? vmname : vmname.substring(pos + 1);
- return name.replace('$', '.');
- }
-
- private boolean isAnonymous(final String vmname) {
- final int dollarPosition = vmname.lastIndexOf('$');
- if (dollarPosition == -1) {
- return false;
- }
- final int internalPosition = dollarPosition + 1;
- if (internalPosition == vmname.length()) {
- // shouldn't happen for classes compiled from Java source
- return false;
- }
- // assume non-identifier start character for anonymous classes
- final char start = vmname.charAt(internalPosition);
- return !Character.isJavaIdentifierStart(start);
- }
-
- public String getClassName(final String vmname, final String vmsignature,
- final String vmsuperclass, final String[] vminterfaces) {
- if (isAnonymous(vmname)) {
- final String vmsupertype;
- if (vminterfaces != null && vminterfaces.length > 0) {
- vmsupertype = vminterfaces[0];
- } else if (vmsuperclass != null) {
- vmsupertype = vmsuperclass;
- } else {
- vmsupertype = null;
- }
- // append Eclipse style label, e.g. "Foo.new Bar() {...}"
- if (vmsupertype != null) {
- final StringBuilder builder = new StringBuilder();
- final String vmenclosing = vmname.substring(0,
- vmname.lastIndexOf('$'));
- builder.append(getClassName(vmenclosing)).append(".new ")
- .append(getClassName(vmsupertype)).append("() {...}");
- return builder.toString();
- }
- }
- return getClassName(vmname);
- }
-
- public String getQualifiedClassName(final String vmname) {
- return vmname.replace('/', '.').replace('$', '.');
- }
-
- public String getMethodName(final String vmclassname,
- final String vmmethodname, final String vmdesc,
- final String vmsignature) {
- if ("<clinit>".equals(vmmethodname)) {
- return "static {...}";
- }
- final StringBuilder result = new StringBuilder();
- if ("<init>".equals(vmmethodname)) {
- if (isAnonymous(vmclassname)) {
- return "{...}";
- } else {
- result.append(getClassName(vmclassname));
- }
- } else {
- result.append(vmmethodname);
- }
- result.append('(');
- final Type[] arguments = Type.getArgumentTypes(vmdesc);
- boolean comma = false;
- for (final Type arg : arguments) {
- if (comma) {
- result.append(", ");
- } else {
- comma = true;
- }
- result.append(getShortTypeName(arg));
- }
- result.append(')');
- return result.toString();
- }
-
- private String getShortTypeName(final Type type) {
- final String name = type.getClassName();
- final int pos = name.lastIndexOf('.');
- final String shortName = pos == -1 ? name : name.substring(pos + 1);
- return shortName.replace('$', '.');
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import org.objectweb.asm.Type;
+
+/**
+ * Names for the Java language.
+ */
+public class JavaNames implements ILanguageNames {
+
+ public String getPackageName(final String vmname) {
+ if (vmname.length() == 0) {
+ return "default";
+ }
+ return vmname.replace('/', '.');
+ }
+
+ private String getClassName(final String vmname) {
+ final int pos = vmname.lastIndexOf('/');
+ final String name = pos == -1 ? vmname : vmname.substring(pos + 1);
+ return name.replace('$', '.');
+ }
+
+ private boolean isAnonymous(final String vmname) {
+ final int dollarPosition = vmname.lastIndexOf('$');
+ if (dollarPosition == -1) {
+ return false;
+ }
+ final int internalPosition = dollarPosition + 1;
+ if (internalPosition == vmname.length()) {
+ // shouldn't happen for classes compiled from Java source
+ return false;
+ }
+ // assume non-identifier start character for anonymous classes
+ final char start = vmname.charAt(internalPosition);
+ return !Character.isJavaIdentifierStart(start);
+ }
+
+ public String getClassName(final String vmname, final String vmsignature,
+ final String vmsuperclass, final String[] vminterfaces) {
+ if (isAnonymous(vmname)) {
+ final String vmsupertype;
+ if (vminterfaces != null && vminterfaces.length > 0) {
+ vmsupertype = vminterfaces[0];
+ } else if (vmsuperclass != null) {
+ vmsupertype = vmsuperclass;
+ } else {
+ vmsupertype = null;
+ }
+ // append Eclipse style label, e.g. "Foo.new Bar() {...}"
+ if (vmsupertype != null) {
+ final StringBuilder builder = new StringBuilder();
+ final String vmenclosing = vmname.substring(0,
+ vmname.lastIndexOf('$'));
+ builder.append(getClassName(vmenclosing)).append(".new ")
+ .append(getClassName(vmsupertype)).append("() {...}");
+ return builder.toString();
+ }
+ }
+ return getClassName(vmname);
+ }
+
+ public String getQualifiedClassName(final String vmname) {
+ return vmname.replace('/', '.').replace('$', '.');
+ }
+
+ public String getMethodName(final String vmclassname,
+ final String vmmethodname, final String vmdesc,
+ final String vmsignature) {
+ if ("<clinit>".equals(vmmethodname)) {
+ return "static {...}";
+ }
+ final StringBuilder result = new StringBuilder();
+ if ("<init>".equals(vmmethodname)) {
+ if (isAnonymous(vmclassname)) {
+ return "{...}";
+ } else {
+ result.append(getClassName(vmclassname));
+ }
+ } else {
+ result.append(vmmethodname);
+ }
+ result.append('(');
+ final Type[] arguments = Type.getArgumentTypes(vmdesc);
+ boolean comma = false;
+ for (final Type arg : arguments) {
+ if (comma) {
+ result.append(", ");
+ } else {
+ comma = true;
+ }
+ result.append(getShortTypeName(arg));
+ }
+ result.append(')');
+ return result.toString();
+ }
+
+ private String getShortTypeName(final Type type) {
+ final String name = type.getClassName();
+ final int pos = name.lastIndexOf('.');
+ final String shortName = pos == -1 ? name : name.substring(pos + 1);
+ return shortName.replace('$', '.');
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/MultiReportVisitor.java b/org.jacoco.report/src/org/jacoco/report/MultiReportVisitor.java
index 56431a9e..d8f4d0c6 100644
--- a/org.jacoco.report/src/org/jacoco/report/MultiReportVisitor.java
+++ b/org.jacoco.report/src/org/jacoco/report/MultiReportVisitor.java
@@ -1,81 +1,81 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.data.ExecutionData;
-import org.jacoco.core.data.SessionInfo;
-
-/**
- * A report visitor that is composed from multiple other visitors. This can be
- * used to create more than one report format in one run.
- */
-public class MultiReportVisitor extends MultiGroupVisitor implements
- IReportVisitor {
-
- private final List<IReportVisitor> visitors;
-
- /**
- * New visitor delegating to all given visitors.
- *
- * @param visitors
- * visitors to delegate to
- */
- public MultiReportVisitor(final List<IReportVisitor> visitors) {
- super(visitors);
- this.visitors = visitors;
- }
-
- public void visitInfo(final List<SessionInfo> sessionInfos,
- final Collection<ExecutionData> executionData) throws IOException {
- for (final IReportVisitor v : visitors) {
- v.visitInfo(sessionInfos, executionData);
- }
- }
-
- public void visitEnd() throws IOException {
- for (final IReportVisitor v : visitors) {
- v.visitEnd();
- }
- }
-
-}
-
-class MultiGroupVisitor implements IReportGroupVisitor {
-
- private final List<? extends IReportGroupVisitor> visitors;
-
- MultiGroupVisitor(final List<? extends IReportGroupVisitor> visitors) {
- this.visitors = visitors;
- }
-
- public void visitBundle(final IBundleCoverage bundle,
- final ISourceFileLocator locator) throws IOException {
- for (final IReportGroupVisitor v : visitors) {
- v.visitBundle(bundle, locator);
- }
- }
-
- public IReportGroupVisitor visitGroup(final String name) throws IOException {
- final List<IReportGroupVisitor> children = new ArrayList<IReportGroupVisitor>();
- for (final IReportGroupVisitor v : visitors) {
- children.add(v.visitGroup(name));
- }
- return new MultiGroupVisitor(children);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.data.ExecutionData;
+import org.jacoco.core.data.SessionInfo;
+
+/**
+ * A report visitor that is composed from multiple other visitors. This can be
+ * used to create more than one report format in one run.
+ */
+public class MultiReportVisitor extends MultiGroupVisitor implements
+ IReportVisitor {
+
+ private final List<IReportVisitor> visitors;
+
+ /**
+ * New visitor delegating to all given visitors.
+ *
+ * @param visitors
+ * visitors to delegate to
+ */
+ public MultiReportVisitor(final List<IReportVisitor> visitors) {
+ super(visitors);
+ this.visitors = visitors;
+ }
+
+ public void visitInfo(final List<SessionInfo> sessionInfos,
+ final Collection<ExecutionData> executionData) throws IOException {
+ for (final IReportVisitor v : visitors) {
+ v.visitInfo(sessionInfos, executionData);
+ }
+ }
+
+ public void visitEnd() throws IOException {
+ for (final IReportVisitor v : visitors) {
+ v.visitEnd();
+ }
+ }
+
+}
+
+class MultiGroupVisitor implements IReportGroupVisitor {
+
+ private final List<? extends IReportGroupVisitor> visitors;
+
+ MultiGroupVisitor(final List<? extends IReportGroupVisitor> visitors) {
+ this.visitors = visitors;
+ }
+
+ public void visitBundle(final IBundleCoverage bundle,
+ final ISourceFileLocator locator) throws IOException {
+ for (final IReportGroupVisitor v : visitors) {
+ v.visitBundle(bundle, locator);
+ }
+ }
+
+ public IReportGroupVisitor visitGroup(final String name) throws IOException {
+ final List<IReportGroupVisitor> children = new ArrayList<IReportGroupVisitor>();
+ for (final IReportGroupVisitor v : visitors) {
+ children.add(v.visitGroup(name));
+ }
+ return new MultiGroupVisitor(children);
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/MultiSourceFileLocator.java b/org.jacoco.report/src/org/jacoco/report/MultiSourceFileLocator.java
index cd70fd0d..30e16c36 100644
--- a/org.jacoco.report/src/org/jacoco/report/MultiSourceFileLocator.java
+++ b/org.jacoco.report/src/org/jacoco/report/MultiSourceFileLocator.java
@@ -1,68 +1,68 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Locator that searches source files in multiple {@link ISourceFileLocator}
- * instances. For each lookup request the first locator that returns a
- * {@link Reader} for source content is selected.
- */
-public class MultiSourceFileLocator implements ISourceFileLocator {
-
- private final int tabWidth;
-
- private final List<ISourceFileLocator> delegates;
-
- /**
- * Creates a new empty locator.
- *
- * @param tabWidth
- * tab width in source files as number of blanks used for all
- * source files
- */
- public MultiSourceFileLocator(final int tabWidth) {
- this.tabWidth = tabWidth;
- this.delegates = new ArrayList<ISourceFileLocator>();
- }
-
- /**
- * Adds the given locator. Locators are queried in the sequence they have
- * been added.
- *
- * @param locator
- * Additional locator to query
- */
- public void add(final ISourceFileLocator locator) {
- delegates.add(locator);
- }
-
- public Reader getSourceFile(final String packageName, final String fileName)
- throws IOException {
- for (final ISourceFileLocator d : delegates) {
- final Reader reader = d.getSourceFile(packageName, fileName);
- if (reader != null) {
- return reader;
- }
- }
- return null;
- }
-
- public int getTabWidth() {
- return tabWidth;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Locator that searches source files in multiple {@link ISourceFileLocator}
+ * instances. For each lookup request the first locator that returns a
+ * {@link Reader} for source content is selected.
+ */
+public class MultiSourceFileLocator implements ISourceFileLocator {
+
+ private final int tabWidth;
+
+ private final List<ISourceFileLocator> delegates;
+
+ /**
+ * Creates a new empty locator.
+ *
+ * @param tabWidth
+ * tab width in source files as number of blanks used for all
+ * source files
+ */
+ public MultiSourceFileLocator(final int tabWidth) {
+ this.tabWidth = tabWidth;
+ this.delegates = new ArrayList<ISourceFileLocator>();
+ }
+
+ /**
+ * Adds the given locator. Locators are queried in the sequence they have
+ * been added.
+ *
+ * @param locator
+ * Additional locator to query
+ */
+ public void add(final ISourceFileLocator locator) {
+ delegates.add(locator);
+ }
+
+ public Reader getSourceFile(final String packageName, final String fileName)
+ throws IOException {
+ for (final ISourceFileLocator d : delegates) {
+ final Reader reader = d.getSourceFile(packageName, fileName);
+ if (reader != null) {
+ return reader;
+ }
+ }
+ return null;
+ }
+
+ public int getTabWidth() {
+ return tabWidth;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/csv/CSVFormatter.java b/org.jacoco.report/src/org/jacoco/report/csv/CSVFormatter.java
index 01520ba0..75aa12b2 100644
--- a/org.jacoco.report/src/org/jacoco/report/csv/CSVFormatter.java
+++ b/org.jacoco.report/src/org/jacoco/report/csv/CSVFormatter.java
@@ -1,99 +1,99 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Brock Janiczak - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.csv;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.util.Collection;
-import java.util.List;
-
-import org.jacoco.core.data.ExecutionData;
-import org.jacoco.core.data.SessionInfo;
-import org.jacoco.report.ILanguageNames;
-import org.jacoco.report.IReportVisitor;
-import org.jacoco.report.JavaNames;
-
-/**
- * Report formatter that will create a single CSV file. By default the filename
- * used will be the name of the session.
- */
-public class CSVFormatter {
-
- private ILanguageNames languageNames = new JavaNames();
-
- private String outputEncoding = "UTF-8";
-
- /**
- * Sets the implementation for language name display. Java language names
- * are defined by default.
- *
- * @param languageNames
- * converter for language specific names
- */
- public void setLanguageNames(final ILanguageNames languageNames) {
- this.languageNames = languageNames;
- }
-
- /**
- * Returns the language names call-back used in this report.
- *
- * @return language names
- */
- public ILanguageNames getLanguageNames() {
- return languageNames;
- }
-
- /**
- * Sets the encoding used for generated CSV document. Default is UTF-8.
- *
- * @param outputEncoding
- * CSV output encoding
- */
- public void setOutputEncoding(final String outputEncoding) {
- this.outputEncoding = outputEncoding;
- }
-
- /**
- * Creates a new visitor to write a report to the given stream.
- *
- * @param output
- * output stream to write the report to
- * @return visitor to emit the report data to
- * @throws IOException
- * in case of problems with the output stream
- */
- public IReportVisitor createVisitor(final OutputStream output)
- throws IOException {
- final DelimitedWriter writer = new DelimitedWriter(
- new OutputStreamWriter(output, outputEncoding));
- final ClassRowWriter rowWriter = new ClassRowWriter(writer,
- languageNames);
- class Visitor extends CSVGroupHandler implements IReportVisitor {
- Visitor() {
- super(rowWriter);
- }
-
- public void visitInfo(final List<SessionInfo> sessionInfos,
- final Collection<ExecutionData> executionData)
- throws IOException {
- // Info not used for CSV report
- }
-
- public void visitEnd() throws IOException {
- writer.close();
- }
- }
- return new Visitor();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Brock Janiczak - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.csv;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.Collection;
+import java.util.List;
+
+import org.jacoco.core.data.ExecutionData;
+import org.jacoco.core.data.SessionInfo;
+import org.jacoco.report.ILanguageNames;
+import org.jacoco.report.IReportVisitor;
+import org.jacoco.report.JavaNames;
+
+/**
+ * Report formatter that will create a single CSV file. By default the filename
+ * used will be the name of the session.
+ */
+public class CSVFormatter {
+
+ private ILanguageNames languageNames = new JavaNames();
+
+ private String outputEncoding = "UTF-8";
+
+ /**
+ * Sets the implementation for language name display. Java language names
+ * are defined by default.
+ *
+ * @param languageNames
+ * converter for language specific names
+ */
+ public void setLanguageNames(final ILanguageNames languageNames) {
+ this.languageNames = languageNames;
+ }
+
+ /**
+ * Returns the language names call-back used in this report.
+ *
+ * @return language names
+ */
+ public ILanguageNames getLanguageNames() {
+ return languageNames;
+ }
+
+ /**
+ * Sets the encoding used for generated CSV document. Default is UTF-8.
+ *
+ * @param outputEncoding
+ * CSV output encoding
+ */
+ public void setOutputEncoding(final String outputEncoding) {
+ this.outputEncoding = outputEncoding;
+ }
+
+ /**
+ * Creates a new visitor to write a report to the given stream.
+ *
+ * @param output
+ * output stream to write the report to
+ * @return visitor to emit the report data to
+ * @throws IOException
+ * in case of problems with the output stream
+ */
+ public IReportVisitor createVisitor(final OutputStream output)
+ throws IOException {
+ final DelimitedWriter writer = new DelimitedWriter(
+ new OutputStreamWriter(output, outputEncoding));
+ final ClassRowWriter rowWriter = new ClassRowWriter(writer,
+ languageNames);
+ class Visitor extends CSVGroupHandler implements IReportVisitor {
+ Visitor() {
+ super(rowWriter);
+ }
+
+ public void visitInfo(final List<SessionInfo> sessionInfos,
+ final Collection<ExecutionData> executionData)
+ throws IOException {
+ // Info not used for CSV report
+ }
+
+ public void visitEnd() throws IOException {
+ writer.close();
+ }
+ }
+ return new Visitor();
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/csv/CSVGroupHandler.java b/org.jacoco.report/src/org/jacoco/report/csv/CSVGroupHandler.java
index 97e8ceb2..cdd22a0d 100644
--- a/org.jacoco.report/src/org/jacoco/report/csv/CSVGroupHandler.java
+++ b/org.jacoco.report/src/org/jacoco/report/csv/CSVGroupHandler.java
@@ -1,59 +1,59 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Brock Janiczak - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.csv;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.analysis.IClassCoverage;
-import org.jacoco.core.analysis.IPackageCoverage;
-import org.jacoco.report.IReportGroupVisitor;
-import org.jacoco.report.ISourceFileLocator;
-
-/**
- * Report visitor that handles coverage information for groups.
- */
-class CSVGroupHandler implements IReportGroupVisitor {
-
- private final ClassRowWriter writer;
-
- private final String groupName;
-
- public CSVGroupHandler(final ClassRowWriter writer) {
- this(writer, null);
- }
-
- private CSVGroupHandler(final ClassRowWriter writer, final String groupName) {
- this.writer = writer;
- this.groupName = groupName;
- }
-
- public void visitBundle(final IBundleCoverage bundle,
- final ISourceFileLocator locator) throws IOException {
- final String name = appendName(bundle.getName());
- for (final IPackageCoverage p : bundle.getPackages()) {
- final String packageName = p.getName();
- for (final IClassCoverage c : p.getClasses()) {
- writer.writeRow(name, packageName, c);
- }
- }
- }
-
- public IReportGroupVisitor visitGroup(final String name) throws IOException {
- return new CSVGroupHandler(writer, appendName(name));
- }
-
- private String appendName(final String name) {
- return groupName == null ? name : (groupName + "/" + name);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Brock Janiczak - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.csv;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.IPackageCoverage;
+import org.jacoco.report.IReportGroupVisitor;
+import org.jacoco.report.ISourceFileLocator;
+
+/**
+ * Report visitor that handles coverage information for groups.
+ */
+class CSVGroupHandler implements IReportGroupVisitor {
+
+ private final ClassRowWriter writer;
+
+ private final String groupName;
+
+ public CSVGroupHandler(final ClassRowWriter writer) {
+ this(writer, null);
+ }
+
+ private CSVGroupHandler(final ClassRowWriter writer, final String groupName) {
+ this.writer = writer;
+ this.groupName = groupName;
+ }
+
+ public void visitBundle(final IBundleCoverage bundle,
+ final ISourceFileLocator locator) throws IOException {
+ final String name = appendName(bundle.getName());
+ for (final IPackageCoverage p : bundle.getPackages()) {
+ final String packageName = p.getName();
+ for (final IClassCoverage c : p.getClasses()) {
+ writer.writeRow(name, packageName, c);
+ }
+ }
+ }
+
+ public IReportGroupVisitor visitGroup(final String name) throws IOException {
+ return new CSVGroupHandler(writer, appendName(name));
+ }
+
+ private String appendName(final String name) {
+ return groupName == null ? name : (groupName + "/" + name);
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/csv/ClassRowWriter.java b/org.jacoco.report/src/org/jacoco/report/csv/ClassRowWriter.java
index abaf95f4..fc9fc1b0 100644
--- a/org.jacoco.report/src/org/jacoco/report/csv/ClassRowWriter.java
+++ b/org.jacoco.report/src/org/jacoco/report/csv/ClassRowWriter.java
@@ -1,92 +1,92 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Brock Janiczak - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.csv;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IClassCoverage;
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
-import org.jacoco.report.ILanguageNames;
-
-/**
- * Writer for rows in the CVS report representing the summary data of a single
- * class.
- */
-class ClassRowWriter {
-
- private static final CounterEntity[] COUNTERS = { CounterEntity.INSTRUCTION,
- CounterEntity.BRANCH, CounterEntity.LINE,
- CounterEntity.COMPLEXITY, CounterEntity.METHOD };
-
- private final DelimitedWriter writer;
-
- private final ILanguageNames languageNames;
-
- /**
- * Creates a new row writer that writes class information to the given CSV
- * writer.
- *
- * @param writer
- * writer for csv output
- * @param languageNames
- * converter for Java identifiers
- * @throws IOException
- * in case of problems with the writer
- */
- public ClassRowWriter(final DelimitedWriter writer,
- final ILanguageNames languageNames) throws IOException {
- this.writer = writer;
- this.languageNames = languageNames;
- writeHeader();
- }
-
- private void writeHeader() throws IOException {
- writer.write("GROUP", "PACKAGE", "CLASS");
- for (final CounterEntity entity : COUNTERS) {
- writer.write(entity.name() + "_MISSED");
- writer.write(entity.name() + "_COVERED");
- }
- writer.nextLine();
- }
-
- /**
- * Writes the class summary information as a row.
- *
- * @param groupName
- * name of the group
- * @param packageName
- * vm name of the package
- * @param node
- * class coverage data
- * @throws IOException
- * in case of problems with the writer
- */
- public void writeRow(final String groupName, final String packageName,
- final IClassCoverage node) throws IOException {
- writer.write(groupName);
- writer.write(languageNames.getPackageName(packageName));
- final String className = languageNames.getClassName(node.getName(),
- node.getSignature(), node.getSuperName(),
- node.getInterfaceNames());
- writer.write(className);
-
- for (final CounterEntity entity : COUNTERS) {
- final ICounter counter = node.getCounter(entity);
- writer.write(counter.getMissedCount());
- writer.write(counter.getCoveredCount());
- }
-
- writer.nextLine();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Brock Janiczak - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.csv;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
+import org.jacoco.report.ILanguageNames;
+
+/**
+ * Writer for rows in the CVS report representing the summary data of a single
+ * class.
+ */
+class ClassRowWriter {
+
+ private static final CounterEntity[] COUNTERS = { CounterEntity.INSTRUCTION,
+ CounterEntity.BRANCH, CounterEntity.LINE,
+ CounterEntity.COMPLEXITY, CounterEntity.METHOD };
+
+ private final DelimitedWriter writer;
+
+ private final ILanguageNames languageNames;
+
+ /**
+ * Creates a new row writer that writes class information to the given CSV
+ * writer.
+ *
+ * @param writer
+ * writer for csv output
+ * @param languageNames
+ * converter for Java identifiers
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public ClassRowWriter(final DelimitedWriter writer,
+ final ILanguageNames languageNames) throws IOException {
+ this.writer = writer;
+ this.languageNames = languageNames;
+ writeHeader();
+ }
+
+ private void writeHeader() throws IOException {
+ writer.write("GROUP", "PACKAGE", "CLASS");
+ for (final CounterEntity entity : COUNTERS) {
+ writer.write(entity.name() + "_MISSED");
+ writer.write(entity.name() + "_COVERED");
+ }
+ writer.nextLine();
+ }
+
+ /**
+ * Writes the class summary information as a row.
+ *
+ * @param groupName
+ * name of the group
+ * @param packageName
+ * vm name of the package
+ * @param node
+ * class coverage data
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public void writeRow(final String groupName, final String packageName,
+ final IClassCoverage node) throws IOException {
+ writer.write(groupName);
+ writer.write(languageNames.getPackageName(packageName));
+ final String className = languageNames.getClassName(node.getName(),
+ node.getSignature(), node.getSuperName(),
+ node.getInterfaceNames());
+ writer.write(className);
+
+ for (final CounterEntity entity : COUNTERS) {
+ final ICounter counter = node.getCounter(entity);
+ writer.write(counter.getMissedCount());
+ writer.write(counter.getCoveredCount());
+ }
+
+ writer.nextLine();
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/csv/DelimitedWriter.java b/org.jacoco.report/src/org/jacoco/report/csv/DelimitedWriter.java
index 1b095390..086d5223 100644
--- a/org.jacoco.report/src/org/jacoco/report/csv/DelimitedWriter.java
+++ b/org.jacoco.report/src/org/jacoco/report/csv/DelimitedWriter.java
@@ -1,170 +1,170 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Brock Janiczak - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.csv;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * Helper class for writing out CSV or tab delimited files.
- * <p>
- * <strong>Example Usage:</strong>
- *
- * <pre>
- * delimitedWriter.writeFields(&quot;header1&quot;, &quot;header2&quot;, ...);
- * for each line to be written {
- * delimitedWriter.writeField(value1);
- * delimitedWriter.writeField(value2);
- * delimitedWriter.nextLine();
- * }
- * delimitedWriter.close();
- * </pre>
- *
- * </p>
- */
-class DelimitedWriter {
- private static final String QUOTE = "\"";
- private static final String ESCAPED_QUOTE = "\"\"";
-
- private static final char DEFAULT_DELIMITER = ',';
- private static final String NEW_LINE = System.getProperty("line.separator");
- private final char delimiter;
- private final Writer delegate;
- private int fieldPosition = 0;
-
- /**
- * Creates a new Delimited writer using the default delimiter
- *
- * @param delegate
- * Writer to delegate all writes to
- */
- public DelimitedWriter(final Writer delegate) {
- this(delegate, DEFAULT_DELIMITER);
- }
-
- /**
- * Creates a new Delimited writer using the default delimiter
- *
- * @param delegate
- * Writer to delegate all writes to
- * @param delimiter
- * delimiter to use (usually a comma, tab or space)
- */
- public DelimitedWriter(final Writer delegate, final char delimiter) {
- this.delegate = delegate;
- this.delimiter = delimiter;
- }
-
- /**
- * Write multiple fields at once. Values will be auto escaped and quoted as
- * needed. Each value will be separated using the current delimiter
- *
- * @param fields
- * Values to write
- * @throws IOException
- * Error writing to the underlying writer object
- */
- public void write(final String... fields) throws IOException {
- for (final String field : fields) {
- write(field);
- }
- }
-
- /**
- * Write a single value. Values will be auto escaped and quoted as needed.
- * If this is not the first field of the current line the value will be
- * prepended with the current delimiter
- *
- * @param field
- * Value to write
- * @throws IOException
- * Error writing to the underlying writer object
- */
- public void write(final String field) throws IOException {
- if (fieldPosition != 0) {
- delegate.write(delimiter);
- }
- delegate.write(escape(field));
- fieldPosition++;
- }
-
- /**
- * Write a single integer value.
- *
- * @param value
- * Value to write
- * @throws IOException
- * Error writing to the underlying writer object
- */
- public void write(final int value) throws IOException {
- write(Integer.toString(value));
- }
-
- /**
- * Write muliple integer values
- *
- * @param values
- * values to write
- * @throws IOException
- * Error writing to the underlying writer object
- */
- public void write(final int... values) throws IOException {
- for (final int value : values) {
- write(Integer.toString(value));
- }
- }
-
- /**
- * Output a new line and advance the writer to the next line. The line
- * delimiter is the default for the platform.
- *
- * @throws IOException
- * Error writing to the underlying writer object
- */
- public void nextLine() throws IOException {
- delegate.write(NEW_LINE);
- fieldPosition = 0;
- }
-
- /**
- * Close the underlying writer object. Once closed all write operations will
- * fail
- *
- * @throws IOException
- * Error closing the underlying writer object
- */
- public void close() throws IOException {
- delegate.close();
- }
-
- /**
- * Escapes any occurrences of the quote character in value by replacing it
- * with a double quote. Also Quotes the value if a quote or delimiter value
- * is found.
- *
- * @param value
- * String that needs escaping
- * @return New string with all values escaped
- */
- private String escape(final String value) {
- String escapedValue = value;
-
- // Escape and quote if the source value contains the delimiter
- // or the quote character
- if (value.indexOf(QUOTE) != -1 || value.indexOf(delimiter) != -1) {
- escapedValue = value.replace(QUOTE, ESCAPED_QUOTE);
- escapedValue = QUOTE + escapedValue + QUOTE;
- }
-
- return escapedValue;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Brock Janiczak - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.csv;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Helper class for writing out CSV or tab delimited files.
+ * <p>
+ * <strong>Example Usage:</strong>
+ *
+ * <pre>
+ * delimitedWriter.writeFields(&quot;header1&quot;, &quot;header2&quot;, ...);
+ * for each line to be written {
+ * delimitedWriter.writeField(value1);
+ * delimitedWriter.writeField(value2);
+ * delimitedWriter.nextLine();
+ * }
+ * delimitedWriter.close();
+ * </pre>
+ *
+ * </p>
+ */
+class DelimitedWriter {
+ private static final String QUOTE = "\"";
+ private static final String ESCAPED_QUOTE = "\"\"";
+
+ private static final char DEFAULT_DELIMITER = ',';
+ private static final String NEW_LINE = System.getProperty("line.separator");
+ private final char delimiter;
+ private final Writer delegate;
+ private int fieldPosition = 0;
+
+ /**
+ * Creates a new Delimited writer using the default delimiter
+ *
+ * @param delegate
+ * Writer to delegate all writes to
+ */
+ public DelimitedWriter(final Writer delegate) {
+ this(delegate, DEFAULT_DELIMITER);
+ }
+
+ /**
+ * Creates a new Delimited writer using the default delimiter
+ *
+ * @param delegate
+ * Writer to delegate all writes to
+ * @param delimiter
+ * delimiter to use (usually a comma, tab or space)
+ */
+ public DelimitedWriter(final Writer delegate, final char delimiter) {
+ this.delegate = delegate;
+ this.delimiter = delimiter;
+ }
+
+ /**
+ * Write multiple fields at once. Values will be auto escaped and quoted as
+ * needed. Each value will be separated using the current delimiter
+ *
+ * @param fields
+ * Values to write
+ * @throws IOException
+ * Error writing to the underlying writer object
+ */
+ public void write(final String... fields) throws IOException {
+ for (final String field : fields) {
+ write(field);
+ }
+ }
+
+ /**
+ * Write a single value. Values will be auto escaped and quoted as needed.
+ * If this is not the first field of the current line the value will be
+ * prepended with the current delimiter
+ *
+ * @param field
+ * Value to write
+ * @throws IOException
+ * Error writing to the underlying writer object
+ */
+ public void write(final String field) throws IOException {
+ if (fieldPosition != 0) {
+ delegate.write(delimiter);
+ }
+ delegate.write(escape(field));
+ fieldPosition++;
+ }
+
+ /**
+ * Write a single integer value.
+ *
+ * @param value
+ * Value to write
+ * @throws IOException
+ * Error writing to the underlying writer object
+ */
+ public void write(final int value) throws IOException {
+ write(Integer.toString(value));
+ }
+
+ /**
+ * Write muliple integer values
+ *
+ * @param values
+ * values to write
+ * @throws IOException
+ * Error writing to the underlying writer object
+ */
+ public void write(final int... values) throws IOException {
+ for (final int value : values) {
+ write(Integer.toString(value));
+ }
+ }
+
+ /**
+ * Output a new line and advance the writer to the next line. The line
+ * delimiter is the default for the platform.
+ *
+ * @throws IOException
+ * Error writing to the underlying writer object
+ */
+ public void nextLine() throws IOException {
+ delegate.write(NEW_LINE);
+ fieldPosition = 0;
+ }
+
+ /**
+ * Close the underlying writer object. Once closed all write operations will
+ * fail
+ *
+ * @throws IOException
+ * Error closing the underlying writer object
+ */
+ public void close() throws IOException {
+ delegate.close();
+ }
+
+ /**
+ * Escapes any occurrences of the quote character in value by replacing it
+ * with a double quote. Also Quotes the value if a quote or delimiter value
+ * is found.
+ *
+ * @param value
+ * String that needs escaping
+ * @return New string with all values escaped
+ */
+ private String escape(final String value) {
+ String escapedValue = value;
+
+ // Escape and quote if the source value contains the delimiter
+ // or the quote character
+ if (value.indexOf(QUOTE) != -1 || value.indexOf(delimiter) != -1) {
+ escapedValue = value.replace(QUOTE, ESCAPED_QUOTE);
+ escapedValue = QUOTE + escapedValue + QUOTE;
+ }
+
+ return escapedValue;
+ }
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/html/HTMLFormatter.java b/org.jacoco.report/src/org/jacoco/report/html/HTMLFormatter.java
index 25fa42ed..30c12338 100644
--- a/org.jacoco.report/src/org/jacoco/report/html/HTMLFormatter.java
+++ b/org.jacoco.report/src/org/jacoco/report/html/HTMLFormatter.java
@@ -1,238 +1,238 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.html;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
-import org.jacoco.core.data.ExecutionData;
-import org.jacoco.core.data.SessionInfo;
-import org.jacoco.report.ILanguageNames;
-import org.jacoco.report.IMultiReportOutput;
-import org.jacoco.report.IReportGroupVisitor;
-import org.jacoco.report.IReportVisitor;
-import org.jacoco.report.ISourceFileLocator;
-import org.jacoco.report.JavaNames;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLGroupVisitor;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.ILinkable;
-import org.jacoco.report.internal.html.index.ElementIndex;
-import org.jacoco.report.internal.html.index.IIndexUpdate;
-import org.jacoco.report.internal.html.page.BundlePage;
-import org.jacoco.report.internal.html.page.ReportPage;
-import org.jacoco.report.internal.html.page.SessionsPage;
-import org.jacoco.report.internal.html.resources.Resources;
-import org.jacoco.report.internal.html.resources.Styles;
-import org.jacoco.report.internal.html.table.BarColumn;
-import org.jacoco.report.internal.html.table.CounterColumn;
-import org.jacoco.report.internal.html.table.LabelColumn;
-import org.jacoco.report.internal.html.table.PercentageColumn;
-import org.jacoco.report.internal.html.table.Table;
-
-/**
- * Formatter for coverage reports in multiple HTML pages.
- */
-public class HTMLFormatter implements IHTMLReportContext {
-
- private ILanguageNames languageNames = new JavaNames();
-
- private Locale locale = Locale.getDefault();
-
- private String footerText = "";
-
- private String outputEncoding = "UTF-8";
-
- private Resources resources;
-
- private ElementIndex index;
-
- private SessionsPage sessionsPage;
-
- private Table table;
-
- /**
- * New instance with default settings.
- */
- public HTMLFormatter() {
- }
-
- /**
- * Sets the implementation for language name display. Java language names
- * are defined by default.
- *
- * @param languageNames
- * converter for language specific names
- */
- public void setLanguageNames(final ILanguageNames languageNames) {
- this.languageNames = languageNames;
- }
-
- /**
- * Sets the locale used for report rendering. The current default locale is
- * used by default.
- *
- * @param locale
- * locale used for report rendering
- */
- public void setLocale(final Locale locale) {
- this.locale = locale;
- }
-
- /**
- * Sets the optional text that should be included in every footer page.
- *
- * @param footerText
- * footer text
- */
- public void setFooterText(final String footerText) {
- this.footerText = footerText;
- }
-
- /**
- * Sets the encoding used for generated HTML pages. Default is UTF-8.
- *
- * @param outputEncoding
- * HTML output encoding
- */
- public void setOutputEncoding(final String outputEncoding) {
- this.outputEncoding = outputEncoding;
- }
-
- // === IHTMLReportContext ===
-
- public ILanguageNames getLanguageNames() {
- return languageNames;
- }
-
- public Resources getResources() {
- return resources;
- }
-
- public Table getTable() {
- if (table == null) {
- table = createTable();
- }
- return table;
- }
-
- private Table createTable() {
- final Table t = new Table();
- t.add("Element", null, new LabelColumn(), false);
- t.add("Missed Instructions", Styles.BAR, new BarColumn(CounterEntity.INSTRUCTION,
- locale), true);
- t.add("Cov.", Styles.CTR2,
- new PercentageColumn(CounterEntity.INSTRUCTION, locale), false);
- t.add("Missed Branches", Styles.BAR, new BarColumn(CounterEntity.BRANCH, locale),
- false);
- t.add("Cov.", Styles.CTR2, new PercentageColumn(CounterEntity.BRANCH, locale),
- false);
- addMissedTotalColumns(t, "Cxty", CounterEntity.COMPLEXITY);
- addMissedTotalColumns(t, "Lines", CounterEntity.LINE);
- addMissedTotalColumns(t, "Methods", CounterEntity.METHOD);
- addMissedTotalColumns(t, "Classes", CounterEntity.CLASS);
- return t;
- }
-
- private void addMissedTotalColumns(final Table table, final String label,
- final CounterEntity entity) {
- table.add("Missed", Styles.CTR1,
- CounterColumn.newMissed(entity, locale), false);
- table.add(label, Styles.CTR2, CounterColumn.newTotal(entity, locale),
- false);
- }
-
- public String getFooterText() {
- return footerText;
- }
-
- public ILinkable getSessionsPage() {
- return sessionsPage;
- }
-
- public String getOutputEncoding() {
- return outputEncoding;
- }
-
- public IIndexUpdate getIndexUpdate() {
- return index;
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * Creates a new visitor to write a report to the given output.
- *
- * @param output
- * output to write the report to
- * @return visitor to emit the report data to
- * @throws IOException
- * in case of problems with the output stream
- */
- public IReportVisitor createVisitor(final IMultiReportOutput output)
- throws IOException {
- final ReportOutputFolder root = new ReportOutputFolder(output);
- resources = new Resources(root);
- resources.copyResources();
- index = new ElementIndex(root);
- return new IReportVisitor() {
-
- private List<SessionInfo> sessionInfos;
- private Collection<ExecutionData> executionData;
-
- private HTMLGroupVisitor groupHandler;
-
- public void visitInfo(final List<SessionInfo> sessionInfos,
- final Collection<ExecutionData> executionData)
- throws IOException {
- this.sessionInfos = sessionInfos;
- this.executionData = executionData;
- }
-
- public void visitBundle(final IBundleCoverage bundle,
- final ISourceFileLocator locator) throws IOException {
- final BundlePage page = new BundlePage(bundle, null, locator,
- root, HTMLFormatter.this);
- createSessionsPage(page);
- page.render();
- }
-
- public IReportGroupVisitor visitGroup(final String name)
- throws IOException {
- groupHandler = new HTMLGroupVisitor(null, root,
- HTMLFormatter.this, name);
- createSessionsPage(groupHandler.getPage());
- return groupHandler;
-
- }
-
- private void createSessionsPage(final ReportPage rootpage) {
- sessionsPage = new SessionsPage(sessionInfos, executionData,
- index, rootpage, root, HTMLFormatter.this);
- }
-
- public void visitEnd() throws IOException {
- if (groupHandler != null) {
- groupHandler.visitEnd();
- }
- sessionsPage.render();
- output.close();
- }
- };
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.html;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
+import org.jacoco.core.data.ExecutionData;
+import org.jacoco.core.data.SessionInfo;
+import org.jacoco.report.ILanguageNames;
+import org.jacoco.report.IMultiReportOutput;
+import org.jacoco.report.IReportGroupVisitor;
+import org.jacoco.report.IReportVisitor;
+import org.jacoco.report.ISourceFileLocator;
+import org.jacoco.report.JavaNames;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLGroupVisitor;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.ILinkable;
+import org.jacoco.report.internal.html.index.ElementIndex;
+import org.jacoco.report.internal.html.index.IIndexUpdate;
+import org.jacoco.report.internal.html.page.BundlePage;
+import org.jacoco.report.internal.html.page.ReportPage;
+import org.jacoco.report.internal.html.page.SessionsPage;
+import org.jacoco.report.internal.html.resources.Resources;
+import org.jacoco.report.internal.html.resources.Styles;
+import org.jacoco.report.internal.html.table.BarColumn;
+import org.jacoco.report.internal.html.table.CounterColumn;
+import org.jacoco.report.internal.html.table.LabelColumn;
+import org.jacoco.report.internal.html.table.PercentageColumn;
+import org.jacoco.report.internal.html.table.Table;
+
+/**
+ * Formatter for coverage reports in multiple HTML pages.
+ */
+public class HTMLFormatter implements IHTMLReportContext {
+
+ private ILanguageNames languageNames = new JavaNames();
+
+ private Locale locale = Locale.getDefault();
+
+ private String footerText = "";
+
+ private String outputEncoding = "UTF-8";
+
+ private Resources resources;
+
+ private ElementIndex index;
+
+ private SessionsPage sessionsPage;
+
+ private Table table;
+
+ /**
+ * New instance with default settings.
+ */
+ public HTMLFormatter() {
+ }
+
+ /**
+ * Sets the implementation for language name display. Java language names
+ * are defined by default.
+ *
+ * @param languageNames
+ * converter for language specific names
+ */
+ public void setLanguageNames(final ILanguageNames languageNames) {
+ this.languageNames = languageNames;
+ }
+
+ /**
+ * Sets the locale used for report rendering. The current default locale is
+ * used by default.
+ *
+ * @param locale
+ * locale used for report rendering
+ */
+ public void setLocale(final Locale locale) {
+ this.locale = locale;
+ }
+
+ /**
+ * Sets the optional text that should be included in every footer page.
+ *
+ * @param footerText
+ * footer text
+ */
+ public void setFooterText(final String footerText) {
+ this.footerText = footerText;
+ }
+
+ /**
+ * Sets the encoding used for generated HTML pages. Default is UTF-8.
+ *
+ * @param outputEncoding
+ * HTML output encoding
+ */
+ public void setOutputEncoding(final String outputEncoding) {
+ this.outputEncoding = outputEncoding;
+ }
+
+ // === IHTMLReportContext ===
+
+ public ILanguageNames getLanguageNames() {
+ return languageNames;
+ }
+
+ public Resources getResources() {
+ return resources;
+ }
+
+ public Table getTable() {
+ if (table == null) {
+ table = createTable();
+ }
+ return table;
+ }
+
+ private Table createTable() {
+ final Table t = new Table();
+ t.add("Element", null, new LabelColumn(), false);
+ t.add("Missed Instructions", Styles.BAR, new BarColumn(CounterEntity.INSTRUCTION,
+ locale), true);
+ t.add("Cov.", Styles.CTR2,
+ new PercentageColumn(CounterEntity.INSTRUCTION, locale), false);
+ t.add("Missed Branches", Styles.BAR, new BarColumn(CounterEntity.BRANCH, locale),
+ false);
+ t.add("Cov.", Styles.CTR2, new PercentageColumn(CounterEntity.BRANCH, locale),
+ false);
+ addMissedTotalColumns(t, "Cxty", CounterEntity.COMPLEXITY);
+ addMissedTotalColumns(t, "Lines", CounterEntity.LINE);
+ addMissedTotalColumns(t, "Methods", CounterEntity.METHOD);
+ addMissedTotalColumns(t, "Classes", CounterEntity.CLASS);
+ return t;
+ }
+
+ private void addMissedTotalColumns(final Table table, final String label,
+ final CounterEntity entity) {
+ table.add("Missed", Styles.CTR1,
+ CounterColumn.newMissed(entity, locale), false);
+ table.add(label, Styles.CTR2, CounterColumn.newTotal(entity, locale),
+ false);
+ }
+
+ public String getFooterText() {
+ return footerText;
+ }
+
+ public ILinkable getSessionsPage() {
+ return sessionsPage;
+ }
+
+ public String getOutputEncoding() {
+ return outputEncoding;
+ }
+
+ public IIndexUpdate getIndexUpdate() {
+ return index;
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * Creates a new visitor to write a report to the given output.
+ *
+ * @param output
+ * output to write the report to
+ * @return visitor to emit the report data to
+ * @throws IOException
+ * in case of problems with the output stream
+ */
+ public IReportVisitor createVisitor(final IMultiReportOutput output)
+ throws IOException {
+ final ReportOutputFolder root = new ReportOutputFolder(output);
+ resources = new Resources(root);
+ resources.copyResources();
+ index = new ElementIndex(root);
+ return new IReportVisitor() {
+
+ private List<SessionInfo> sessionInfos;
+ private Collection<ExecutionData> executionData;
+
+ private HTMLGroupVisitor groupHandler;
+
+ public void visitInfo(final List<SessionInfo> sessionInfos,
+ final Collection<ExecutionData> executionData)
+ throws IOException {
+ this.sessionInfos = sessionInfos;
+ this.executionData = executionData;
+ }
+
+ public void visitBundle(final IBundleCoverage bundle,
+ final ISourceFileLocator locator) throws IOException {
+ final BundlePage page = new BundlePage(bundle, null, locator,
+ root, HTMLFormatter.this);
+ createSessionsPage(page);
+ page.render();
+ }
+
+ public IReportGroupVisitor visitGroup(final String name)
+ throws IOException {
+ groupHandler = new HTMLGroupVisitor(null, root,
+ HTMLFormatter.this, name);
+ createSessionsPage(groupHandler.getPage());
+ return groupHandler;
+
+ }
+
+ private void createSessionsPage(final ReportPage rootpage) {
+ sessionsPage = new SessionsPage(sessionInfos, executionData,
+ index, rootpage, root, HTMLFormatter.this);
+ }
+
+ public void visitEnd() throws IOException {
+ if (groupHandler != null) {
+ groupHandler.visitEnd();
+ }
+ sessionsPage.render();
+ output.close();
+ }
+ };
+ }
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/AbstractGroupVisitor.java b/org.jacoco.report/src/org/jacoco/report/internal/AbstractGroupVisitor.java
index 8b5721c4..2a1a0a32 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/AbstractGroupVisitor.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/AbstractGroupVisitor.java
@@ -1,102 +1,102 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.CoverageNodeImpl;
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.analysis.ICoverageNode.ElementType;
-import org.jacoco.report.IReportGroupVisitor;
-import org.jacoco.report.ISourceFileLocator;
-
-/**
- * Internal base visitor to calculate group counter summaries for hierarchical
- * reports.
- */
-public abstract class AbstractGroupVisitor implements IReportGroupVisitor {
-
- /** coverage node for this group to total counters */
- protected final CoverageNodeImpl total;
-
- private AbstractGroupVisitor lastChild;
-
- /**
- * Creates a new group with the given name.
- *
- * @param name
- * name for the coverage node created internally
- */
- protected AbstractGroupVisitor(final String name) {
- total = new CoverageNodeImpl(ElementType.GROUP, name);
- }
-
- public final void visitBundle(final IBundleCoverage bundle,
- final ISourceFileLocator locator) throws IOException {
- finalizeLastChild();
- total.increment(bundle);
- handleBundle(bundle, locator);
- }
-
- /**
- * Called to handle the given bundle in a specific way.
- *
- * @param bundle
- * @param locator
- * @throws IOException
- */
- protected abstract void handleBundle(IBundleCoverage bundle,
- ISourceFileLocator locator) throws IOException;
-
- public final IReportGroupVisitor visitGroup(final String name)
- throws IOException {
- finalizeLastChild();
- lastChild = handleGroup(name);
- return lastChild;
- }
-
- /**
- * Called to handle a group with the given name in a specific way.
- *
- * @param name
- * @return created child group
- * @throws IOException
- */
- protected abstract AbstractGroupVisitor handleGroup(final String name)
- throws IOException;
-
- /**
- * Must be called at the end of every group.
- *
- * @throws IOException
- */
- public final void visitEnd() throws IOException {
- finalizeLastChild();
- handleEnd();
- }
-
- /**
- * Called to handle the end of this group in a specific way.
- *
- * @throws IOException
- */
- protected abstract void handleEnd() throws IOException;
-
- private void finalizeLastChild() throws IOException {
- if (lastChild != null) {
- lastChild.visitEnd();
- total.increment(lastChild.total);
- lastChild = null;
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.CoverageNodeImpl;
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.analysis.ICoverageNode.ElementType;
+import org.jacoco.report.IReportGroupVisitor;
+import org.jacoco.report.ISourceFileLocator;
+
+/**
+ * Internal base visitor to calculate group counter summaries for hierarchical
+ * reports.
+ */
+public abstract class AbstractGroupVisitor implements IReportGroupVisitor {
+
+ /** coverage node for this group to total counters */
+ protected final CoverageNodeImpl total;
+
+ private AbstractGroupVisitor lastChild;
+
+ /**
+ * Creates a new group with the given name.
+ *
+ * @param name
+ * name for the coverage node created internally
+ */
+ protected AbstractGroupVisitor(final String name) {
+ total = new CoverageNodeImpl(ElementType.GROUP, name);
+ }
+
+ public final void visitBundle(final IBundleCoverage bundle,
+ final ISourceFileLocator locator) throws IOException {
+ finalizeLastChild();
+ total.increment(bundle);
+ handleBundle(bundle, locator);
+ }
+
+ /**
+ * Called to handle the given bundle in a specific way.
+ *
+ * @param bundle
+ * @param locator
+ * @throws IOException
+ */
+ protected abstract void handleBundle(IBundleCoverage bundle,
+ ISourceFileLocator locator) throws IOException;
+
+ public final IReportGroupVisitor visitGroup(final String name)
+ throws IOException {
+ finalizeLastChild();
+ lastChild = handleGroup(name);
+ return lastChild;
+ }
+
+ /**
+ * Called to handle a group with the given name in a specific way.
+ *
+ * @param name
+ * @return created child group
+ * @throws IOException
+ */
+ protected abstract AbstractGroupVisitor handleGroup(final String name)
+ throws IOException;
+
+ /**
+ * Must be called at the end of every group.
+ *
+ * @throws IOException
+ */
+ public final void visitEnd() throws IOException {
+ finalizeLastChild();
+ handleEnd();
+ }
+
+ /**
+ * Called to handle the end of this group in a specific way.
+ *
+ * @throws IOException
+ */
+ protected abstract void handleEnd() throws IOException;
+
+ private void finalizeLastChild() throws IOException {
+ if (lastChild != null) {
+ lastChild.visitEnd();
+ total.increment(lastChild.total);
+ lastChild = null;
+ }
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/NormalizedFileNames.java b/org.jacoco.report/src/org/jacoco/report/internal/NormalizedFileNames.java
index 4afe9ecc..ab04b1c8 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/NormalizedFileNames.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/NormalizedFileNames.java
@@ -1,90 +1,90 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal;
-
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Internal utility to create normalized file names from string ids. The file
- * names generated by an instance of this class have the following properties:
- *
- * <ul>
- * <li>The same input id is mapped to the same file name.</li>
- * <li>Different ids are mapped to different file names.</li>
- * <li>For safe characters the file name corresponds to the input id, other
- * characters are replaced by <code>_</code> (underscore).</li>
- * <li>File names are case aware, i.e. the same file name but with different
- * upper/lower case characters is not possible.</li>
- * <li>If unique filenames can't directly created from the ids, additional
- * suffixes are appended.</li>
- * </ul>
- */
-class NormalizedFileNames {
-
- private static final BitSet LEGAL_CHARS = new BitSet();
-
- static {
- final String legal = "abcdefghijklmnopqrstuvwxyz"
- + "ABCDEFGHIJKLMNOPQRSTUVWYXZ0123456789$-._";
- for (final char c : legal.toCharArray()) {
- LEGAL_CHARS.set(c);
- }
- }
-
- private final Map<String, String> mapping = new HashMap<String, String>();
-
- private final Set<String> usedNames = new HashSet<String>();
-
- public String getFileName(final String id) {
- String name = mapping.get(id);
- if (name != null) {
- return name;
- }
- name = replaceIllegalChars(id);
- name = ensureUniqueness(name);
- mapping.put(id, name);
- return name;
- }
-
- private String replaceIllegalChars(final String s) {
- final StringBuilder sb = new StringBuilder(s.length());
- boolean modified = false;
- for (int i = 0; i < s.length(); i++) {
- final char c = s.charAt(i);
- if (LEGAL_CHARS.get(c)) {
- sb.append(c);
- } else {
- sb.append('_');
- modified = true;
- }
- }
- return modified ? sb.toString() : s;
- }
-
- private String ensureUniqueness(final String s) {
- String unique = s;
- String lower = unique.toLowerCase(Locale.ENGLISH);
- int idx = 1;
- while (usedNames.contains(lower)) {
- unique = s + '~' + idx++;
- lower = unique.toLowerCase(Locale.ENGLISH);
- }
- usedNames.add(lower);
- return unique;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal;
+
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Internal utility to create normalized file names from string ids. The file
+ * names generated by an instance of this class have the following properties:
+ *
+ * <ul>
+ * <li>The same input id is mapped to the same file name.</li>
+ * <li>Different ids are mapped to different file names.</li>
+ * <li>For safe characters the file name corresponds to the input id, other
+ * characters are replaced by <code>_</code> (underscore).</li>
+ * <li>File names are case aware, i.e. the same file name but with different
+ * upper/lower case characters is not possible.</li>
+ * <li>If unique filenames can't directly created from the ids, additional
+ * suffixes are appended.</li>
+ * </ul>
+ */
+class NormalizedFileNames {
+
+ private static final BitSet LEGAL_CHARS = new BitSet();
+
+ static {
+ final String legal = "abcdefghijklmnopqrstuvwxyz"
+ + "ABCDEFGHIJKLMNOPQRSTUVWYXZ0123456789$-._";
+ for (final char c : legal.toCharArray()) {
+ LEGAL_CHARS.set(c);
+ }
+ }
+
+ private final Map<String, String> mapping = new HashMap<String, String>();
+
+ private final Set<String> usedNames = new HashSet<String>();
+
+ public String getFileName(final String id) {
+ String name = mapping.get(id);
+ if (name != null) {
+ return name;
+ }
+ name = replaceIllegalChars(id);
+ name = ensureUniqueness(name);
+ mapping.put(id, name);
+ return name;
+ }
+
+ private String replaceIllegalChars(final String s) {
+ final StringBuilder sb = new StringBuilder(s.length());
+ boolean modified = false;
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ if (LEGAL_CHARS.get(c)) {
+ sb.append(c);
+ } else {
+ sb.append('_');
+ modified = true;
+ }
+ }
+ return modified ? sb.toString() : s;
+ }
+
+ private String ensureUniqueness(final String s) {
+ String unique = s;
+ String lower = unique.toLowerCase(Locale.ENGLISH);
+ int idx = 1;
+ while (usedNames.contains(lower)) {
+ unique = s + '~' + idx++;
+ lower = unique.toLowerCase(Locale.ENGLISH);
+ }
+ usedNames.add(lower);
+ return unique;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/ReportOutputFolder.java b/org.jacoco.report/src/org/jacoco/report/internal/ReportOutputFolder.java
index 9f263ce3..f4ad0d8a 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/ReportOutputFolder.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/ReportOutputFolder.java
@@ -1,126 +1,126 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jacoco.report.IMultiReportOutput;
-
-/**
- * Logical representation of a folder in the output structure. This utility
- * ensures valid and unique file names and helps to create relative links.
- */
-public class ReportOutputFolder {
-
- private final IMultiReportOutput output;
-
- private final ReportOutputFolder parent;
-
- private final String path;
-
- /** Cached sub-folder instances to guarantee stable normalization */
- private final Map<String, ReportOutputFolder> subFolders = new HashMap<String, ReportOutputFolder>();
-
- private final NormalizedFileNames fileNames;
-
- /**
- * Creates a new root folder for the given output.
- *
- * @param output
- * output for generated files
- */
- public ReportOutputFolder(final IMultiReportOutput output) {
- this(output, null, "");
- }
-
- /**
- * Creates a new root folder for the given output.
- *
- * @param output
- * output for generated files
- */
- private ReportOutputFolder(final IMultiReportOutput output,
- final ReportOutputFolder parent, final String path) {
- this.output = output;
- this.parent = parent;
- this.path = path;
- fileNames = new NormalizedFileNames();
- }
-
- /**
- * Creates a sub-folder with the given name.
- *
- * @param name
- * name of the sub-folder
- * @return handle for output into the sub-folder
- */
- public ReportOutputFolder subFolder(final String name) {
- final String normalizedName = normalize(name);
- ReportOutputFolder folder = subFolders.get(normalizedName);
- if (folder != null) {
- return folder;
- }
- folder = new ReportOutputFolder(output, this, path + normalizedName
- + "/");
- subFolders.put(normalizedName, folder);
- return folder;
- }
-
- /**
- * Creates a new file in this folder with the given local name.
- *
- * @param name
- * name of the sub-folder
- * @return handle for output into the sub-folder
- * @throws IOException
- * if the file creation fails
- */
- public OutputStream createFile(final String name) throws IOException {
- return output.createFile(path + normalize(name));
- }
-
- /**
- * Returns a link relative to a given base to a resource within this folder.
- *
- * @param base
- * base to create the relative link from
- * @param name
- * name of the file or folder in this folder
- * @return relative link
- * @throws IllegalArgumentException
- * if this folder and the base do not have the same root
- */
- public String getLink(final ReportOutputFolder base, final String name) {
- if (base.isAncestorOf(this)) {
- return this.path.substring(base.path.length()) + normalize(name);
- }
- if (base.parent == null) {
- throw new IllegalArgumentException("Folders with different roots.");
- }
- return "../" + this.getLink(base.parent, name);
- }
-
- private boolean isAncestorOf(final ReportOutputFolder folder) {
- if (this == folder) {
- return true;
- }
- return folder.parent == null ? false : isAncestorOf(folder.parent);
- }
-
- private String normalize(final String name) {
- return fileNames.getFileName(name);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jacoco.report.IMultiReportOutput;
+
+/**
+ * Logical representation of a folder in the output structure. This utility
+ * ensures valid and unique file names and helps to create relative links.
+ */
+public class ReportOutputFolder {
+
+ private final IMultiReportOutput output;
+
+ private final ReportOutputFolder parent;
+
+ private final String path;
+
+ /** Cached sub-folder instances to guarantee stable normalization */
+ private final Map<String, ReportOutputFolder> subFolders = new HashMap<String, ReportOutputFolder>();
+
+ private final NormalizedFileNames fileNames;
+
+ /**
+ * Creates a new root folder for the given output.
+ *
+ * @param output
+ * output for generated files
+ */
+ public ReportOutputFolder(final IMultiReportOutput output) {
+ this(output, null, "");
+ }
+
+ /**
+ * Creates a new root folder for the given output.
+ *
+ * @param output
+ * output for generated files
+ */
+ private ReportOutputFolder(final IMultiReportOutput output,
+ final ReportOutputFolder parent, final String path) {
+ this.output = output;
+ this.parent = parent;
+ this.path = path;
+ fileNames = new NormalizedFileNames();
+ }
+
+ /**
+ * Creates a sub-folder with the given name.
+ *
+ * @param name
+ * name of the sub-folder
+ * @return handle for output into the sub-folder
+ */
+ public ReportOutputFolder subFolder(final String name) {
+ final String normalizedName = normalize(name);
+ ReportOutputFolder folder = subFolders.get(normalizedName);
+ if (folder != null) {
+ return folder;
+ }
+ folder = new ReportOutputFolder(output, this, path + normalizedName
+ + "/");
+ subFolders.put(normalizedName, folder);
+ return folder;
+ }
+
+ /**
+ * Creates a new file in this folder with the given local name.
+ *
+ * @param name
+ * name of the sub-folder
+ * @return handle for output into the sub-folder
+ * @throws IOException
+ * if the file creation fails
+ */
+ public OutputStream createFile(final String name) throws IOException {
+ return output.createFile(path + normalize(name));
+ }
+
+ /**
+ * Returns a link relative to a given base to a resource within this folder.
+ *
+ * @param base
+ * base to create the relative link from
+ * @param name
+ * name of the file or folder in this folder
+ * @return relative link
+ * @throws IllegalArgumentException
+ * if this folder and the base do not have the same root
+ */
+ public String getLink(final ReportOutputFolder base, final String name) {
+ if (base.isAncestorOf(this)) {
+ return this.path.substring(base.path.length()) + normalize(name);
+ }
+ if (base.parent == null) {
+ throw new IllegalArgumentException("Folders with different roots.");
+ }
+ return "../" + this.getLink(base.parent, name);
+ }
+
+ private boolean isAncestorOf(final ReportOutputFolder folder) {
+ if (this == folder) {
+ return true;
+ }
+ return folder.parent == null ? false : isAncestorOf(folder.parent);
+ }
+
+ private String normalize(final String name) {
+ return fileNames.getFileName(name);
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLDocument.java b/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLDocument.java
index ee6d9373..fc220608 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLDocument.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLDocument.java
@@ -1,97 +1,97 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-
-import org.jacoco.report.internal.xml.XMLDocument;
-
-/**
- * {@link XMLDocument} that declares its content type to be XHTML 1.0 Strict and
- * produces {@link HTMLElement}s as children.
- */
-public class HTMLDocument extends XMLDocument {
-
- private static final String ROOT = "html";
-
- private static final String PUBID = "-//W3C//DTD XHTML 1.0 Strict//EN";
-
- private static final String SYSTEM = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
-
- private static final String XMLNS = "xmlns";
-
- private static final String XHTML_NAMESPACE_URL = "http://www.w3.org/1999/xhtml";
-
- /**
- * Creates a new HTML document based on the given writer.
- *
- * @param writer
- * writer for content output
- * @param encoding
- * document encoding
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLDocument(final Writer writer, final String encoding)
- throws IOException {
- super(ROOT, PUBID, SYSTEM, encoding, false, writer);
- attr(XMLNS, XHTML_NAMESPACE_URL);
- }
-
- /**
- * Creates a new HTML document based on the given stream.
- *
- * @param output
- * stream for content output
- * @param encoding
- * document encoding
- * @throws IOException
- * in case of problems with the stream
- */
- public HTMLDocument(final OutputStream output, final String encoding)
- throws IOException {
- super(ROOT, PUBID, SYSTEM, encoding, false, output);
- attr(XMLNS, XHTML_NAMESPACE_URL);
- }
-
- @Override
- public HTMLElement element(final String name) throws IOException {
- final HTMLElement element = new HTMLElement(writer, name);
- addChildElement(element);
- return element;
- }
-
- /**
- * Creates a 'head' element.
- *
- * @return 'head' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement head() throws IOException {
- return element("head");
- }
-
- /**
- * Creates a 'body' element.
- *
- * @return 'body' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement body() throws IOException {
- return element("body");
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+
+import org.jacoco.report.internal.xml.XMLDocument;
+
+/**
+ * {@link XMLDocument} that declares its content type to be XHTML 1.0 Strict and
+ * produces {@link HTMLElement}s as children.
+ */
+public class HTMLDocument extends XMLDocument {
+
+ private static final String ROOT = "html";
+
+ private static final String PUBID = "-//W3C//DTD XHTML 1.0 Strict//EN";
+
+ private static final String SYSTEM = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
+
+ private static final String XMLNS = "xmlns";
+
+ private static final String XHTML_NAMESPACE_URL = "http://www.w3.org/1999/xhtml";
+
+ /**
+ * Creates a new HTML document based on the given writer.
+ *
+ * @param writer
+ * writer for content output
+ * @param encoding
+ * document encoding
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLDocument(final Writer writer, final String encoding)
+ throws IOException {
+ super(ROOT, PUBID, SYSTEM, encoding, false, writer);
+ attr(XMLNS, XHTML_NAMESPACE_URL);
+ }
+
+ /**
+ * Creates a new HTML document based on the given stream.
+ *
+ * @param output
+ * stream for content output
+ * @param encoding
+ * document encoding
+ * @throws IOException
+ * in case of problems with the stream
+ */
+ public HTMLDocument(final OutputStream output, final String encoding)
+ throws IOException {
+ super(ROOT, PUBID, SYSTEM, encoding, false, output);
+ attr(XMLNS, XHTML_NAMESPACE_URL);
+ }
+
+ @Override
+ public HTMLElement element(final String name) throws IOException {
+ final HTMLElement element = new HTMLElement(writer, name);
+ addChildElement(element);
+ return element;
+ }
+
+ /**
+ * Creates a 'head' element.
+ *
+ * @return 'head' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement head() throws IOException {
+ return element("head");
+ }
+
+ /**
+ * Creates a 'body' element.
+ *
+ * @return 'body' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement body() throws IOException {
+ return element("body");
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLElement.java b/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLElement.java
index 47da3b35..11ccf89e 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLElement.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLElement.java
@@ -1,396 +1,396 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.xml.XMLElement;
-
-/**
- * A {@link XMLElement} with utility methods to create XHTML documents. It
- * provides methods of HTML tags to avoid magic strings in the generators.
- */
-public class HTMLElement extends XMLElement {
-
- /**
- * Creates a new element for a HTML document.
- *
- * @param writer
- * all output will be written directly to this
- * @param name
- * element name
- */
- protected HTMLElement(final Writer writer, final String name) {
- super(writer, name);
- }
-
- @Override
- public HTMLElement element(final String name) throws IOException {
- final HTMLElement element = new HTMLElement(writer, name);
- addChildElement(element);
- return element;
- }
-
- private void classattr(final String classattr) throws IOException {
- attr("class", classattr);
- }
-
- /**
- * Creates a 'meta' element.
- *
- * @param httpequivattr
- * value of the http-equiv attribute
- * @param contentattr
- * value for the content attribute
- * @return 'meta' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement meta(final String httpequivattr, final String contentattr)
- throws IOException {
- final HTMLElement meta = element("meta");
- meta.attr("http-equiv", httpequivattr);
- meta.attr("content", contentattr);
- return meta;
- }
-
- /**
- * Creates a 'link' element.
- *
- * @param relattr
- * value of the rel attribute
- * @param hrefattr
- * value for the href attribute
- * @param typeattr
- * value for the type attribute
- * @return 'link' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement link(final String relattr, final String hrefattr,
- final String typeattr) throws IOException {
- final HTMLElement link = element("link");
- link.attr("rel", relattr);
- link.attr("href", hrefattr);
- link.attr("type", typeattr);
- return link;
- }
-
- /**
- * Creates a 'title' element.
- *
- * @return 'title' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement title() throws IOException {
- return element("title");
- }
-
- /**
- * Creates a 'h1' element.
- *
- * @return 'h1' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement h1() throws IOException {
- return element("h1");
- }
-
- /**
- * Creates a 'p' element.
- *
- * @return 'p' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement p() throws IOException {
- return element("p");
- }
-
- /**
- * Creates a 'span' element.
- *
- * @return 'span' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement span() throws IOException {
- return element("span");
- }
-
- /**
- * Creates a 'span' element.
- *
- * @param classattr
- * value of the class attribute
- * @return 'span' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement span(final String classattr) throws IOException {
- final HTMLElement span = span();
- span.classattr(classattr);
- return span;
- }
-
- /**
- * Creates a 'span' element.
- *
- * @param classattr
- * value of the class attribute
- * @param idattr
- * value of the id attribute
- * @return 'span' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement span(final String classattr, final String idattr)
- throws IOException {
- final HTMLElement span = span(classattr);
- span.attr("id", idattr);
- return span;
- }
-
- /**
- * Creates a 'div' element.
- *
- * @param classattr
- * value of the class attribute
- * @return 'div' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement div(final String classattr) throws IOException {
- final HTMLElement div = element("div");
- div.classattr(classattr);
- return div;
- }
-
- /**
- * Creates a 'code' element.
- *
- * @return 'code' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement code() throws IOException {
- return element("code");
- }
-
- /**
- * Creates a 'pre' element.
- *
- * @param classattr
- * value of the class attribute
- * @return 'pre' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement pre(final String classattr) throws IOException {
- final HTMLElement pre = element("pre");
- pre.classattr(classattr);
- return pre;
- }
-
- /**
- * Creates a 'a' element.
- *
- * @param hrefattr
- * value of the href attribute
- * @return 'a' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement a(final String hrefattr) throws IOException {
- final HTMLElement a = element("a");
- a.attr("href", hrefattr);
- return a;
- }
-
- /**
- * Creates a 'a' element.
- *
- * @param hrefattr
- * value of the href attribute
- * @param classattr
- * value of the class attribute
- * @return 'a' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement a(final String hrefattr, final String classattr)
- throws IOException {
- final HTMLElement a = a(hrefattr);
- a.classattr(classattr);
- return a;
- }
-
- /**
- * Creates a link to the given {@link ILinkable}.
- *
- * @param linkable
- * object to link to
- * @param base
- * base folder where the link should be placed
- * @return 'a' element or 'span' element, if the link target does not exist
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement a(final ILinkable linkable, final ReportOutputFolder base)
- throws IOException {
- final HTMLElement a;
- final String link = linkable.getLink(base);
- if (link == null) {
- a = span(linkable.getLinkStyle());
- } else {
- a = a(link, linkable.getLinkStyle());
- }
- a.text(linkable.getLinkLabel());
- return a;
- }
-
- /**
- * Creates a 'table' element.
- *
- * @param classattr
- * value of the class attribute
- * @return 'table' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement table(final String classattr) throws IOException {
- final HTMLElement table = element("table");
- table.classattr(classattr);
- table.attr("cellspacing", "0");
- return table;
- }
-
- /**
- * Creates a 'thead' element.
- *
- * @return 'thead' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement thead() throws IOException {
- return element("thead");
- }
-
- /**
- * Creates a 'tfoot' element.
- *
- * @return 'tfoot' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement tfoot() throws IOException {
- return element("tfoot");
- }
-
- /**
- * Creates a 'tbody' element.
- *
- * @return 'tbody' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement tbody() throws IOException {
- return element("tbody");
- }
-
- /**
- * Creates a 'tr' element.
- *
- * @return 'tr' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement tr() throws IOException {
- return element("tr");
- }
-
- /**
- * Creates a 'td' element.
- *
- * @return 'td' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement td() throws IOException {
- return element("td");
- }
-
- /**
- * Creates a 'td' element.
- *
- * @param classattr
- * value of the class attribute
- * @return 'td' element
- * @throws IOException
- * in case of problems with the writer
- */
- public HTMLElement td(final String classattr) throws IOException {
- final HTMLElement td = td();
- td.classattr(classattr);
- return td;
- }
-
- /**
- * Creates a 'img' element.
- *
- * @param srcattr
- * value of the src attribute
- * @param widthattr
- * value of the width attribute
- * @param heightattr
- * value of the height attribute
- * @param titleattr
- * value of the title and alt attribute
- * @throws IOException
- * in case of problems with the writer
- */
- public void img(final String srcattr, final int widthattr,
- final int heightattr, final String titleattr) throws IOException {
- final HTMLElement img = element("img");
- img.attr("src", srcattr);
- img.attr("width", widthattr);
- img.attr("height", heightattr);
- img.attr("title", titleattr);
- img.attr("alt", titleattr);
- img.close();
- }
-
- /**
- * Creates a 'script' element.
- *
- * @param typeattr
- * value of the type attribute
- * @param srcattr
- * value of the src attribute
- * @throws IOException
- * in case of problems with the writer
- */
- public void script(final String typeattr, final String srcattr)
- throws IOException {
- final HTMLElement script = element("script");
- script.attr("type", typeattr);
- script.attr("src", srcattr);
- // Enforce open and closing tag otherwise it won't work in browsers:
- script.text("");
- script.close();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.xml.XMLElement;
+
+/**
+ * A {@link XMLElement} with utility methods to create XHTML documents. It
+ * provides methods of HTML tags to avoid magic strings in the generators.
+ */
+public class HTMLElement extends XMLElement {
+
+ /**
+ * Creates a new element for a HTML document.
+ *
+ * @param writer
+ * all output will be written directly to this
+ * @param name
+ * element name
+ */
+ protected HTMLElement(final Writer writer, final String name) {
+ super(writer, name);
+ }
+
+ @Override
+ public HTMLElement element(final String name) throws IOException {
+ final HTMLElement element = new HTMLElement(writer, name);
+ addChildElement(element);
+ return element;
+ }
+
+ private void classattr(final String classattr) throws IOException {
+ attr("class", classattr);
+ }
+
+ /**
+ * Creates a 'meta' element.
+ *
+ * @param httpequivattr
+ * value of the http-equiv attribute
+ * @param contentattr
+ * value for the content attribute
+ * @return 'meta' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement meta(final String httpequivattr, final String contentattr)
+ throws IOException {
+ final HTMLElement meta = element("meta");
+ meta.attr("http-equiv", httpequivattr);
+ meta.attr("content", contentattr);
+ return meta;
+ }
+
+ /**
+ * Creates a 'link' element.
+ *
+ * @param relattr
+ * value of the rel attribute
+ * @param hrefattr
+ * value for the href attribute
+ * @param typeattr
+ * value for the type attribute
+ * @return 'link' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement link(final String relattr, final String hrefattr,
+ final String typeattr) throws IOException {
+ final HTMLElement link = element("link");
+ link.attr("rel", relattr);
+ link.attr("href", hrefattr);
+ link.attr("type", typeattr);
+ return link;
+ }
+
+ /**
+ * Creates a 'title' element.
+ *
+ * @return 'title' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement title() throws IOException {
+ return element("title");
+ }
+
+ /**
+ * Creates a 'h1' element.
+ *
+ * @return 'h1' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement h1() throws IOException {
+ return element("h1");
+ }
+
+ /**
+ * Creates a 'p' element.
+ *
+ * @return 'p' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement p() throws IOException {
+ return element("p");
+ }
+
+ /**
+ * Creates a 'span' element.
+ *
+ * @return 'span' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement span() throws IOException {
+ return element("span");
+ }
+
+ /**
+ * Creates a 'span' element.
+ *
+ * @param classattr
+ * value of the class attribute
+ * @return 'span' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement span(final String classattr) throws IOException {
+ final HTMLElement span = span();
+ span.classattr(classattr);
+ return span;
+ }
+
+ /**
+ * Creates a 'span' element.
+ *
+ * @param classattr
+ * value of the class attribute
+ * @param idattr
+ * value of the id attribute
+ * @return 'span' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement span(final String classattr, final String idattr)
+ throws IOException {
+ final HTMLElement span = span(classattr);
+ span.attr("id", idattr);
+ return span;
+ }
+
+ /**
+ * Creates a 'div' element.
+ *
+ * @param classattr
+ * value of the class attribute
+ * @return 'div' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement div(final String classattr) throws IOException {
+ final HTMLElement div = element("div");
+ div.classattr(classattr);
+ return div;
+ }
+
+ /**
+ * Creates a 'code' element.
+ *
+ * @return 'code' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement code() throws IOException {
+ return element("code");
+ }
+
+ /**
+ * Creates a 'pre' element.
+ *
+ * @param classattr
+ * value of the class attribute
+ * @return 'pre' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement pre(final String classattr) throws IOException {
+ final HTMLElement pre = element("pre");
+ pre.classattr(classattr);
+ return pre;
+ }
+
+ /**
+ * Creates a 'a' element.
+ *
+ * @param hrefattr
+ * value of the href attribute
+ * @return 'a' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement a(final String hrefattr) throws IOException {
+ final HTMLElement a = element("a");
+ a.attr("href", hrefattr);
+ return a;
+ }
+
+ /**
+ * Creates a 'a' element.
+ *
+ * @param hrefattr
+ * value of the href attribute
+ * @param classattr
+ * value of the class attribute
+ * @return 'a' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement a(final String hrefattr, final String classattr)
+ throws IOException {
+ final HTMLElement a = a(hrefattr);
+ a.classattr(classattr);
+ return a;
+ }
+
+ /**
+ * Creates a link to the given {@link ILinkable}.
+ *
+ * @param linkable
+ * object to link to
+ * @param base
+ * base folder where the link should be placed
+ * @return 'a' element or 'span' element, if the link target does not exist
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement a(final ILinkable linkable, final ReportOutputFolder base)
+ throws IOException {
+ final HTMLElement a;
+ final String link = linkable.getLink(base);
+ if (link == null) {
+ a = span(linkable.getLinkStyle());
+ } else {
+ a = a(link, linkable.getLinkStyle());
+ }
+ a.text(linkable.getLinkLabel());
+ return a;
+ }
+
+ /**
+ * Creates a 'table' element.
+ *
+ * @param classattr
+ * value of the class attribute
+ * @return 'table' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement table(final String classattr) throws IOException {
+ final HTMLElement table = element("table");
+ table.classattr(classattr);
+ table.attr("cellspacing", "0");
+ return table;
+ }
+
+ /**
+ * Creates a 'thead' element.
+ *
+ * @return 'thead' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement thead() throws IOException {
+ return element("thead");
+ }
+
+ /**
+ * Creates a 'tfoot' element.
+ *
+ * @return 'tfoot' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement tfoot() throws IOException {
+ return element("tfoot");
+ }
+
+ /**
+ * Creates a 'tbody' element.
+ *
+ * @return 'tbody' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement tbody() throws IOException {
+ return element("tbody");
+ }
+
+ /**
+ * Creates a 'tr' element.
+ *
+ * @return 'tr' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement tr() throws IOException {
+ return element("tr");
+ }
+
+ /**
+ * Creates a 'td' element.
+ *
+ * @return 'td' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement td() throws IOException {
+ return element("td");
+ }
+
+ /**
+ * Creates a 'td' element.
+ *
+ * @param classattr
+ * value of the class attribute
+ * @return 'td' element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public HTMLElement td(final String classattr) throws IOException {
+ final HTMLElement td = td();
+ td.classattr(classattr);
+ return td;
+ }
+
+ /**
+ * Creates a 'img' element.
+ *
+ * @param srcattr
+ * value of the src attribute
+ * @param widthattr
+ * value of the width attribute
+ * @param heightattr
+ * value of the height attribute
+ * @param titleattr
+ * value of the title and alt attribute
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public void img(final String srcattr, final int widthattr,
+ final int heightattr, final String titleattr) throws IOException {
+ final HTMLElement img = element("img");
+ img.attr("src", srcattr);
+ img.attr("width", widthattr);
+ img.attr("height", heightattr);
+ img.attr("title", titleattr);
+ img.attr("alt", titleattr);
+ img.close();
+ }
+
+ /**
+ * Creates a 'script' element.
+ *
+ * @param typeattr
+ * value of the type attribute
+ * @param srcattr
+ * value of the src attribute
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public void script(final String typeattr, final String srcattr)
+ throws IOException {
+ final HTMLElement script = element("script");
+ script.attr("type", typeattr);
+ script.attr("src", srcattr);
+ // Enforce open and closing tag otherwise it won't work in browsers:
+ script.text("");
+ script.close();
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLGroupVisitor.java b/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLGroupVisitor.java
index 2330166c..54b4c528 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLGroupVisitor.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/HTMLGroupVisitor.java
@@ -1,86 +1,86 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.ISourceFileLocator;
-import org.jacoco.report.internal.AbstractGroupVisitor;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.page.BundlePage;
-import org.jacoco.report.internal.html.page.GroupPage;
-import org.jacoco.report.internal.html.page.NodePage;
-import org.jacoco.report.internal.html.page.ReportPage;
-
-/**
- * Group visitor for HTML reports.
- */
-public class HTMLGroupVisitor extends AbstractGroupVisitor {
-
- private final ReportOutputFolder folder;
-
- private final IHTMLReportContext context;
-
- private final GroupPage page;
-
- /**
- * Create a new group handler.
- *
- * @param parent
- * @param folder
- * @param context
- * @param name
- */
- public HTMLGroupVisitor(final ReportPage parent,
- final ReportOutputFolder folder, final IHTMLReportContext context,
- final String name) {
- super(name);
- this.folder = folder;
- this.context = context;
- page = new GroupPage(total, parent, folder, context);
- }
-
- /**
- * Returns the page rendered for this group.
- *
- * @return page for this group
- */
- public NodePage<ICoverageNode> getPage() {
- return page;
- }
-
- @Override
- protected void handleBundle(final IBundleCoverage bundle,
- final ISourceFileLocator locator) throws IOException {
- final BundlePage bundlepage = new BundlePage(bundle, page, locator,
- folder.subFolder(bundle.getName()), context);
- bundlepage.render();
- page.addItem(bundlepage);
- }
-
- @Override
- protected AbstractGroupVisitor handleGroup(final String name)
- throws IOException {
- final HTMLGroupVisitor handler = new HTMLGroupVisitor(page,
- folder.subFolder(name), context, name);
- page.addItem(handler.getPage());
- return handler;
- }
-
- @Override
- protected void handleEnd() throws IOException {
- page.render();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.ISourceFileLocator;
+import org.jacoco.report.internal.AbstractGroupVisitor;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.page.BundlePage;
+import org.jacoco.report.internal.html.page.GroupPage;
+import org.jacoco.report.internal.html.page.NodePage;
+import org.jacoco.report.internal.html.page.ReportPage;
+
+/**
+ * Group visitor for HTML reports.
+ */
+public class HTMLGroupVisitor extends AbstractGroupVisitor {
+
+ private final ReportOutputFolder folder;
+
+ private final IHTMLReportContext context;
+
+ private final GroupPage page;
+
+ /**
+ * Create a new group handler.
+ *
+ * @param parent
+ * @param folder
+ * @param context
+ * @param name
+ */
+ public HTMLGroupVisitor(final ReportPage parent,
+ final ReportOutputFolder folder, final IHTMLReportContext context,
+ final String name) {
+ super(name);
+ this.folder = folder;
+ this.context = context;
+ page = new GroupPage(total, parent, folder, context);
+ }
+
+ /**
+ * Returns the page rendered for this group.
+ *
+ * @return page for this group
+ */
+ public NodePage<ICoverageNode> getPage() {
+ return page;
+ }
+
+ @Override
+ protected void handleBundle(final IBundleCoverage bundle,
+ final ISourceFileLocator locator) throws IOException {
+ final BundlePage bundlepage = new BundlePage(bundle, page, locator,
+ folder.subFolder(bundle.getName()), context);
+ bundlepage.render();
+ page.addItem(bundlepage);
+ }
+
+ @Override
+ protected AbstractGroupVisitor handleGroup(final String name)
+ throws IOException {
+ final HTMLGroupVisitor handler = new HTMLGroupVisitor(page,
+ folder.subFolder(name), context, name);
+ page.addItem(handler.getPage());
+ return handler;
+ }
+
+ @Override
+ protected void handleEnd() throws IOException {
+ page.render();
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java b/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java
index 6bf4b388..4763a5d6 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java
@@ -1,82 +1,82 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html;
-
-import java.util.Locale;
-
-import org.jacoco.report.ILanguageNames;
-import org.jacoco.report.internal.html.index.IIndexUpdate;
-import org.jacoco.report.internal.html.resources.Resources;
-import org.jacoco.report.internal.html.table.Table;
-
-/**
- * Context and configuration information during creation of a HTML report.
- */
-public interface IHTMLReportContext {
-
- /**
- * Returns the static resources used in this report.
- *
- * @return static resources
- */
- public Resources getResources();
-
- /**
- * Returns the language names call-back used in this report.
- *
- * @return language names
- */
- public ILanguageNames getLanguageNames();
-
- /**
- * Returns a table for rendering coverage nodes.
- *
- * @return table for rendering
- */
- public Table getTable();
-
- /**
- * Returns a string of textual information to include in every page footer.
- *
- * @return footer text or empty string
- */
- public String getFooterText();
-
- /**
- * Returns the link to the sessions page.
- *
- * @return sessions page link
- */
- public ILinkable getSessionsPage();
-
- /**
- * Returns the encoding of the generated HTML documents.
- *
- * @return encoding for generated HTML documents
- */
- public String getOutputEncoding();
-
- /**
- * Returns the service for index updates.
- *
- * @return sevice for indes updates
- */
- public IIndexUpdate getIndexUpdate();
-
- /**
- * Returns the locale used to format numbers and dates.
- *
- * @return locale for numbers and dates
- */
- public Locale getLocale();
-
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html;
+
+import java.util.Locale;
+
+import org.jacoco.report.ILanguageNames;
+import org.jacoco.report.internal.html.index.IIndexUpdate;
+import org.jacoco.report.internal.html.resources.Resources;
+import org.jacoco.report.internal.html.table.Table;
+
+/**
+ * Context and configuration information during creation of a HTML report.
+ */
+public interface IHTMLReportContext {
+
+ /**
+ * Returns the static resources used in this report.
+ *
+ * @return static resources
+ */
+ public Resources getResources();
+
+ /**
+ * Returns the language names call-back used in this report.
+ *
+ * @return language names
+ */
+ public ILanguageNames getLanguageNames();
+
+ /**
+ * Returns a table for rendering coverage nodes.
+ *
+ * @return table for rendering
+ */
+ public Table getTable();
+
+ /**
+ * Returns a string of textual information to include in every page footer.
+ *
+ * @return footer text or empty string
+ */
+ public String getFooterText();
+
+ /**
+ * Returns the link to the sessions page.
+ *
+ * @return sessions page link
+ */
+ public ILinkable getSessionsPage();
+
+ /**
+ * Returns the encoding of the generated HTML documents.
+ *
+ * @return encoding for generated HTML documents
+ */
+ public String getOutputEncoding();
+
+ /**
+ * Returns the service for index updates.
+ *
+ * @return sevice for indes updates
+ */
+ public IIndexUpdate getIndexUpdate();
+
+ /**
+ * Returns the locale used to format numbers and dates.
+ *
+ * @return locale for numbers and dates
+ */
+ public Locale getLocale();
+
} \ No newline at end of file
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java
index 8fb04186..e3be26e3 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java
@@ -1,80 +1,80 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.core.analysis.IPackageCoverage;
-import org.jacoco.report.ISourceFileLocator;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-
-/**
- * Page showing coverage information for a bundle. The page contains a table
- * with all packages of the bundle.
- */
-public class BundlePage extends TablePage<ICoverageNode> {
-
- private final ISourceFileLocator locator;
-
- private IBundleCoverage bundle;
-
- /**
- * Creates a new visitor in the given context.
- *
- * @param bundle
- * @param parent
- * @param locator
- * @param folder
- * @param context
- */
- public BundlePage(final IBundleCoverage bundle, final ReportPage parent,
- final ISourceFileLocator locator, final ReportOutputFolder folder,
- final IHTMLReportContext context) {
- super(bundle.getPlainCopy(), parent, folder, context);
- this.bundle = bundle;
- this.locator = locator;
- }
-
- @Override
- public void render() throws IOException {
- renderPackages();
- super.render();
- // Don't keep the bundle structure in memory
- bundle = null;
- }
-
- private void renderPackages() throws IOException {
- for (final IPackageCoverage p : bundle.getPackages()) {
- final String packagename = p.getName();
- final String foldername = packagename.length() == 0 ? "default"
- : packagename.replace('/', '.');
- final PackagePage page = new PackagePage(p, this, locator,
- folder.subFolder(foldername), context);
- page.render();
- addItem(page);
- }
- }
-
- @Override
- protected String getOnload() {
- return "initialSort(['breadcrumb', 'coveragetable'])";
- }
-
- @Override
- protected String getFileName() {
- return "index.html";
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.core.analysis.IPackageCoverage;
+import org.jacoco.report.ISourceFileLocator;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+
+/**
+ * Page showing coverage information for a bundle. The page contains a table
+ * with all packages of the bundle.
+ */
+public class BundlePage extends TablePage<ICoverageNode> {
+
+ private final ISourceFileLocator locator;
+
+ private IBundleCoverage bundle;
+
+ /**
+ * Creates a new visitor in the given context.
+ *
+ * @param bundle
+ * @param parent
+ * @param locator
+ * @param folder
+ * @param context
+ */
+ public BundlePage(final IBundleCoverage bundle, final ReportPage parent,
+ final ISourceFileLocator locator, final ReportOutputFolder folder,
+ final IHTMLReportContext context) {
+ super(bundle.getPlainCopy(), parent, folder, context);
+ this.bundle = bundle;
+ this.locator = locator;
+ }
+
+ @Override
+ public void render() throws IOException {
+ renderPackages();
+ super.render();
+ // Don't keep the bundle structure in memory
+ bundle = null;
+ }
+
+ private void renderPackages() throws IOException {
+ for (final IPackageCoverage p : bundle.getPackages()) {
+ final String packagename = p.getName();
+ final String foldername = packagename.length() == 0 ? "default"
+ : packagename.replace('/', '.');
+ final PackagePage page = new PackagePage(p, this, locator,
+ folder.subFolder(foldername), context);
+ page.render();
+ addItem(page);
+ }
+ }
+
+ @Override
+ protected String getOnload() {
+ return "initialSort(['breadcrumb', 'coveragetable'])";
+ }
+
+ @Override
+ protected String getFileName() {
+ return "index.html";
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java
index ec09d9a2..4aefa0ad 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java
@@ -1,79 +1,79 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IClassCoverage;
-import org.jacoco.core.analysis.IMethodCoverage;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.ILinkable;
-
-/**
- * Page showing coverage information for a class as a table of methods. The
- * methods are linked to the corresponding source file.
- */
-public class ClassPage extends TablePage<IClassCoverage> {
-
- private final ILinkable sourcePage;
-
- /**
- * Creates a new visitor in the given context.
- *
- * @param classNode
- * @param parent
- * @param sourcePage
- * corresponding source page or <code>null</code>
- * @param folder
- * @param context
- */
- public ClassPage(final IClassCoverage classNode, final ReportPage parent,
- final ILinkable sourcePage, final ReportOutputFolder folder,
- final IHTMLReportContext context) {
- super(classNode, parent, folder, context);
- this.sourcePage = sourcePage;
- context.getIndexUpdate().addClass(this, classNode.getId());
- }
-
- @Override
- protected String getOnload() {
- return "initialSort(['breadcrumb'])";
- }
-
- @Override
- public void render() throws IOException {
- for (final IMethodCoverage m : getNode().getMethods()) {
- final String label = context.getLanguageNames().getMethodName(
- getNode().getName(), m.getName(), m.getDesc(),
- m.getSignature());
- addItem(new MethodItem(m, label, sourcePage));
- }
- super.render();
- }
-
- @Override
- protected String getFileName() {
- final String vmname = getNode().getName();
- final int pos = vmname.lastIndexOf('/');
- final String shortname = pos == -1 ? vmname : vmname.substring(pos + 1);
- return shortname + ".html";
- }
-
- @Override
- public String getLinkLabel() {
- return context.getLanguageNames().getClassName(getNode().getName(),
- getNode().getSignature(), getNode().getSuperName(),
- getNode().getInterfaceNames());
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.IMethodCoverage;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.ILinkable;
+
+/**
+ * Page showing coverage information for a class as a table of methods. The
+ * methods are linked to the corresponding source file.
+ */
+public class ClassPage extends TablePage<IClassCoverage> {
+
+ private final ILinkable sourcePage;
+
+ /**
+ * Creates a new visitor in the given context.
+ *
+ * @param classNode
+ * @param parent
+ * @param sourcePage
+ * corresponding source page or <code>null</code>
+ * @param folder
+ * @param context
+ */
+ public ClassPage(final IClassCoverage classNode, final ReportPage parent,
+ final ILinkable sourcePage, final ReportOutputFolder folder,
+ final IHTMLReportContext context) {
+ super(classNode, parent, folder, context);
+ this.sourcePage = sourcePage;
+ context.getIndexUpdate().addClass(this, classNode.getId());
+ }
+
+ @Override
+ protected String getOnload() {
+ return "initialSort(['breadcrumb'])";
+ }
+
+ @Override
+ public void render() throws IOException {
+ for (final IMethodCoverage m : getNode().getMethods()) {
+ final String label = context.getLanguageNames().getMethodName(
+ getNode().getName(), m.getName(), m.getDesc(),
+ m.getSignature());
+ addItem(new MethodItem(m, label, sourcePage));
+ }
+ super.render();
+ }
+
+ @Override
+ protected String getFileName() {
+ final String vmname = getNode().getName();
+ final int pos = vmname.lastIndexOf('/');
+ final String shortname = pos == -1 ? vmname : vmname.substring(pos + 1);
+ return shortname + ".html";
+ }
+
+ @Override
+ public String getLinkLabel() {
+ return context.getLanguageNames().getClassName(getNode().getName(),
+ getNode().getSignature(), getNode().getSuperName(),
+ getNode().getInterfaceNames());
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java
index 156b5d8d..a42ed137 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java
@@ -1,47 +1,47 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-
-/**
- * Page showing coverage information for a node that groups other nodes. The
- * page shows a table of linked nodes.
- */
-public class GroupPage extends TablePage<ICoverageNode> {
-
- /**
- * Creates a new visitor in the given context.
- *
- * @param node
- * @param parent
- * @param folder
- * @param context
- */
- public GroupPage(final ICoverageNode node, final ReportPage parent,
- final ReportOutputFolder folder, final IHTMLReportContext context) {
- super(node, parent, folder, context);
- }
-
- @Override
- protected String getOnload() {
- return "initialSort(['breadcrumb', 'coveragetable'])";
- }
-
- @Override
- protected String getFileName() {
- return "index.html";
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+
+/**
+ * Page showing coverage information for a node that groups other nodes. The
+ * page shows a table of linked nodes.
+ */
+public class GroupPage extends TablePage<ICoverageNode> {
+
+ /**
+ * Creates a new visitor in the given context.
+ *
+ * @param node
+ * @param parent
+ * @param folder
+ * @param context
+ */
+ public GroupPage(final ICoverageNode node, final ReportPage parent,
+ final ReportOutputFolder folder, final IHTMLReportContext context) {
+ super(node, parent, folder, context);
+ }
+
+ @Override
+ protected String getOnload() {
+ return "initialSort(['breadcrumb', 'coveragetable'])";
+ }
+
+ @Override
+ protected String getFileName() {
+ return "index.html";
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java
index b88a0c6c..42aa64ad 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java
@@ -1,61 +1,61 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.core.analysis.IMethodCoverage;
-import org.jacoco.core.analysis.ISourceNode;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.ILinkable;
-import org.jacoco.report.internal.html.resources.Styles;
-import org.jacoco.report.internal.html.table.ITableItem;
-
-/**
- * Table items representing a method.
- */
-final class MethodItem implements ITableItem {
-
- private final IMethodCoverage node;
-
- private final String label;
-
- private final ILinkable sourcePage;
-
- MethodItem(final IMethodCoverage node, final String label,
- final ILinkable sourcePage) {
- this.node = node;
- this.label = label;
- this.sourcePage = sourcePage;
- }
-
- public String getLinkLabel() {
- return label;
- }
-
- public String getLinkStyle() {
- return Styles.EL_METHOD;
- }
-
- public String getLink(final ReportOutputFolder base) {
- if (sourcePage == null) {
- return null;
- }
- final String link = sourcePage.getLink(base);
- final int first = node.getFirstLine();
- return first != ISourceNode.UNKNOWN_LINE ? link + "#L" + first : link;
- }
-
- public ICoverageNode getNode() {
- return node;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.core.analysis.IMethodCoverage;
+import org.jacoco.core.analysis.ISourceNode;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.ILinkable;
+import org.jacoco.report.internal.html.resources.Styles;
+import org.jacoco.report.internal.html.table.ITableItem;
+
+/**
+ * Table items representing a method.
+ */
+final class MethodItem implements ITableItem {
+
+ private final IMethodCoverage node;
+
+ private final String label;
+
+ private final ILinkable sourcePage;
+
+ MethodItem(final IMethodCoverage node, final String label,
+ final ILinkable sourcePage) {
+ this.node = node;
+ this.label = label;
+ this.sourcePage = sourcePage;
+ }
+
+ public String getLinkLabel() {
+ return label;
+ }
+
+ public String getLinkStyle() {
+ return Styles.EL_METHOD;
+ }
+
+ public String getLink(final ReportOutputFolder base) {
+ if (sourcePage == null) {
+ return null;
+ }
+ final String link = sourcePage.getLink(base);
+ final int first = node.getFirstLine();
+ return first != ISourceNode.UNKNOWN_LINE ? link + "#L" + first : link;
+ }
+
+ public ICoverageNode getNode() {
+ return node;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java
index dc5b55b7..3f7e044a 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java
@@ -1,70 +1,70 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.resources.Resources;
-import org.jacoco.report.internal.html.resources.Styles;
-import org.jacoco.report.internal.html.table.ITableItem;
-
-/**
- * Report page that represents a coverage node.
- *
- * @param <NodeType>
- * type of the node represented by this page
- */
-public abstract class NodePage<NodeType extends ICoverageNode> extends
- ReportPage implements ITableItem {
-
- private final NodeType node;
-
- /**
- * Creates a new node page.
- *
- * @param node
- * corresponding node
- * @param parent
- * optional hierarchical parent
- * @param folder
- * base folder to create this report in
- * @param context
- * settings context
- */
- protected NodePage(final NodeType node, final ReportPage parent,
- final ReportOutputFolder folder, final IHTMLReportContext context) {
- super(parent, folder, context);
- this.node = node;
- }
-
- // === ILinkable ===
-
- public String getLinkStyle() {
- if (isRootPage()) {
- return Styles.EL_REPORT;
- } else {
- return Resources.getElementStyle(node.getElementType());
- }
- }
-
- public String getLinkLabel() {
- return node.getName();
- }
-
- // === ICoverageTableItem ===
-
- public NodeType getNode() {
- return node;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.resources.Resources;
+import org.jacoco.report.internal.html.resources.Styles;
+import org.jacoco.report.internal.html.table.ITableItem;
+
+/**
+ * Report page that represents a coverage node.
+ *
+ * @param <NodeType>
+ * type of the node represented by this page
+ */
+public abstract class NodePage<NodeType extends ICoverageNode> extends
+ ReportPage implements ITableItem {
+
+ private final NodeType node;
+
+ /**
+ * Creates a new node page.
+ *
+ * @param node
+ * corresponding node
+ * @param parent
+ * optional hierarchical parent
+ * @param folder
+ * base folder to create this report in
+ * @param context
+ * settings context
+ */
+ protected NodePage(final NodeType node, final ReportPage parent,
+ final ReportOutputFolder folder, final IHTMLReportContext context) {
+ super(parent, folder, context);
+ this.node = node;
+ }
+
+ // === ILinkable ===
+
+ public String getLinkStyle() {
+ if (isRootPage()) {
+ return Styles.EL_REPORT;
+ } else {
+ return Resources.getElementStyle(node.getElementType());
+ }
+ }
+
+ public String getLinkLabel() {
+ return node.getName();
+ }
+
+ // === ICoverageTableItem ===
+
+ public NodeType getNode() {
+ return node;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java
index 8aeebaa6..54576da6 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java
@@ -1,101 +1,101 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jacoco.core.analysis.IClassCoverage;
-import org.jacoco.core.analysis.IPackageCoverage;
-import org.jacoco.core.analysis.ISourceFileCoverage;
-import org.jacoco.report.ISourceFileLocator;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.ILinkable;
-
-/**
- * Page showing coverage information for a Java package. The page contains a
- * table with all classes of the package.
- */
-public class PackagePage extends TablePage<IPackageCoverage> {
-
- private final ISourceFileLocator locator;
-
- /**
- * Creates a new visitor in the given context.
- *
- * @param node
- * @param parent
- * @param locator
- * @param folder
- * @param context
- */
- public PackagePage(final IPackageCoverage node, final ReportPage parent,
- final ISourceFileLocator locator, final ReportOutputFolder folder,
- final IHTMLReportContext context) {
- super(node, parent, folder, context);
- this.locator = locator;
- }
-
- @Override
- public void render() throws IOException {
- final Map<String, ILinkable> sourceFiles = renderSourceFiles();
- renderClasses(sourceFiles);
- super.render();
- }
-
- private final Map<String, ILinkable> renderSourceFiles() throws IOException {
- final Map<String, ILinkable> sourceFiles = new HashMap<String, ILinkable>();
- final String packagename = getNode().getName();
- for (final ISourceFileCoverage s : getNode().getSourceFiles()) {
- final String sourcename = s.getName();
- final Reader reader = locator
- .getSourceFile(packagename, sourcename);
- if (reader != null) {
- final SourceFilePage sourcePage = new SourceFilePage(s, reader,
- locator.getTabWidth(), this, folder, context);
- sourcePage.render();
- sourceFiles.put(sourcename, sourcePage);
- }
-
- }
- return sourceFiles;
- }
-
- private void renderClasses(final Map<String, ILinkable> sourceFiles)
- throws IOException {
- for (final IClassCoverage c : getNode().getClasses()) {
- final ClassPage page = new ClassPage(c, this, sourceFiles.get(c
- .getSourceFileName()), folder, context);
- page.render();
- addItem(page);
- }
- }
-
- @Override
- protected String getOnload() {
- return "initialSort(['breadcrumb', 'coveragetable'])";
- }
-
- @Override
- protected String getFileName() {
- return "index.html";
- }
-
- @Override
- public String getLinkLabel() {
- return context.getLanguageNames().getPackageName(getNode().getName());
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.IPackageCoverage;
+import org.jacoco.core.analysis.ISourceFileCoverage;
+import org.jacoco.report.ISourceFileLocator;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.ILinkable;
+
+/**
+ * Page showing coverage information for a Java package. The page contains a
+ * table with all classes of the package.
+ */
+public class PackagePage extends TablePage<IPackageCoverage> {
+
+ private final ISourceFileLocator locator;
+
+ /**
+ * Creates a new visitor in the given context.
+ *
+ * @param node
+ * @param parent
+ * @param locator
+ * @param folder
+ * @param context
+ */
+ public PackagePage(final IPackageCoverage node, final ReportPage parent,
+ final ISourceFileLocator locator, final ReportOutputFolder folder,
+ final IHTMLReportContext context) {
+ super(node, parent, folder, context);
+ this.locator = locator;
+ }
+
+ @Override
+ public void render() throws IOException {
+ final Map<String, ILinkable> sourceFiles = renderSourceFiles();
+ renderClasses(sourceFiles);
+ super.render();
+ }
+
+ private final Map<String, ILinkable> renderSourceFiles() throws IOException {
+ final Map<String, ILinkable> sourceFiles = new HashMap<String, ILinkable>();
+ final String packagename = getNode().getName();
+ for (final ISourceFileCoverage s : getNode().getSourceFiles()) {
+ final String sourcename = s.getName();
+ final Reader reader = locator
+ .getSourceFile(packagename, sourcename);
+ if (reader != null) {
+ final SourceFilePage sourcePage = new SourceFilePage(s, reader,
+ locator.getTabWidth(), this, folder, context);
+ sourcePage.render();
+ sourceFiles.put(sourcename, sourcePage);
+ }
+
+ }
+ return sourceFiles;
+ }
+
+ private void renderClasses(final Map<String, ILinkable> sourceFiles)
+ throws IOException {
+ for (final IClassCoverage c : getNode().getClasses()) {
+ final ClassPage page = new ClassPage(c, this, sourceFiles.get(c
+ .getSourceFileName()), folder, context);
+ page.render();
+ addItem(page);
+ }
+ }
+
+ @Override
+ protected String getOnload() {
+ return "initialSort(['breadcrumb', 'coveragetable'])";
+ }
+
+ @Override
+ protected String getFileName() {
+ return "index.html";
+ }
+
+ @Override
+ public String getLinkLabel() {
+ return context.getLanguageNames().getPackageName(getNode().getName());
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java
index 9c4c2b61..429d62b0 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java
@@ -1,172 +1,172 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import java.io.IOException;
-
-import org.jacoco.core.JaCoCo;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLDocument;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.ILinkable;
-import org.jacoco.report.internal.html.resources.Resources;
-import org.jacoco.report.internal.html.resources.Styles;
-
-/**
- * Base class for HTML page generators. It renders the page skeleton with the
- * breadcrumb, the title and the footer. Every report page is part of a
- * hierarchy and has a parent page (except the root page).
- */
-public abstract class ReportPage implements ILinkable {
-
- private final ReportPage parent;
-
- /** output folder for this node */
- protected final ReportOutputFolder folder;
-
- /** context for this report */
- protected final IHTMLReportContext context;
-
- /**
- * Creates a new report page.
- *
- * @param parent
- * optional hierarchical parent
- * @param folder
- * base folder to create this report in
- * @param context
- * settings context
- */
- protected ReportPage(final ReportPage parent,
- final ReportOutputFolder folder, final IHTMLReportContext context) {
- this.parent = parent;
- this.context = context;
- this.folder = folder;
- }
-
- /**
- * Checks whether this is the root page of the report.
- *
- * @return <code>true</code> if this is the root page
- */
- protected final boolean isRootPage() {
- return parent == null;
- }
-
- /**
- * Renders this page's content and optionally additional pages. This method
- * must be called at most once.
- *
- * @throws IOException
- */
- public void render() throws IOException {
- final HTMLDocument doc = new HTMLDocument(
- folder.createFile(getFileName()), context.getOutputEncoding());
- doc.attr("lang", context.getLocale().getLanguage());
- head(doc.head());
- body(doc.body());
- doc.close();
- }
-
- /**
- * Creates the elements within the head element.
- *
- * @param head
- * head tag of the page
- * @throws IOException
- * in case of IO problems with the report writer
- */
- protected void head(final HTMLElement head) throws IOException {
- head.meta("Content-Type", "text/html;charset=UTF-8");
- head.link("stylesheet",
- context.getResources().getLink(folder, Resources.STYLESHEET),
- "text/css");
- head.link("shortcut icon",
- context.getResources().getLink(folder, "report.gif"),
- "image/gif");
- head.title().text(getLinkLabel());
- }
-
- private void body(final HTMLElement body) throws IOException {
- body.attr("onload", getOnload());
- final HTMLElement navigation = body.div(Styles.BREADCRUMB);
- navigation.attr("id", "breadcrumb");
- infoLinks(navigation.span(Styles.RIGHT));
- breadcrumb(navigation, folder);
- body.h1().text(getLinkLabel());
- content(body);
- footer(body);
- }
-
- /**
- * Returns the onload handler for this page.
- *
- * @return handler or <code>null</code>
- */
- protected String getOnload() {
- return null;
- }
-
- private void infoLinks(final HTMLElement span) throws IOException {
- span.a(context.getSessionsPage(), folder);
- }
-
- private void breadcrumb(final HTMLElement div, final ReportOutputFolder base)
- throws IOException {
- breadcrumbParent(parent, div, base);
- div.span(getLinkStyle()).text(getLinkLabel());
- }
-
- private static void breadcrumbParent(final ReportPage page,
- final HTMLElement div, final ReportOutputFolder base)
- throws IOException {
- if (page != null) {
- breadcrumbParent(page.parent, div, base);
- div.a(page, base);
- div.text(" > ");
- }
- }
-
- private void footer(final HTMLElement body) throws IOException {
- final HTMLElement footer = body.div(Styles.FOOTER);
- final HTMLElement versioninfo = footer.span(Styles.RIGHT);
- versioninfo.text("Created with ");
- versioninfo.a(JaCoCo.HOMEURL).text("JaCoCo");
- versioninfo.text(" ").text(JaCoCo.VERSION);
- footer.text(context.getFooterText());
- }
-
- /**
- * Specifies the local file name of this page.
- *
- * @return local file name
- */
- protected abstract String getFileName();
-
- /**
- * Creates the actual content of the page.
- *
- * @param body
- * body tag of the page
- * @throws IOException
- * in case of IO problems with the report writer
- */
- protected abstract void content(final HTMLElement body) throws IOException;
-
- // === ILinkable ===
-
- public final String getLink(final ReportOutputFolder base) {
- return folder.getLink(base, getFileName());
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import java.io.IOException;
+
+import org.jacoco.core.JaCoCo;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLDocument;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.ILinkable;
+import org.jacoco.report.internal.html.resources.Resources;
+import org.jacoco.report.internal.html.resources.Styles;
+
+/**
+ * Base class for HTML page generators. It renders the page skeleton with the
+ * breadcrumb, the title and the footer. Every report page is part of a
+ * hierarchy and has a parent page (except the root page).
+ */
+public abstract class ReportPage implements ILinkable {
+
+ private final ReportPage parent;
+
+ /** output folder for this node */
+ protected final ReportOutputFolder folder;
+
+ /** context for this report */
+ protected final IHTMLReportContext context;
+
+ /**
+ * Creates a new report page.
+ *
+ * @param parent
+ * optional hierarchical parent
+ * @param folder
+ * base folder to create this report in
+ * @param context
+ * settings context
+ */
+ protected ReportPage(final ReportPage parent,
+ final ReportOutputFolder folder, final IHTMLReportContext context) {
+ this.parent = parent;
+ this.context = context;
+ this.folder = folder;
+ }
+
+ /**
+ * Checks whether this is the root page of the report.
+ *
+ * @return <code>true</code> if this is the root page
+ */
+ protected final boolean isRootPage() {
+ return parent == null;
+ }
+
+ /**
+ * Renders this page's content and optionally additional pages. This method
+ * must be called at most once.
+ *
+ * @throws IOException
+ */
+ public void render() throws IOException {
+ final HTMLDocument doc = new HTMLDocument(
+ folder.createFile(getFileName()), context.getOutputEncoding());
+ doc.attr("lang", context.getLocale().getLanguage());
+ head(doc.head());
+ body(doc.body());
+ doc.close();
+ }
+
+ /**
+ * Creates the elements within the head element.
+ *
+ * @param head
+ * head tag of the page
+ * @throws IOException
+ * in case of IO problems with the report writer
+ */
+ protected void head(final HTMLElement head) throws IOException {
+ head.meta("Content-Type", "text/html;charset=UTF-8");
+ head.link("stylesheet",
+ context.getResources().getLink(folder, Resources.STYLESHEET),
+ "text/css");
+ head.link("shortcut icon",
+ context.getResources().getLink(folder, "report.gif"),
+ "image/gif");
+ head.title().text(getLinkLabel());
+ }
+
+ private void body(final HTMLElement body) throws IOException {
+ body.attr("onload", getOnload());
+ final HTMLElement navigation = body.div(Styles.BREADCRUMB);
+ navigation.attr("id", "breadcrumb");
+ infoLinks(navigation.span(Styles.RIGHT));
+ breadcrumb(navigation, folder);
+ body.h1().text(getLinkLabel());
+ content(body);
+ footer(body);
+ }
+
+ /**
+ * Returns the onload handler for this page.
+ *
+ * @return handler or <code>null</code>
+ */
+ protected String getOnload() {
+ return null;
+ }
+
+ private void infoLinks(final HTMLElement span) throws IOException {
+ span.a(context.getSessionsPage(), folder);
+ }
+
+ private void breadcrumb(final HTMLElement div, final ReportOutputFolder base)
+ throws IOException {
+ breadcrumbParent(parent, div, base);
+ div.span(getLinkStyle()).text(getLinkLabel());
+ }
+
+ private static void breadcrumbParent(final ReportPage page,
+ final HTMLElement div, final ReportOutputFolder base)
+ throws IOException {
+ if (page != null) {
+ breadcrumbParent(page.parent, div, base);
+ div.a(page, base);
+ div.text(" > ");
+ }
+ }
+
+ private void footer(final HTMLElement body) throws IOException {
+ final HTMLElement footer = body.div(Styles.FOOTER);
+ final HTMLElement versioninfo = footer.span(Styles.RIGHT);
+ versioninfo.text("Created with ");
+ versioninfo.a(JaCoCo.HOMEURL).text("JaCoCo");
+ versioninfo.text(" ").text(JaCoCo.VERSION);
+ footer.text(context.getFooterText());
+ }
+
+ /**
+ * Specifies the local file name of this page.
+ *
+ * @return local file name
+ */
+ protected abstract String getFileName();
+
+ /**
+ * Creates the actual content of the page.
+ *
+ * @param body
+ * body tag of the page
+ * @throws IOException
+ * in case of IO problems with the report writer
+ */
+ protected abstract void content(final HTMLElement body) throws IOException;
+
+ // === ILinkable ===
+
+ public final String getLink(final ReportOutputFolder base) {
+ return folder.getLink(base, getFileName());
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java
index 353058c9..e93ad471 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java
@@ -1,154 +1,154 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-import org.jacoco.core.data.ExecutionData;
-import org.jacoco.core.data.SessionInfo;
-import org.jacoco.report.ILanguageNames;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.index.ElementIndex;
-import org.jacoco.report.internal.html.resources.Styles;
-
-/**
- * Page to display information about sessions covered by this report.
- */
-public class SessionsPage extends ReportPage {
-
- private static final String MSG_SESSIONS = "This coverage report is based "
- + "on execution data from the following sessions:";
-
- private static final String MSG_NO_SESSIONS = "No session information available.";
-
- private static final String MSG_EXECDATA = "Execution data for the "
- + "following classes is considered in this report:";
-
- private static final String MSG_NO_EXECDATA = "No execution data available.";
-
- private final List<SessionInfo> sessionInfos;
-
- private final DateFormat dateFormat;
-
- private final List<ExecutionData> executionData;
-
- private final ElementIndex index;
-
- /**
- * Creates a new page page to display session information.
- *
- * @param sessionInfos
- * @param executionData
- * @param index
- * @param parent
- * @param folder
- * @param context
- */
- public SessionsPage(final List<SessionInfo> sessionInfos,
- final Collection<ExecutionData> executionData,
- final ElementIndex index, final ReportPage parent,
- final ReportOutputFolder folder, final IHTMLReportContext context) {
- super(parent, folder, context);
- this.sessionInfos = sessionInfos;
- this.executionData = new ArrayList<ExecutionData>(executionData);
- this.index = index;
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
- DateFormat.DEFAULT, context.getLocale());
- final ILanguageNames names = context.getLanguageNames();
- Collections.sort(this.executionData, new Comparator<ExecutionData>() {
- public int compare(final ExecutionData e1, final ExecutionData e2) {
- return names.getQualifiedClassName(e1.getName()).compareTo(
- names.getQualifiedClassName(e2.getName()));
- }
- });
- }
-
- @Override
- protected void content(final HTMLElement body) throws IOException {
- if (sessionInfos.isEmpty()) {
- body.p().text(MSG_NO_SESSIONS);
- } else {
- body.p().text(MSG_SESSIONS);
- sessionTable(body);
- }
- if (executionData.isEmpty()) {
- body.p().text(MSG_NO_EXECDATA);
- } else {
- body.p().text(MSG_EXECDATA);
- executionDataTable(body);
- }
- }
-
- private void sessionTable(final HTMLElement body) throws IOException {
- final HTMLElement table = body.table(Styles.COVERAGETABLE);
- {
- final HTMLElement tr = table.thead().tr();
- tr.td().text("Session");
- tr.td().text("Start Time");
- tr.td().text("Dump Time");
- }
- final HTMLElement tbody = table.tbody();
- for (final SessionInfo i : sessionInfos) {
- final HTMLElement tr = tbody.tr();
- tr.td().span(Styles.EL_SESSION).text(i.getId());
- tr.td().text(dateFormat.format(new Date(i.getStartTimeStamp())));
- tr.td().text(dateFormat.format(new Date(i.getDumpTimeStamp())));
- }
- }
-
- private void executionDataTable(final HTMLElement body) throws IOException {
- final HTMLElement table = body.table(Styles.COVERAGETABLE);
- {
- final HTMLElement tr = table.thead().tr();
- tr.td().text("Class");
- tr.td().text("Id");
- }
- final HTMLElement tbody = table.tbody();
- final ILanguageNames names = context.getLanguageNames();
- for (final ExecutionData e : executionData) {
- final HTMLElement tr = tbody.tr();
- final String link = index.getLinkToClass(e.getId());
- final String qualifiedName = names.getQualifiedClassName(e
- .getName());
- if (link == null) {
- tr.td().span(Styles.EL_CLASS).text(qualifiedName);
- } else {
- tr.td().a(link, Styles.EL_CLASS).text(qualifiedName);
- }
- final String id = String.format("%016x", Long.valueOf(e.getId()));
- tr.td().code().text(id);
- }
- }
-
- @Override
- protected String getFileName() {
- return ".sessions.html";
- }
-
- public String getLinkStyle() {
- return Styles.EL_SESSION;
- }
-
- public String getLinkLabel() {
- return "Sessions";
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import org.jacoco.core.data.ExecutionData;
+import org.jacoco.core.data.SessionInfo;
+import org.jacoco.report.ILanguageNames;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.index.ElementIndex;
+import org.jacoco.report.internal.html.resources.Styles;
+
+/**
+ * Page to display information about sessions covered by this report.
+ */
+public class SessionsPage extends ReportPage {
+
+ private static final String MSG_SESSIONS = "This coverage report is based "
+ + "on execution data from the following sessions:";
+
+ private static final String MSG_NO_SESSIONS = "No session information available.";
+
+ private static final String MSG_EXECDATA = "Execution data for the "
+ + "following classes is considered in this report:";
+
+ private static final String MSG_NO_EXECDATA = "No execution data available.";
+
+ private final List<SessionInfo> sessionInfos;
+
+ private final DateFormat dateFormat;
+
+ private final List<ExecutionData> executionData;
+
+ private final ElementIndex index;
+
+ /**
+ * Creates a new page page to display session information.
+ *
+ * @param sessionInfos
+ * @param executionData
+ * @param index
+ * @param parent
+ * @param folder
+ * @param context
+ */
+ public SessionsPage(final List<SessionInfo> sessionInfos,
+ final Collection<ExecutionData> executionData,
+ final ElementIndex index, final ReportPage parent,
+ final ReportOutputFolder folder, final IHTMLReportContext context) {
+ super(parent, folder, context);
+ this.sessionInfos = sessionInfos;
+ this.executionData = new ArrayList<ExecutionData>(executionData);
+ this.index = index;
+ dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
+ DateFormat.DEFAULT, context.getLocale());
+ final ILanguageNames names = context.getLanguageNames();
+ Collections.sort(this.executionData, new Comparator<ExecutionData>() {
+ public int compare(final ExecutionData e1, final ExecutionData e2) {
+ return names.getQualifiedClassName(e1.getName()).compareTo(
+ names.getQualifiedClassName(e2.getName()));
+ }
+ });
+ }
+
+ @Override
+ protected void content(final HTMLElement body) throws IOException {
+ if (sessionInfos.isEmpty()) {
+ body.p().text(MSG_NO_SESSIONS);
+ } else {
+ body.p().text(MSG_SESSIONS);
+ sessionTable(body);
+ }
+ if (executionData.isEmpty()) {
+ body.p().text(MSG_NO_EXECDATA);
+ } else {
+ body.p().text(MSG_EXECDATA);
+ executionDataTable(body);
+ }
+ }
+
+ private void sessionTable(final HTMLElement body) throws IOException {
+ final HTMLElement table = body.table(Styles.COVERAGETABLE);
+ {
+ final HTMLElement tr = table.thead().tr();
+ tr.td().text("Session");
+ tr.td().text("Start Time");
+ tr.td().text("Dump Time");
+ }
+ final HTMLElement tbody = table.tbody();
+ for (final SessionInfo i : sessionInfos) {
+ final HTMLElement tr = tbody.tr();
+ tr.td().span(Styles.EL_SESSION).text(i.getId());
+ tr.td().text(dateFormat.format(new Date(i.getStartTimeStamp())));
+ tr.td().text(dateFormat.format(new Date(i.getDumpTimeStamp())));
+ }
+ }
+
+ private void executionDataTable(final HTMLElement body) throws IOException {
+ final HTMLElement table = body.table(Styles.COVERAGETABLE);
+ {
+ final HTMLElement tr = table.thead().tr();
+ tr.td().text("Class");
+ tr.td().text("Id");
+ }
+ final HTMLElement tbody = table.tbody();
+ final ILanguageNames names = context.getLanguageNames();
+ for (final ExecutionData e : executionData) {
+ final HTMLElement tr = tbody.tr();
+ final String link = index.getLinkToClass(e.getId());
+ final String qualifiedName = names.getQualifiedClassName(e
+ .getName());
+ if (link == null) {
+ tr.td().span(Styles.EL_CLASS).text(qualifiedName);
+ } else {
+ tr.td().a(link, Styles.EL_CLASS).text(qualifiedName);
+ }
+ final String id = String.format("%016x", Long.valueOf(e.getId()));
+ tr.td().code().text(id);
+ }
+ }
+
+ @Override
+ protected String getFileName() {
+ return ".sessions.html";
+ }
+
+ public String getLinkStyle() {
+ return Styles.EL_SESSION;
+ }
+
+ public String getLinkLabel() {
+ return "Sessions";
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java
index b378e472..44cdead4 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java
@@ -1,85 +1,85 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import static java.lang.String.format;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.jacoco.core.analysis.ISourceFileCoverage;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.resources.Resources;
-
-/**
- * Page showing the content of a source file with numbered and highlighted
- * source lines.
- */
-public class SourceFilePage extends NodePage<ISourceFileCoverage> {
-
- private final Reader sourceReader;
-
- private final int tabWidth;
-
- /**
- * Creates a new page with given information.
- *
- * @param sourceFileNode
- * @param sourceReader
- * @param tabWidth
- * @param parent
- * @param folder
- * @param context
- */
- public SourceFilePage(final ISourceFileCoverage sourceFileNode,
- final Reader sourceReader, final int tabWidth,
- final ReportPage parent, final ReportOutputFolder folder,
- final IHTMLReportContext context) {
- super(sourceFileNode, parent, folder, context);
- this.sourceReader = sourceReader;
- this.tabWidth = tabWidth;
- }
-
- @Override
- protected void content(final HTMLElement body) throws IOException {
- final SourceHighlighter hl = new SourceHighlighter(context.getLocale());
- hl.render(body, getNode(), sourceReader);
- sourceReader.close();
- }
-
- @Override
- protected void head(final HTMLElement head) throws IOException {
- super.head(head);
- head.link(
- "stylesheet",
- context.getResources().getLink(folder,
- Resources.PRETTIFY_STYLESHEET), "text/css");
- head.script(
- "text/javascript",
- context.getResources().getLink(folder,
- Resources.PRETTIFY_SCRIPT));
- }
-
- @Override
- protected String getOnload() {
- return format("window['PR_TAB_WIDTH']=%d;prettyPrint()",
- Integer.valueOf(tabWidth));
- }
-
- @Override
- protected String getFileName() {
- return getNode().getName() + ".html";
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import static java.lang.String.format;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import org.jacoco.core.analysis.ISourceFileCoverage;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.resources.Resources;
+
+/**
+ * Page showing the content of a source file with numbered and highlighted
+ * source lines.
+ */
+public class SourceFilePage extends NodePage<ISourceFileCoverage> {
+
+ private final Reader sourceReader;
+
+ private final int tabWidth;
+
+ /**
+ * Creates a new page with given information.
+ *
+ * @param sourceFileNode
+ * @param sourceReader
+ * @param tabWidth
+ * @param parent
+ * @param folder
+ * @param context
+ */
+ public SourceFilePage(final ISourceFileCoverage sourceFileNode,
+ final Reader sourceReader, final int tabWidth,
+ final ReportPage parent, final ReportOutputFolder folder,
+ final IHTMLReportContext context) {
+ super(sourceFileNode, parent, folder, context);
+ this.sourceReader = sourceReader;
+ this.tabWidth = tabWidth;
+ }
+
+ @Override
+ protected void content(final HTMLElement body) throws IOException {
+ final SourceHighlighter hl = new SourceHighlighter(context.getLocale());
+ hl.render(body, getNode(), sourceReader);
+ sourceReader.close();
+ }
+
+ @Override
+ protected void head(final HTMLElement head) throws IOException {
+ super.head(head);
+ head.link(
+ "stylesheet",
+ context.getResources().getLink(folder,
+ Resources.PRETTIFY_STYLESHEET), "text/css");
+ head.script(
+ "text/javascript",
+ context.getResources().getLink(folder,
+ Resources.PRETTIFY_SCRIPT));
+ }
+
+ @Override
+ protected String getOnload() {
+ return format("window['PR_TAB_WIDTH']=%d;prettyPrint()",
+ Integer.valueOf(tabWidth));
+ }
+
+ @Override
+ protected String getFileName() {
+ return getNode().getName() + ".html";
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java
index 483496e2..8b7e191e 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java
@@ -1,131 +1,131 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Locale;
-
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.analysis.ILine;
-import org.jacoco.core.analysis.ISourceNode;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.resources.Styles;
-
-/**
- * Creates a highlighted output of a source file.
- */
-final class SourceHighlighter {
-
- private final Locale locale;
-
- private String lang;
-
- /**
- * Creates a new highlighter with default settings.
- *
- * @param locale
- * locale for tooltip rendering
- */
- public SourceHighlighter(final Locale locale) {
- this.locale = locale;
- lang = "java";
- }
-
- /**
- * Specifies the source language. This value might be used for syntax
- * highlighting. Default is "java".
- *
- * @param lang
- * source language identifier
- */
- public void setLanguage(final String lang) {
- this.lang = lang;
- }
-
- /**
- * Highlights the given source file.
- *
- * @param parent
- * parent HTML element
- * @param source
- * highlighting information
- * @param contents
- * contents of the source file
- * @throws IOException
- * problems while reading the source file or writing the output
- */
- public void render(final HTMLElement parent, final ISourceNode source,
- final Reader contents) throws IOException {
- final HTMLElement pre = parent.pre(Styles.SOURCE + " lang-" + lang
- + " linenums");
- final BufferedReader lineBuffer = new BufferedReader(contents);
- String line;
- int nr = 0;
- while ((line = lineBuffer.readLine()) != null) {
- nr++;
- renderCodeLine(pre, line, source.getLine(nr), nr);
- }
- }
-
- private void renderCodeLine(final HTMLElement pre, final String linesrc,
- final ILine line, final int lineNr) throws IOException {
- highlight(pre, line, lineNr).text(linesrc);
- pre.text("\n");
- }
-
- HTMLElement highlight(final HTMLElement pre, final ILine line,
- final int lineNr) throws IOException {
- final String style;
- switch (line.getStatus()) {
- case ICounter.NOT_COVERED:
- style = Styles.NOT_COVERED;
- break;
- case ICounter.FULLY_COVERED:
- style = Styles.FULLY_COVERED;
- break;
- case ICounter.PARTLY_COVERED:
- style = Styles.PARTLY_COVERED;
- break;
- default:
- return pre;
- }
-
- final String lineId = "L" + Integer.toString(lineNr);
- final ICounter branches = line.getBranchCounter();
- switch (branches.getStatus()) {
- case ICounter.NOT_COVERED:
- return span(pre, lineId, style, Styles.BRANCH_NOT_COVERED,
- "All %2$d branches missed.", branches);
- case ICounter.FULLY_COVERED:
- return span(pre, lineId, style, Styles.BRANCH_FULLY_COVERED,
- "All %2$d branches covered.", branches);
- case ICounter.PARTLY_COVERED:
- return span(pre, lineId, style, Styles.BRANCH_PARTLY_COVERED,
- "%1$d of %2$d branches missed.", branches);
- default:
- return pre.span(style, lineId);
- }
- }
-
- private HTMLElement span(final HTMLElement parent, final String id,
- final String style1, final String style2, final String title,
- final ICounter branches) throws IOException {
- final HTMLElement span = parent.span(style1 + " " + style2, id);
- final Integer missed = Integer.valueOf(branches.getMissedCount());
- final Integer total = Integer.valueOf(branches.getTotalCount());
- span.attr("title", String.format(locale, title, missed, total));
- return span;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Locale;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.analysis.ILine;
+import org.jacoco.core.analysis.ISourceNode;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.resources.Styles;
+
+/**
+ * Creates a highlighted output of a source file.
+ */
+final class SourceHighlighter {
+
+ private final Locale locale;
+
+ private String lang;
+
+ /**
+ * Creates a new highlighter with default settings.
+ *
+ * @param locale
+ * locale for tooltip rendering
+ */
+ public SourceHighlighter(final Locale locale) {
+ this.locale = locale;
+ lang = "java";
+ }
+
+ /**
+ * Specifies the source language. This value might be used for syntax
+ * highlighting. Default is "java".
+ *
+ * @param lang
+ * source language identifier
+ */
+ public void setLanguage(final String lang) {
+ this.lang = lang;
+ }
+
+ /**
+ * Highlights the given source file.
+ *
+ * @param parent
+ * parent HTML element
+ * @param source
+ * highlighting information
+ * @param contents
+ * contents of the source file
+ * @throws IOException
+ * problems while reading the source file or writing the output
+ */
+ public void render(final HTMLElement parent, final ISourceNode source,
+ final Reader contents) throws IOException {
+ final HTMLElement pre = parent.pre(Styles.SOURCE + " lang-" + lang
+ + " linenums");
+ final BufferedReader lineBuffer = new BufferedReader(contents);
+ String line;
+ int nr = 0;
+ while ((line = lineBuffer.readLine()) != null) {
+ nr++;
+ renderCodeLine(pre, line, source.getLine(nr), nr);
+ }
+ }
+
+ private void renderCodeLine(final HTMLElement pre, final String linesrc,
+ final ILine line, final int lineNr) throws IOException {
+ highlight(pre, line, lineNr).text(linesrc);
+ pre.text("\n");
+ }
+
+ HTMLElement highlight(final HTMLElement pre, final ILine line,
+ final int lineNr) throws IOException {
+ final String style;
+ switch (line.getStatus()) {
+ case ICounter.NOT_COVERED:
+ style = Styles.NOT_COVERED;
+ break;
+ case ICounter.FULLY_COVERED:
+ style = Styles.FULLY_COVERED;
+ break;
+ case ICounter.PARTLY_COVERED:
+ style = Styles.PARTLY_COVERED;
+ break;
+ default:
+ return pre;
+ }
+
+ final String lineId = "L" + Integer.toString(lineNr);
+ final ICounter branches = line.getBranchCounter();
+ switch (branches.getStatus()) {
+ case ICounter.NOT_COVERED:
+ return span(pre, lineId, style, Styles.BRANCH_NOT_COVERED,
+ "All %2$d branches missed.", branches);
+ case ICounter.FULLY_COVERED:
+ return span(pre, lineId, style, Styles.BRANCH_FULLY_COVERED,
+ "All %2$d branches covered.", branches);
+ case ICounter.PARTLY_COVERED:
+ return span(pre, lineId, style, Styles.BRANCH_PARTLY_COVERED,
+ "%1$d of %2$d branches missed.", branches);
+ default:
+ return pre.span(style, lineId);
+ }
+ }
+
+ private HTMLElement span(final HTMLElement parent, final String id,
+ final String style1, final String style2, final String title,
+ final ICounter branches) throws IOException {
+ final HTMLElement span = parent.span(style1 + " " + style2, id);
+ final Integer missed = Integer.valueOf(branches.getMissedCount());
+ final Integer total = Integer.valueOf(branches.getTotalCount());
+ span.attr("title", String.format(locale, title, missed, total));
+ return span;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java
index 956f2ba4..81c25275 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java
@@ -1,78 +1,78 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.page;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.IHTMLReportContext;
-import org.jacoco.report.internal.html.resources.Resources;
-import org.jacoco.report.internal.html.table.ITableItem;
-
-/**
- * Report page that contains a table of items linked to other pages.
- *
- * @param <NodeType>
- * type of the node represented by this page
- */
-public abstract class TablePage<NodeType extends ICoverageNode> extends
- NodePage<NodeType> {
-
- private final List<ITableItem> items = new ArrayList<ITableItem>();
-
- /**
- * Creates a new node page.
- *
- * @param node
- * corresponding node
- * @param parent
- * optional hierarchical parent
- * @param folder
- * base folder to create this report in
- * @param context
- * settings context
- */
- protected TablePage(final NodeType node, final ReportPage parent,
- final ReportOutputFolder folder, final IHTMLReportContext context) {
- super(node, parent, folder, context);
- }
-
- /**
- * Adds the given item to the table. Method must be called before the page
- * is rendered.
- *
- * @param item
- */
- public void addItem(final ITableItem item) {
- items.add(item);
- }
-
- @Override
- protected void head(final HTMLElement head) throws IOException {
- super.head(head);
- head.script("text/javascript",
- context.getResources().getLink(folder, Resources.SORT_SCRIPT));
- }
-
- @Override
- protected void content(final HTMLElement body) throws IOException {
- context.getTable().render(body, items, getNode(),
- context.getResources(), folder);
- // free memory, otherwise we will keep the complete page tree:
- items.clear();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.page;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.IHTMLReportContext;
+import org.jacoco.report.internal.html.resources.Resources;
+import org.jacoco.report.internal.html.table.ITableItem;
+
+/**
+ * Report page that contains a table of items linked to other pages.
+ *
+ * @param <NodeType>
+ * type of the node represented by this page
+ */
+public abstract class TablePage<NodeType extends ICoverageNode> extends
+ NodePage<NodeType> {
+
+ private final List<ITableItem> items = new ArrayList<ITableItem>();
+
+ /**
+ * Creates a new node page.
+ *
+ * @param node
+ * corresponding node
+ * @param parent
+ * optional hierarchical parent
+ * @param folder
+ * base folder to create this report in
+ * @param context
+ * settings context
+ */
+ protected TablePage(final NodeType node, final ReportPage parent,
+ final ReportOutputFolder folder, final IHTMLReportContext context) {
+ super(node, parent, folder, context);
+ }
+
+ /**
+ * Adds the given item to the table. Method must be called before the page
+ * is rendered.
+ *
+ * @param item
+ */
+ public void addItem(final ITableItem item) {
+ items.add(item);
+ }
+
+ @Override
+ protected void head(final HTMLElement head) throws IOException {
+ super.head(head);
+ head.script("text/javascript",
+ context.getResources().getLink(folder, Resources.SORT_SCRIPT));
+ }
+
+ @Override
+ protected void content(final HTMLElement body) throws IOException {
+ context.getTable().render(body, items, getNode(),
+ context.getResources(), folder);
+ // free memory, otherwise we will keep the complete page tree:
+ items.clear();
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Resources.java b/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Resources.java
index f6264c77..b94ae6a1 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Resources.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Resources.java
@@ -1,136 +1,136 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.jacoco.core.analysis.ICoverageNode.ElementType;
-import org.jacoco.report.internal.ReportOutputFolder;
-
-/**
- * Static resource that are included with the coverage report and might be
- * referenced from created HTML pages.
- */
-public class Resources {
-
- /** The name of the style sheet */
- public static final String STYLESHEET = "report.css";
-
- /** The name of the prettify style sheet */
- public static final String PRETTIFY_STYLESHEET = "prettify.css";
-
- /** The name of the prettify script */
- public static final String PRETTIFY_SCRIPT = "prettify.js";
-
- /** The name of the sort script */
- public static final String SORT_SCRIPT = "sort.js";
-
- /** The name of the red part of the coverage bar */
- public static final String REDBAR = "redbar.gif";
-
- /** The name of the green part of the coverage bar */
- public static final String GREENBAR = "greenbar.gif";
-
- private final ReportOutputFolder folder;
-
- /**
- * Attaches resources to the report with the given root folder.
- *
- * @param root
- * root folder of the report
- */
- public Resources(final ReportOutputFolder root) {
- folder = root.subFolder(".resources");
- }
-
- /**
- * Returns a relative link to a static resource.
- *
- * @param base
- * base folder from where the link should be created
- * @param name
- * name of the static resource, see constants in this class
- * @return relative link
- */
- public String getLink(final ReportOutputFolder base, final String name) {
- return folder.getLink(base, name);
- }
-
- /**
- * Determines the style sheet class for the given element type.
- *
- * @param type
- * type of the element
- * @return style class name
- */
- public static String getElementStyle(final ElementType type) {
- switch (type) {
- case GROUP:
- return Styles.EL_GROUP;
- case BUNDLE:
- return Styles.EL_BUNDLE;
- case PACKAGE:
- return Styles.EL_PACKAGE;
- case SOURCEFILE:
- return Styles.EL_SOURCE;
- case CLASS:
- return Styles.EL_CLASS;
- case METHOD:
- return Styles.EL_METHOD;
- }
- throw new AssertionError("Unknown element type: " + type);
- }
-
- /**
- * Copies all static resources into the report.
- *
- * @throws IOException
- * if the resources can't be written to the report
- */
- public void copyResources() throws IOException {
- copyResource(STYLESHEET);
- copyResource("report.gif");
- copyResource("group.gif");
- copyResource("bundle.gif");
- copyResource("package.gif");
- copyResource("source.gif");
- copyResource("class.gif");
- copyResource("method.gif");
- copyResource("session.gif");
- copyResource("sort.gif");
- copyResource("up.gif");
- copyResource("down.gif");
- copyResource("branchfc.gif");
- copyResource("branchnc.gif");
- copyResource("branchpc.gif");
- copyResource(REDBAR);
- copyResource(GREENBAR);
- copyResource(PRETTIFY_STYLESHEET);
- copyResource(PRETTIFY_SCRIPT);
- copyResource(SORT_SCRIPT);
- }
-
- private void copyResource(final String name) throws IOException {
- final InputStream in = Resources.class.getResourceAsStream(name);
- final OutputStream out = folder.createFile(name);
- final byte[] buffer = new byte[256];
- int len;
- while ((len = in.read(buffer)) != -1) {
- out.write(buffer, 0, len);
- }
- in.close();
- out.close();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.jacoco.core.analysis.ICoverageNode.ElementType;
+import org.jacoco.report.internal.ReportOutputFolder;
+
+/**
+ * Static resource that are included with the coverage report and might be
+ * referenced from created HTML pages.
+ */
+public class Resources {
+
+ /** The name of the style sheet */
+ public static final String STYLESHEET = "report.css";
+
+ /** The name of the prettify style sheet */
+ public static final String PRETTIFY_STYLESHEET = "prettify.css";
+
+ /** The name of the prettify script */
+ public static final String PRETTIFY_SCRIPT = "prettify.js";
+
+ /** The name of the sort script */
+ public static final String SORT_SCRIPT = "sort.js";
+
+ /** The name of the red part of the coverage bar */
+ public static final String REDBAR = "redbar.gif";
+
+ /** The name of the green part of the coverage bar */
+ public static final String GREENBAR = "greenbar.gif";
+
+ private final ReportOutputFolder folder;
+
+ /**
+ * Attaches resources to the report with the given root folder.
+ *
+ * @param root
+ * root folder of the report
+ */
+ public Resources(final ReportOutputFolder root) {
+ folder = root.subFolder(".resources");
+ }
+
+ /**
+ * Returns a relative link to a static resource.
+ *
+ * @param base
+ * base folder from where the link should be created
+ * @param name
+ * name of the static resource, see constants in this class
+ * @return relative link
+ */
+ public String getLink(final ReportOutputFolder base, final String name) {
+ return folder.getLink(base, name);
+ }
+
+ /**
+ * Determines the style sheet class for the given element type.
+ *
+ * @param type
+ * type of the element
+ * @return style class name
+ */
+ public static String getElementStyle(final ElementType type) {
+ switch (type) {
+ case GROUP:
+ return Styles.EL_GROUP;
+ case BUNDLE:
+ return Styles.EL_BUNDLE;
+ case PACKAGE:
+ return Styles.EL_PACKAGE;
+ case SOURCEFILE:
+ return Styles.EL_SOURCE;
+ case CLASS:
+ return Styles.EL_CLASS;
+ case METHOD:
+ return Styles.EL_METHOD;
+ }
+ throw new AssertionError("Unknown element type: " + type);
+ }
+
+ /**
+ * Copies all static resources into the report.
+ *
+ * @throws IOException
+ * if the resources can't be written to the report
+ */
+ public void copyResources() throws IOException {
+ copyResource(STYLESHEET);
+ copyResource("report.gif");
+ copyResource("group.gif");
+ copyResource("bundle.gif");
+ copyResource("package.gif");
+ copyResource("source.gif");
+ copyResource("class.gif");
+ copyResource("method.gif");
+ copyResource("session.gif");
+ copyResource("sort.gif");
+ copyResource("up.gif");
+ copyResource("down.gif");
+ copyResource("branchfc.gif");
+ copyResource("branchnc.gif");
+ copyResource("branchpc.gif");
+ copyResource(REDBAR);
+ copyResource(GREENBAR);
+ copyResource(PRETTIFY_STYLESHEET);
+ copyResource(PRETTIFY_SCRIPT);
+ copyResource(SORT_SCRIPT);
+ }
+
+ private void copyResource(final String name) throws IOException {
+ final InputStream in = Resources.class.getResourceAsStream(name);
+ final OutputStream out = folder.createFile(name);
+ final byte[] buffer = new byte[256];
+ int len;
+ while ((len = in.read(buffer)) != -1) {
+ out.write(buffer, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Styles.java b/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Styles.java
index 7d3b9f9f..6dbf0ef8 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Styles.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/resources/Styles.java
@@ -1,120 +1,120 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.resources;
-
-/**
- * Constants for styles defined by the report style sheet.
- */
-public final class Styles {
-
- /** Breadcrumb bar */
- public static final String BREADCRUMB = "breadcrumb";
-
- /** Footer */
- public static final String FOOTER = "footer";
-
- /** Text block aligned to the right */
- public static final String RIGHT = "right";
-
- /** Report element */
- public static final String EL_REPORT = "el_report";
-
- /** Sessions element */
- public static final String EL_SESSION = "el_session";
-
- /** Group element */
- public static final String EL_GROUP = "el_group";
-
- /** Bundle element */
- public static final String EL_BUNDLE = "el_bundle";
-
- /** Package element */
- public static final String EL_PACKAGE = "el_package";
-
- /** Source file element */
- public static final String EL_SOURCE = "el_source";
-
- /** Class element */
- public static final String EL_CLASS = "el_class";
-
- /** Method element */
- public static final String EL_METHOD = "el_method";
-
- /** Coverage table */
- public static final String COVERAGETABLE = "coverage";
-
- /** Table cells for a graphical bar */
- public static final String BAR = "bar";
-
- /** Table cells for the first column of a counter */
- public static final String CTR1 = "ctr1";
-
- /** Table cells for the second column of a counter */
- public static final String CTR2 = "ctr2";
-
- /** Table header for sortable columns */
- public static final String SORTABLE = "sortable";
-
- /** Table header for column sorted upwards */
- public static final String UP = "up";
-
- /** Table header for column sorted downwards */
- public static final String DOWN = "down";
-
- /** Block of source code */
- public static final String SOURCE = "source";
-
- /** Line number before each source line */
- public static final String NR = "nr";
-
- /** Part of source code where instructions are not covered */
- public static final String NOT_COVERED = "nc";
-
- /** Part of source code where instructions are partly covered */
- public static final String PARTLY_COVERED = "pc";
-
- /** Part of source code where instructions are is fully covered */
- public static final String FULLY_COVERED = "fc";
-
- /** Part of source code where branches are not covered */
- public static final String BRANCH_NOT_COVERED = "bnc";
-
- /** Part of source code where branches are partly covered */
- public static final String BRANCH_PARTLY_COVERED = "bpc";
-
- /** Part of source code where branches are fully covered */
- public static final String BRANCH_FULLY_COVERED = "bfc";
-
- /**
- * Returns a combined style from the given styles.
- *
- * @param styles
- * list of separate styles, entries might be null
- * @return combined style or <code>null</code> if no style is given
- */
- public static String combine(final String... styles) {
- final StringBuilder sb = new StringBuilder();
- for (final String style : styles) {
- if (style != null) {
- if (sb.length() > 0) {
- sb.append(" ");
- }
- sb.append(style);
- }
- }
- return sb.length() == 0 ? null : sb.toString();
- }
-
- private Styles() {
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.resources;
+
+/**
+ * Constants for styles defined by the report style sheet.
+ */
+public final class Styles {
+
+ /** Breadcrumb bar */
+ public static final String BREADCRUMB = "breadcrumb";
+
+ /** Footer */
+ public static final String FOOTER = "footer";
+
+ /** Text block aligned to the right */
+ public static final String RIGHT = "right";
+
+ /** Report element */
+ public static final String EL_REPORT = "el_report";
+
+ /** Sessions element */
+ public static final String EL_SESSION = "el_session";
+
+ /** Group element */
+ public static final String EL_GROUP = "el_group";
+
+ /** Bundle element */
+ public static final String EL_BUNDLE = "el_bundle";
+
+ /** Package element */
+ public static final String EL_PACKAGE = "el_package";
+
+ /** Source file element */
+ public static final String EL_SOURCE = "el_source";
+
+ /** Class element */
+ public static final String EL_CLASS = "el_class";
+
+ /** Method element */
+ public static final String EL_METHOD = "el_method";
+
+ /** Coverage table */
+ public static final String COVERAGETABLE = "coverage";
+
+ /** Table cells for a graphical bar */
+ public static final String BAR = "bar";
+
+ /** Table cells for the first column of a counter */
+ public static final String CTR1 = "ctr1";
+
+ /** Table cells for the second column of a counter */
+ public static final String CTR2 = "ctr2";
+
+ /** Table header for sortable columns */
+ public static final String SORTABLE = "sortable";
+
+ /** Table header for column sorted upwards */
+ public static final String UP = "up";
+
+ /** Table header for column sorted downwards */
+ public static final String DOWN = "down";
+
+ /** Block of source code */
+ public static final String SOURCE = "source";
+
+ /** Line number before each source line */
+ public static final String NR = "nr";
+
+ /** Part of source code where instructions are not covered */
+ public static final String NOT_COVERED = "nc";
+
+ /** Part of source code where instructions are partly covered */
+ public static final String PARTLY_COVERED = "pc";
+
+ /** Part of source code where instructions are is fully covered */
+ public static final String FULLY_COVERED = "fc";
+
+ /** Part of source code where branches are not covered */
+ public static final String BRANCH_NOT_COVERED = "bnc";
+
+ /** Part of source code where branches are partly covered */
+ public static final String BRANCH_PARTLY_COVERED = "bpc";
+
+ /** Part of source code where branches are fully covered */
+ public static final String BRANCH_FULLY_COVERED = "bfc";
+
+ /**
+ * Returns a combined style from the given styles.
+ *
+ * @param styles
+ * list of separate styles, entries might be null
+ * @return combined style or <code>null</code> if no style is given
+ */
+ public static String combine(final String... styles) {
+ final StringBuilder sb = new StringBuilder();
+ for (final String style : styles) {
+ if (style != null) {
+ if (sb.length() > 0) {
+ sb.append(" ");
+ }
+ sb.append(style);
+ }
+ }
+ return sb.length() == 0 ? null : sb.toString();
+ }
+
+ private Styles() {
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/resources/report.css b/org.jacoco.report/src/org/jacoco/report/internal/html/resources/report.css
index 27e6ca7f..98d385f2 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/resources/report.css
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/resources/report.css
@@ -1,236 +1,236 @@
-body, td {
- font-family:sans-serif;
- font-size:10pt;
-}
-
-h1 {
- font-weight:bold;
- font-size:18pt;
-}
-
-.breadcrumb {
- border:#d6d3ce 1px solid;
- padding:2px 4px 2px 4px;
-}
-
-
-.el_report {
- padding-left:18px;
- background-image:url(report.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-.el_group {
- padding-left:18px;
- background-image:url(group.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-.el_bundle {
- padding-left:18px;
- background-image:url(bundle.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-.el_package {
- padding-left:18px;
- background-image:url(package.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-.el_class {
- padding-left:18px;
- background-image:url(class.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-.el_source {
- padding-left:18px;
- background-image:url(source.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-.el_method {
- padding-left:18px;
- background-image:url(method.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-.el_session {
- padding-left:18px;
- background-image:url(session.gif);
- background-position:left center;
- background-repeat:no-repeat;
-}
-
-pre.source {
- border:#d6d3ce 1px solid;
- font-family:monospace;
-}
-
-pre.source ol {
- margin-bottom: 0px;
- margin-top: 0px;
-}
-
-pre.source li {
- border-left: 1px solid #D6D3CE;
- color: #A0A0A0;
- padding-left: 0px;
-}
-
-pre.source span.fc {
- background-color:#ccffcc;
-}
-
-pre.source span.nc {
- background-color:#ffcccc;
-}
-
-pre.source span.pc {
- background-color:#ffffcc;
-}
-
-pre.source span.bfc {
- background-image: url(branchfc.gif);
- background-repeat: no-repeat;
- background-position: 2px center;
-}
-
-pre.source span.bfc:hover {
- background-color:#80ff80;
-}
-
-pre.source span.bnc {
- background-image: url(branchnc.gif);
- background-repeat: no-repeat;
- background-position: 2px center;
-}
-
-pre.source span.bnc:hover {
- background-color:#ff8080;
-}
-
-pre.source span.bpc {
- background-image: url(branchpc.gif);
- background-repeat: no-repeat;
- background-position: 2px center;
-}
-
-pre.source span.bpc:hover {
- background-color:#ffff80;
-}
-
-table.coverage {
- empty-cells:show;
- border-collapse:collapse;
-}
-
-table.coverage thead {
- background-color:#e0e0e0;
-}
-
-table.coverage thead td {
- white-space:nowrap;
- padding:2px 14px 0px 6px;
- border-bottom:#b0b0b0 1px solid;
-}
-
-table.coverage thead td.bar {
- border-left:#cccccc 1px solid;
-}
-
-table.coverage thead td.ctr1 {
- text-align:right;
- border-left:#cccccc 1px solid;
-}
-
-table.coverage thead td.ctr2 {
- text-align:right;
- padding-left:2px;
-}
-
-table.coverage thead td.sortable {
- cursor:pointer;
- background-image:url(sort.gif);
- background-position:right center;
- background-repeat:no-repeat;
-}
-
-table.coverage thead td.up {
- background-image:url(up.gif);
-}
-
-table.coverage thead td.down {
- background-image:url(down.gif);
-}
-
-table.coverage tbody td {
- white-space:nowrap;
- padding:2px 6px 2px 6px;
- border-bottom:#d6d3ce 1px solid;
-}
-
-table.coverage tbody tr:hover {
- background: #f0f0d0 !important;
-}
-
-table.coverage tbody td.bar {
- border-left:#e8e8e8 1px solid;
-}
-
-table.coverage tbody td.ctr1 {
- text-align:right;
- padding-right:14px;
- border-left:#e8e8e8 1px solid;
-}
-
-table.coverage tbody td.ctr2 {
- text-align:right;
- padding-right:14px;
- padding-left:2px;
-}
-
-table.coverage tfoot td {
- white-space:nowrap;
- padding:2px 6px 2px 6px;
-}
-
-table.coverage tfoot td.bar {
- border-left:#e8e8e8 1px solid;
-}
-
-table.coverage tfoot td.ctr1 {
- text-align:right;
- padding-right:14px;
- border-left:#e8e8e8 1px solid;
-}
-
-table.coverage tfoot td.ctr2 {
- text-align:right;
- padding-right:14px;
- padding-left:2px;
-}
-
-.footer {
- margin-top:20px;
- border-top:#d6d3ce 1px solid;
- padding-top:2px;
- font-size:8pt;
- color:#a0a0a0;
-}
-
-.footer a {
- color:#a0a0a0;
-}
-
-.right {
- float:right;
-}
+body, td {
+ font-family:sans-serif;
+ font-size:10pt;
+}
+
+h1 {
+ font-weight:bold;
+ font-size:18pt;
+}
+
+.breadcrumb {
+ border:#d6d3ce 1px solid;
+ padding:2px 4px 2px 4px;
+}
+
+
+.el_report {
+ padding-left:18px;
+ background-image:url(report.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+.el_group {
+ padding-left:18px;
+ background-image:url(group.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+.el_bundle {
+ padding-left:18px;
+ background-image:url(bundle.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+.el_package {
+ padding-left:18px;
+ background-image:url(package.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+.el_class {
+ padding-left:18px;
+ background-image:url(class.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+.el_source {
+ padding-left:18px;
+ background-image:url(source.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+.el_method {
+ padding-left:18px;
+ background-image:url(method.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+.el_session {
+ padding-left:18px;
+ background-image:url(session.gif);
+ background-position:left center;
+ background-repeat:no-repeat;
+}
+
+pre.source {
+ border:#d6d3ce 1px solid;
+ font-family:monospace;
+}
+
+pre.source ol {
+ margin-bottom: 0px;
+ margin-top: 0px;
+}
+
+pre.source li {
+ border-left: 1px solid #D6D3CE;
+ color: #A0A0A0;
+ padding-left: 0px;
+}
+
+pre.source span.fc {
+ background-color:#ccffcc;
+}
+
+pre.source span.nc {
+ background-color:#ffcccc;
+}
+
+pre.source span.pc {
+ background-color:#ffffcc;
+}
+
+pre.source span.bfc {
+ background-image: url(branchfc.gif);
+ background-repeat: no-repeat;
+ background-position: 2px center;
+}
+
+pre.source span.bfc:hover {
+ background-color:#80ff80;
+}
+
+pre.source span.bnc {
+ background-image: url(branchnc.gif);
+ background-repeat: no-repeat;
+ background-position: 2px center;
+}
+
+pre.source span.bnc:hover {
+ background-color:#ff8080;
+}
+
+pre.source span.bpc {
+ background-image: url(branchpc.gif);
+ background-repeat: no-repeat;
+ background-position: 2px center;
+}
+
+pre.source span.bpc:hover {
+ background-color:#ffff80;
+}
+
+table.coverage {
+ empty-cells:show;
+ border-collapse:collapse;
+}
+
+table.coverage thead {
+ background-color:#e0e0e0;
+}
+
+table.coverage thead td {
+ white-space:nowrap;
+ padding:2px 14px 0px 6px;
+ border-bottom:#b0b0b0 1px solid;
+}
+
+table.coverage thead td.bar {
+ border-left:#cccccc 1px solid;
+}
+
+table.coverage thead td.ctr1 {
+ text-align:right;
+ border-left:#cccccc 1px solid;
+}
+
+table.coverage thead td.ctr2 {
+ text-align:right;
+ padding-left:2px;
+}
+
+table.coverage thead td.sortable {
+ cursor:pointer;
+ background-image:url(sort.gif);
+ background-position:right center;
+ background-repeat:no-repeat;
+}
+
+table.coverage thead td.up {
+ background-image:url(up.gif);
+}
+
+table.coverage thead td.down {
+ background-image:url(down.gif);
+}
+
+table.coverage tbody td {
+ white-space:nowrap;
+ padding:2px 6px 2px 6px;
+ border-bottom:#d6d3ce 1px solid;
+}
+
+table.coverage tbody tr:hover {
+ background: #f0f0d0 !important;
+}
+
+table.coverage tbody td.bar {
+ border-left:#e8e8e8 1px solid;
+}
+
+table.coverage tbody td.ctr1 {
+ text-align:right;
+ padding-right:14px;
+ border-left:#e8e8e8 1px solid;
+}
+
+table.coverage tbody td.ctr2 {
+ text-align:right;
+ padding-right:14px;
+ padding-left:2px;
+}
+
+table.coverage tfoot td {
+ white-space:nowrap;
+ padding:2px 6px 2px 6px;
+}
+
+table.coverage tfoot td.bar {
+ border-left:#e8e8e8 1px solid;
+}
+
+table.coverage tfoot td.ctr1 {
+ text-align:right;
+ padding-right:14px;
+ border-left:#e8e8e8 1px solid;
+}
+
+table.coverage tfoot td.ctr2 {
+ text-align:right;
+ padding-right:14px;
+ padding-left:2px;
+}
+
+.footer {
+ margin-top:20px;
+ border-top:#d6d3ce 1px solid;
+ padding-top:2px;
+ font-size:8pt;
+ color:#a0a0a0;
+}
+
+.footer a {
+ color:#a0a0a0;
+}
+
+.right {
+ float:right;
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/BarColumn.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/BarColumn.java
index 5acdffba..0e060ba8 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/BarColumn.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/BarColumn.java
@@ -1,109 +1,109 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-
-import org.jacoco.core.analysis.CounterComparator;
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.resources.Resources;
-
-/**
- * Column with a graphical bar that represents the total amount of items in with
- * length, and the coverage ratio with a red/green sections. The implementation
- * is stateful, instances must not be used in parallel.
- */
-public class BarColumn implements IColumnRenderer {
-
- private static final int WIDTH = 120;
-
- private final CounterEntity entity;
-
- private final NumberFormat integerFormat;
-
- private int max;
-
- private final Comparator<ITableItem> comparator;
-
- /**
- * Creates a new column that is based on the {@link ICounter} for the given
- * entity.
- *
- * @param entity
- * counter entity for visualization
- * @param locale
- * locale for rendering numbers
- */
- public BarColumn(final CounterEntity entity, final Locale locale) {
- this.entity = entity;
- this.integerFormat = DecimalFormat.getIntegerInstance(locale);
- this.comparator = new TableItemComparator(CounterComparator.MISSEDITEMS
- .reverse().on(entity)
- .second(CounterComparator.TOTALITEMS.reverse().on(entity)));
- }
-
- public boolean init(final List<? extends ITableItem> items,
- final ICoverageNode total) {
- this.max = 0;
- for (final ITableItem item : items) {
- final int count = item.getNode().getCounter(entity).getTotalCount();
- if (count > this.max) {
- this.max = count;
- }
- }
- return true;
- }
-
- public void footer(final HTMLElement td, final ICoverageNode total,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- final ICounter counter = total.getCounter(entity);
- td.text(integerFormat.format(counter.getMissedCount())).text(" of ")
- .text(integerFormat.format(counter.getTotalCount()));
- }
-
- public void item(final HTMLElement td, final ITableItem item,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- if (max > 0) {
- final ICounter counter = item.getNode().getCounter(entity);
- final int missed = counter.getMissedCount();
- bar(td, missed, Resources.REDBAR, resources, base);
- final int covered = counter.getCoveredCount();
- bar(td, covered, Resources.GREENBAR, resources, base);
- }
- }
-
- private void bar(final HTMLElement td, final int count, final String image,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- final int width = count * WIDTH / max;
- if (width > 0) {
- td.img(resources.getLink(base, image), width, 10,
- integerFormat.format(count));
- }
- }
-
- public Comparator<ITableItem> getComparator() {
- return comparator;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+
+import org.jacoco.core.analysis.CounterComparator;
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.resources.Resources;
+
+/**
+ * Column with a graphical bar that represents the total amount of items in with
+ * length, and the coverage ratio with a red/green sections. The implementation
+ * is stateful, instances must not be used in parallel.
+ */
+public class BarColumn implements IColumnRenderer {
+
+ private static final int WIDTH = 120;
+
+ private final CounterEntity entity;
+
+ private final NumberFormat integerFormat;
+
+ private int max;
+
+ private final Comparator<ITableItem> comparator;
+
+ /**
+ * Creates a new column that is based on the {@link ICounter} for the given
+ * entity.
+ *
+ * @param entity
+ * counter entity for visualization
+ * @param locale
+ * locale for rendering numbers
+ */
+ public BarColumn(final CounterEntity entity, final Locale locale) {
+ this.entity = entity;
+ this.integerFormat = DecimalFormat.getIntegerInstance(locale);
+ this.comparator = new TableItemComparator(CounterComparator.MISSEDITEMS
+ .reverse().on(entity)
+ .second(CounterComparator.TOTALITEMS.reverse().on(entity)));
+ }
+
+ public boolean init(final List<? extends ITableItem> items,
+ final ICoverageNode total) {
+ this.max = 0;
+ for (final ITableItem item : items) {
+ final int count = item.getNode().getCounter(entity).getTotalCount();
+ if (count > this.max) {
+ this.max = count;
+ }
+ }
+ return true;
+ }
+
+ public void footer(final HTMLElement td, final ICoverageNode total,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ final ICounter counter = total.getCounter(entity);
+ td.text(integerFormat.format(counter.getMissedCount())).text(" of ")
+ .text(integerFormat.format(counter.getTotalCount()));
+ }
+
+ public void item(final HTMLElement td, final ITableItem item,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ if (max > 0) {
+ final ICounter counter = item.getNode().getCounter(entity);
+ final int missed = counter.getMissedCount();
+ bar(td, missed, Resources.REDBAR, resources, base);
+ final int covered = counter.getCoveredCount();
+ bar(td, covered, Resources.GREENBAR, resources, base);
+ }
+ }
+
+ private void bar(final HTMLElement td, final int count, final String image,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ final int width = count * WIDTH / max;
+ if (width > 0) {
+ td.img(resources.getLink(base, image), width, 10,
+ integerFormat.format(count));
+ }
+ }
+
+ public Comparator<ITableItem> getComparator() {
+ return comparator;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/CounterColumn.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/CounterColumn.java
index b81d5191..5ae7f6da 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/CounterColumn.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/CounterColumn.java
@@ -1,161 +1,161 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-
-import org.jacoco.core.analysis.CounterComparator;
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.resources.Resources;
-
-/**
- * Column that prints the counter values of entities for each item and a summary
- * in the footer. If the total number of items is zero, no column is emitted at
- * all. The implementation is stateful, instances must not be used in parallel.
- */
-public abstract class CounterColumn implements IColumnRenderer {
-
- /**
- * Creates a new column that shows the total count for the given entity.
- *
- * @param entity
- * counter entity for this column
- * @param locale
- * locale for rendering numbers
- * @return column instance
- */
- public static CounterColumn newTotal(final CounterEntity entity,
- final Locale locale) {
- return new CounterColumn(entity, locale, CounterComparator.TOTALITEMS
- .reverse().on(entity)) {
- @Override
- protected int getValue(final ICounter counter) {
- return counter.getTotalCount();
- }
- };
- }
-
- /**
- * Creates a new column that shows the missed count for the given entity.
- *
- * @param entity
- * counter entity for this column
- * @param locale
- * locale for rendering numbers
- * @return column instance
- */
- public static CounterColumn newMissed(final CounterEntity entity,
- final Locale locale) {
- return new CounterColumn(entity, locale, CounterComparator.MISSEDITEMS
- .reverse().on(entity)) {
- @Override
- protected int getValue(final ICounter counter) {
- return counter.getMissedCount();
- }
- };
- }
-
- /**
- * Creates a new column that shows the covered count for the given entity.
- *
- * @param entity
- * counter entity for this column
- * @param locale
- * locale for rendering numbers
- * @return column instance
- */
- public static CounterColumn newCovered(final CounterEntity entity,
- final Locale locale) {
- return new CounterColumn(entity, locale, CounterComparator.COVEREDITEMS
- .reverse().on(entity)) {
- @Override
- protected int getValue(final ICounter counter) {
- return counter.getCoveredCount();
- }
- };
- }
-
- private final CounterEntity entity;
-
- private final NumberFormat integerFormat;
-
- private final Comparator<ITableItem> comparator;
-
- /**
- * Creates a new column that is based on the {@link ICounter} for the given
- * entity.
- *
- * @param entity
- * counter entity for this column
- * @param locale
- * locale for rendering numbers
- * @param comparator
- * comparator for the nodes of this column
- */
- protected CounterColumn(final CounterEntity entity, final Locale locale,
- final Comparator<ICoverageNode> comparator) {
- this.entity = entity;
- this.integerFormat = DecimalFormat.getIntegerInstance(locale);
- this.comparator = new TableItemComparator(comparator);
- }
-
- public boolean init(final List<? extends ITableItem> items,
- final ICoverageNode total) {
- for (final ITableItem i : items) {
- if (i.getNode().getCounter(entity).getTotalCount() > 0) {
- return true;
- }
- }
- return false;
- }
-
- public void footer(final HTMLElement td, final ICoverageNode total,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- cell(td, total);
- }
-
- public void item(final HTMLElement td, final ITableItem item,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- cell(td, item.getNode());
- }
-
- private void cell(final HTMLElement td, final ICoverageNode node)
- throws IOException {
- final int value = getValue(node.getCounter(entity));
- td.text(integerFormat.format(value));
- }
-
- public Comparator<ITableItem> getComparator() {
- return comparator;
- }
-
- /**
- * Retrieves the respective value from the counter.
- *
- * @param counter
- * counter object
- * @return value of interest
- */
- protected abstract int getValue(ICounter counter);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+
+import org.jacoco.core.analysis.CounterComparator;
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.resources.Resources;
+
+/**
+ * Column that prints the counter values of entities for each item and a summary
+ * in the footer. If the total number of items is zero, no column is emitted at
+ * all. The implementation is stateful, instances must not be used in parallel.
+ */
+public abstract class CounterColumn implements IColumnRenderer {
+
+ /**
+ * Creates a new column that shows the total count for the given entity.
+ *
+ * @param entity
+ * counter entity for this column
+ * @param locale
+ * locale for rendering numbers
+ * @return column instance
+ */
+ public static CounterColumn newTotal(final CounterEntity entity,
+ final Locale locale) {
+ return new CounterColumn(entity, locale, CounterComparator.TOTALITEMS
+ .reverse().on(entity)) {
+ @Override
+ protected int getValue(final ICounter counter) {
+ return counter.getTotalCount();
+ }
+ };
+ }
+
+ /**
+ * Creates a new column that shows the missed count for the given entity.
+ *
+ * @param entity
+ * counter entity for this column
+ * @param locale
+ * locale for rendering numbers
+ * @return column instance
+ */
+ public static CounterColumn newMissed(final CounterEntity entity,
+ final Locale locale) {
+ return new CounterColumn(entity, locale, CounterComparator.MISSEDITEMS
+ .reverse().on(entity)) {
+ @Override
+ protected int getValue(final ICounter counter) {
+ return counter.getMissedCount();
+ }
+ };
+ }
+
+ /**
+ * Creates a new column that shows the covered count for the given entity.
+ *
+ * @param entity
+ * counter entity for this column
+ * @param locale
+ * locale for rendering numbers
+ * @return column instance
+ */
+ public static CounterColumn newCovered(final CounterEntity entity,
+ final Locale locale) {
+ return new CounterColumn(entity, locale, CounterComparator.COVEREDITEMS
+ .reverse().on(entity)) {
+ @Override
+ protected int getValue(final ICounter counter) {
+ return counter.getCoveredCount();
+ }
+ };
+ }
+
+ private final CounterEntity entity;
+
+ private final NumberFormat integerFormat;
+
+ private final Comparator<ITableItem> comparator;
+
+ /**
+ * Creates a new column that is based on the {@link ICounter} for the given
+ * entity.
+ *
+ * @param entity
+ * counter entity for this column
+ * @param locale
+ * locale for rendering numbers
+ * @param comparator
+ * comparator for the nodes of this column
+ */
+ protected CounterColumn(final CounterEntity entity, final Locale locale,
+ final Comparator<ICoverageNode> comparator) {
+ this.entity = entity;
+ this.integerFormat = DecimalFormat.getIntegerInstance(locale);
+ this.comparator = new TableItemComparator(comparator);
+ }
+
+ public boolean init(final List<? extends ITableItem> items,
+ final ICoverageNode total) {
+ for (final ITableItem i : items) {
+ if (i.getNode().getCounter(entity).getTotalCount() > 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void footer(final HTMLElement td, final ICoverageNode total,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ cell(td, total);
+ }
+
+ public void item(final HTMLElement td, final ITableItem item,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ cell(td, item.getNode());
+ }
+
+ private void cell(final HTMLElement td, final ICoverageNode node)
+ throws IOException {
+ final int value = getValue(node.getCounter(entity));
+ td.text(integerFormat.format(value));
+ }
+
+ public Comparator<ITableItem> getComparator() {
+ return comparator;
+ }
+
+ /**
+ * Retrieves the respective value from the counter.
+ *
+ * @param counter
+ * counter object
+ * @return value of interest
+ */
+ protected abstract int getValue(ICounter counter);
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/IColumnRenderer.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/IColumnRenderer.java
index 0085bec4..741303f5 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/IColumnRenderer.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/IColumnRenderer.java
@@ -1,82 +1,82 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.List;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.resources.Resources;
-
-/**
- * Renderer for a single column of a coverage table. The methods are always
- * called in the sequence <code>init header footer item*</code>. Implementations
- * might be stateful.
- */
-public interface IColumnRenderer {
-
- /**
- * Initializes the column before any output method is called.
- *
- * @param items
- * all items that will be displayed in the table
- * @param total
- * the summary of all coverage data items in the table
- * @return <code>true</code> if the column should be visible
- */
- public boolean init(List<? extends ITableItem> items, ICoverageNode total);
-
- /**
- * Renders the footer for this column.
- *
- * @param td
- * the parent table cell
- * @param total
- * the summary of all coverage data items in the table
- * @param resources
- * static resources that might be referenced
- * @param base
- * base folder of the table
- * @throws IOException
- * in case of IO problems with the element output
- */
- public void footer(HTMLElement td, ICoverageNode total,
- Resources resources, ReportOutputFolder base) throws IOException;
-
- /**
- * Renders a single item in this column.
- *
- * @param td
- * the parent table cell
- * @param item
- * the item to display
- * @param resources
- * static resources that might be referenced
- * @param base
- * base folder of the table
- * @throws IOException
- * in case of IO problems with the element output
- */
- public void item(HTMLElement td, ITableItem item, Resources resources,
- ReportOutputFolder base) throws IOException;
-
- /**
- * Returns the comparator to sort this table column.
- *
- * @return comparator for this column
- */
- public Comparator<ITableItem> getComparator();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.List;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.resources.Resources;
+
+/**
+ * Renderer for a single column of a coverage table. The methods are always
+ * called in the sequence <code>init header footer item*</code>. Implementations
+ * might be stateful.
+ */
+public interface IColumnRenderer {
+
+ /**
+ * Initializes the column before any output method is called.
+ *
+ * @param items
+ * all items that will be displayed in the table
+ * @param total
+ * the summary of all coverage data items in the table
+ * @return <code>true</code> if the column should be visible
+ */
+ public boolean init(List<? extends ITableItem> items, ICoverageNode total);
+
+ /**
+ * Renders the footer for this column.
+ *
+ * @param td
+ * the parent table cell
+ * @param total
+ * the summary of all coverage data items in the table
+ * @param resources
+ * static resources that might be referenced
+ * @param base
+ * base folder of the table
+ * @throws IOException
+ * in case of IO problems with the element output
+ */
+ public void footer(HTMLElement td, ICoverageNode total,
+ Resources resources, ReportOutputFolder base) throws IOException;
+
+ /**
+ * Renders a single item in this column.
+ *
+ * @param td
+ * the parent table cell
+ * @param item
+ * the item to display
+ * @param resources
+ * static resources that might be referenced
+ * @param base
+ * base folder of the table
+ * @throws IOException
+ * in case of IO problems with the element output
+ */
+ public void item(HTMLElement td, ITableItem item, Resources resources,
+ ReportOutputFolder base) throws IOException;
+
+ /**
+ * Returns the comparator to sort this table column.
+ *
+ * @return comparator for this column
+ */
+ public Comparator<ITableItem> getComparator();
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/ITableItem.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/ITableItem.java
index d6ab6859..5d019c33 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/ITableItem.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/ITableItem.java
@@ -1,29 +1,29 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.internal.html.ILinkable;
-
-/**
- * Interface for a item (row) in a coverage data table.
- */
-public interface ITableItem extends ILinkable {
-
- /**
- * Returns the corresponding node data.
- *
- * @return node data
- */
- public ICoverageNode getNode();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.internal.html.ILinkable;
+
+/**
+ * Interface for a item (row) in a coverage data table.
+ */
+public interface ITableItem extends ILinkable {
+
+ /**
+ * Returns the corresponding node data.
+ *
+ * @return node data
+ */
+ public ICoverageNode getNode();
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/LabelColumn.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/LabelColumn.java
index 13a884d1..f61a63e9 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/LabelColumn.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/LabelColumn.java
@@ -1,56 +1,56 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.List;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.resources.Resources;
-
-/**
- * Column for the item label. The implementation is stateless, instances might
- * be used in parallel.
- */
-public class LabelColumn implements IColumnRenderer {
-
- private static final Comparator<ITableItem> COMPARATOR = new Comparator<ITableItem>() {
- public int compare(final ITableItem i1, final ITableItem i2) {
- return i1.getLinkLabel().compareToIgnoreCase(i2.getLinkLabel());
- }
- };
-
- public boolean init(final List<? extends ITableItem> items,
- final ICoverageNode total) {
- return true;
- }
-
- public void footer(final HTMLElement td, final ICoverageNode total,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- td.text("Total");
- }
-
- public void item(final HTMLElement td, final ITableItem item,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- td.a(item, base);
- }
-
- public Comparator<ITableItem> getComparator() {
- return COMPARATOR;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.List;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.resources.Resources;
+
+/**
+ * Column for the item label. The implementation is stateless, instances might
+ * be used in parallel.
+ */
+public class LabelColumn implements IColumnRenderer {
+
+ private static final Comparator<ITableItem> COMPARATOR = new Comparator<ITableItem>() {
+ public int compare(final ITableItem i1, final ITableItem i2) {
+ return i1.getLinkLabel().compareToIgnoreCase(i2.getLinkLabel());
+ }
+ };
+
+ public boolean init(final List<? extends ITableItem> items,
+ final ICoverageNode total) {
+ return true;
+ }
+
+ public void footer(final HTMLElement td, final ICoverageNode total,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ td.text("Total");
+ }
+
+ public void item(final HTMLElement td, final ITableItem item,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ td.a(item, base);
+ }
+
+ public Comparator<ITableItem> getComparator() {
+ return COMPARATOR;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/PercentageColumn.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/PercentageColumn.java
index 5a105c99..72645895 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/PercentageColumn.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/PercentageColumn.java
@@ -1,90 +1,90 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-
-import org.jacoco.core.analysis.CounterComparator;
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.resources.Resources;
-
-/**
- * Column that prints the coverage percentage for each item and the total
- * percentage in the footer. The implementation is stateless, instances might be
- * used in parallel.
- */
-public class PercentageColumn implements IColumnRenderer {
-
- private final CounterEntity entity;
-
- private final NumberFormat percentageFormat;
-
- private final Comparator<ITableItem> comparator;
-
- /**
- * Creates a new column that is based on the {@link ICounter} for the given
- * entity.
- *
- * @param entity
- * counter entity for this column
- * @param locale
- * locale for rendering numbers
- */
- public PercentageColumn(final CounterEntity entity, final Locale locale) {
- this.entity = entity;
- this.percentageFormat = DecimalFormat.getPercentInstance(locale);
- comparator = new TableItemComparator(
- CounterComparator.MISSEDRATIO.on(entity));
- }
-
- public boolean init(final List<? extends ITableItem> items,
- final ICoverageNode total) {
- return true;
- }
-
- public void footer(final HTMLElement td, final ICoverageNode total,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- cell(td, total);
- }
-
- public void item(final HTMLElement td, final ITableItem item,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- cell(td, item.getNode());
- }
-
- private void cell(final HTMLElement td, final ICoverageNode node)
- throws IOException {
- final ICounter counter = node.getCounter(entity);
- final int total = counter.getTotalCount();
- if (total == 0) {
- td.text("n/a");
- } else {
- td.text(percentageFormat.format(counter.getCoveredRatio()));
- }
- }
-
- public Comparator<ITableItem> getComparator() {
- return comparator;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+
+import org.jacoco.core.analysis.CounterComparator;
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.resources.Resources;
+
+/**
+ * Column that prints the coverage percentage for each item and the total
+ * percentage in the footer. The implementation is stateless, instances might be
+ * used in parallel.
+ */
+public class PercentageColumn implements IColumnRenderer {
+
+ private final CounterEntity entity;
+
+ private final NumberFormat percentageFormat;
+
+ private final Comparator<ITableItem> comparator;
+
+ /**
+ * Creates a new column that is based on the {@link ICounter} for the given
+ * entity.
+ *
+ * @param entity
+ * counter entity for this column
+ * @param locale
+ * locale for rendering numbers
+ */
+ public PercentageColumn(final CounterEntity entity, final Locale locale) {
+ this.entity = entity;
+ this.percentageFormat = DecimalFormat.getPercentInstance(locale);
+ comparator = new TableItemComparator(
+ CounterComparator.MISSEDRATIO.on(entity));
+ }
+
+ public boolean init(final List<? extends ITableItem> items,
+ final ICoverageNode total) {
+ return true;
+ }
+
+ public void footer(final HTMLElement td, final ICoverageNode total,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ cell(td, total);
+ }
+
+ public void item(final HTMLElement td, final ITableItem item,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ cell(td, item.getNode());
+ }
+
+ private void cell(final HTMLElement td, final ICoverageNode node)
+ throws IOException {
+ final ICounter counter = node.getCounter(entity);
+ final int total = counter.getTotalCount();
+ if (total == 0) {
+ td.text("n/a");
+ } else {
+ td.text(percentageFormat.format(counter.getCoveredRatio()));
+ }
+ }
+
+ public Comparator<ITableItem> getComparator() {
+ return comparator;
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/Table.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/Table.java
index 896445da..1e3cb35a 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/Table.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/Table.java
@@ -1,195 +1,195 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.report.internal.ReportOutputFolder;
-import org.jacoco.report.internal.html.HTMLElement;
-import org.jacoco.report.internal.html.resources.Resources;
-import org.jacoco.report.internal.html.resources.Styles;
-
-/**
- * Renderer for a table of {@link ITableItem}s.
- */
-public class Table {
-
- private final List<Column> columns;
-
- private Comparator<ITableItem> defaultComparator;
-
- /**
- * Create a new table without any columns yet.
- */
- public Table() {
- this.columns = new ArrayList<Table.Column>();
- }
-
- /**
- * Adds a new column with the given properties to the table.
- *
- * @param header
- * column header caption
- * @param style
- * optional CSS style class name for the td-Elements of this
- * column
- * @param renderer
- * callback for column rendering
- * @param defaultSorting
- * If <code>true</code>, this column is the default sorting
- * column. Only one column can be selected for default sorting.
- *
- */
- public void add(final String header, final String style,
- final IColumnRenderer renderer, final boolean defaultSorting) {
- columns.add(new Column(columns.size(), header, style, renderer,
- defaultSorting));
- if (defaultSorting) {
- if (defaultComparator != null) {
- throw new IllegalStateException(
- "Default sorting only allowed for one column.");
- }
- this.defaultComparator = renderer.getComparator();
- }
- }
-
- /**
- * Renders a table for the given icon
- *
- * @param parent
- * parent element in which the table is created
- * @param items
- * items that will make the table rows
- * @param total
- * the summary of all coverage data items in the table static
- * resources that might be referenced
- * @param resources
- * static resources that might be referenced
- * @param base
- * base folder of the table
- * @throws IOException
- * in case of IO problems with the element output
- */
- public void render(final HTMLElement parent,
- final List<? extends ITableItem> items, final ICoverageNode total,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- final List<? extends ITableItem> sortedItems = sort(items);
- final HTMLElement table = parent.table(Styles.COVERAGETABLE);
- table.attr("id", "coveragetable");
- header(table, sortedItems, total);
- footer(table, total, resources, base);
- body(table, sortedItems, resources, base);
- }
-
- private void header(final HTMLElement table,
- final List<? extends ITableItem> items, final ICoverageNode total)
- throws IOException {
- final HTMLElement tr = table.thead().tr();
- for (final Column c : columns) {
- c.init(tr, items, total);
- }
- }
-
- private void footer(final HTMLElement table, final ICoverageNode total,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- final HTMLElement tr = table.tfoot().tr();
- for (final Column c : columns) {
- c.footer(tr, total, resources, base);
- }
- }
-
- private void body(final HTMLElement table,
- final List<? extends ITableItem> items, final Resources resources,
- final ReportOutputFolder base) throws IOException {
- final HTMLElement tbody = table.tbody();
- int idx = 0;
- for (final ITableItem item : items) {
- final HTMLElement tr = tbody.tr();
- for (final Column c : columns) {
- c.body(tr, idx, item, resources, base);
- }
- idx++;
- }
- }
-
- private List<? extends ITableItem> sort(
- final List<? extends ITableItem> items) {
- if (defaultComparator != null) {
- final ArrayList<ITableItem> result = new ArrayList<ITableItem>(
- items);
- Collections.sort(result, defaultComparator);
- return result;
- }
- return items;
- }
-
- private static class Column {
-
- private final char idprefix;
- private final String header;
- private final IColumnRenderer renderer;
- private final SortIndex<ITableItem> index;
- private final String style, headerStyle;
-
- private boolean visible;
-
- Column(final int idx, final String header, final String style,
- final IColumnRenderer renderer, final boolean defaultSorting) {
- this.idprefix = (char) ('a' + idx);
- this.header = header;
- this.renderer = renderer;
- index = new SortIndex<ITableItem>(renderer.getComparator());
- this.style = style;
- this.headerStyle = Styles.combine(defaultSorting ? Styles.DOWN
- : null, Styles.SORTABLE, style);
- }
-
- void init(final HTMLElement tr, final List<? extends ITableItem> items,
- final ICoverageNode total) throws IOException {
- visible = renderer.init(items, total);
- if (visible) {
- index.init(items);
- final HTMLElement td = tr.td(headerStyle);
- td.attr("id", String.valueOf(idprefix));
- td.attr("onclick", "toggleSort(this)");
- td.text(header);
- }
- }
-
- void footer(final HTMLElement tr, final ICoverageNode total,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- if (visible) {
- renderer.footer(tr.td(style), total, resources, base);
- }
- }
-
- void body(final HTMLElement tr, final int idx, final ITableItem item,
- final Resources resources, final ReportOutputFolder base)
- throws IOException {
- if (visible) {
- final HTMLElement td = tr.td(style);
- td.attr("id", idprefix + String.valueOf(index.getPosition(idx)));
- renderer.item(td, item, resources, base);
- }
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.report.internal.ReportOutputFolder;
+import org.jacoco.report.internal.html.HTMLElement;
+import org.jacoco.report.internal.html.resources.Resources;
+import org.jacoco.report.internal.html.resources.Styles;
+
+/**
+ * Renderer for a table of {@link ITableItem}s.
+ */
+public class Table {
+
+ private final List<Column> columns;
+
+ private Comparator<ITableItem> defaultComparator;
+
+ /**
+ * Create a new table without any columns yet.
+ */
+ public Table() {
+ this.columns = new ArrayList<Table.Column>();
+ }
+
+ /**
+ * Adds a new column with the given properties to the table.
+ *
+ * @param header
+ * column header caption
+ * @param style
+ * optional CSS style class name for the td-Elements of this
+ * column
+ * @param renderer
+ * callback for column rendering
+ * @param defaultSorting
+ * If <code>true</code>, this column is the default sorting
+ * column. Only one column can be selected for default sorting.
+ *
+ */
+ public void add(final String header, final String style,
+ final IColumnRenderer renderer, final boolean defaultSorting) {
+ columns.add(new Column(columns.size(), header, style, renderer,
+ defaultSorting));
+ if (defaultSorting) {
+ if (defaultComparator != null) {
+ throw new IllegalStateException(
+ "Default sorting only allowed for one column.");
+ }
+ this.defaultComparator = renderer.getComparator();
+ }
+ }
+
+ /**
+ * Renders a table for the given icon
+ *
+ * @param parent
+ * parent element in which the table is created
+ * @param items
+ * items that will make the table rows
+ * @param total
+ * the summary of all coverage data items in the table static
+ * resources that might be referenced
+ * @param resources
+ * static resources that might be referenced
+ * @param base
+ * base folder of the table
+ * @throws IOException
+ * in case of IO problems with the element output
+ */
+ public void render(final HTMLElement parent,
+ final List<? extends ITableItem> items, final ICoverageNode total,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ final List<? extends ITableItem> sortedItems = sort(items);
+ final HTMLElement table = parent.table(Styles.COVERAGETABLE);
+ table.attr("id", "coveragetable");
+ header(table, sortedItems, total);
+ footer(table, total, resources, base);
+ body(table, sortedItems, resources, base);
+ }
+
+ private void header(final HTMLElement table,
+ final List<? extends ITableItem> items, final ICoverageNode total)
+ throws IOException {
+ final HTMLElement tr = table.thead().tr();
+ for (final Column c : columns) {
+ c.init(tr, items, total);
+ }
+ }
+
+ private void footer(final HTMLElement table, final ICoverageNode total,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ final HTMLElement tr = table.tfoot().tr();
+ for (final Column c : columns) {
+ c.footer(tr, total, resources, base);
+ }
+ }
+
+ private void body(final HTMLElement table,
+ final List<? extends ITableItem> items, final Resources resources,
+ final ReportOutputFolder base) throws IOException {
+ final HTMLElement tbody = table.tbody();
+ int idx = 0;
+ for (final ITableItem item : items) {
+ final HTMLElement tr = tbody.tr();
+ for (final Column c : columns) {
+ c.body(tr, idx, item, resources, base);
+ }
+ idx++;
+ }
+ }
+
+ private List<? extends ITableItem> sort(
+ final List<? extends ITableItem> items) {
+ if (defaultComparator != null) {
+ final ArrayList<ITableItem> result = new ArrayList<ITableItem>(
+ items);
+ Collections.sort(result, defaultComparator);
+ return result;
+ }
+ return items;
+ }
+
+ private static class Column {
+
+ private final char idprefix;
+ private final String header;
+ private final IColumnRenderer renderer;
+ private final SortIndex<ITableItem> index;
+ private final String style, headerStyle;
+
+ private boolean visible;
+
+ Column(final int idx, final String header, final String style,
+ final IColumnRenderer renderer, final boolean defaultSorting) {
+ this.idprefix = (char) ('a' + idx);
+ this.header = header;
+ this.renderer = renderer;
+ index = new SortIndex<ITableItem>(renderer.getComparator());
+ this.style = style;
+ this.headerStyle = Styles.combine(defaultSorting ? Styles.DOWN
+ : null, Styles.SORTABLE, style);
+ }
+
+ void init(final HTMLElement tr, final List<? extends ITableItem> items,
+ final ICoverageNode total) throws IOException {
+ visible = renderer.init(items, total);
+ if (visible) {
+ index.init(items);
+ final HTMLElement td = tr.td(headerStyle);
+ td.attr("id", String.valueOf(idprefix));
+ td.attr("onclick", "toggleSort(this)");
+ td.text(header);
+ }
+ }
+
+ void footer(final HTMLElement tr, final ICoverageNode total,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ if (visible) {
+ renderer.footer(tr.td(style), total, resources, base);
+ }
+ }
+
+ void body(final HTMLElement tr, final int idx, final ITableItem item,
+ final Resources resources, final ReportOutputFolder base)
+ throws IOException {
+ if (visible) {
+ final HTMLElement td = tr.td(style);
+ td.attr("id", idprefix + String.valueOf(index.getPosition(idx)));
+ renderer.item(td, item, resources, base);
+ }
+ }
+
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/table/TableItemComparator.java b/org.jacoco.report/src/org/jacoco/report/internal/html/table/TableItemComparator.java
index 33426107..68dbc9a4 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/table/TableItemComparator.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/table/TableItemComparator.java
@@ -1,33 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.html.table;
-
-import java.util.Comparator;
-
-import org.jacoco.core.analysis.ICoverageNode;
-
-/**
- * Adapter to sort table items based on their coverage nodes.
- */
-class TableItemComparator implements Comparator<ITableItem> {
-
- private final Comparator<ICoverageNode> comparator;
-
- TableItemComparator(final Comparator<ICoverageNode> comparator) {
- this.comparator = comparator;
- }
-
- public int compare(final ITableItem i1, final ITableItem i2) {
- return comparator.compare(i1.getNode(), i2.getNode());
- }
-
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.html.table;
+
+import java.util.Comparator;
+
+import org.jacoco.core.analysis.ICoverageNode;
+
+/**
+ * Adapter to sort table items based on their coverage nodes.
+ */
+class TableItemComparator implements Comparator<ITableItem> {
+
+ private final Comparator<ICoverageNode> comparator;
+
+ TableItemComparator(final Comparator<ICoverageNode> comparator) {
+ this.comparator = comparator;
+ }
+
+ public int compare(final ITableItem i1, final ITableItem i2) {
+ return comparator.compare(i1.getNode(), i2.getNode());
+ }
+
} \ No newline at end of file
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLCoverageWriter.java b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLCoverageWriter.java
index 79e3a616..f359bd3e 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLCoverageWriter.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLCoverageWriter.java
@@ -1,154 +1,154 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.xml;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.analysis.IClassCoverage;
-import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.analysis.ICoverageNode;
-import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
-import org.jacoco.core.analysis.ILine;
-import org.jacoco.core.analysis.IMethodCoverage;
-import org.jacoco.core.analysis.IPackageCoverage;
-import org.jacoco.core.analysis.ISourceFileCoverage;
-import org.jacoco.core.analysis.ISourceNode;
-
-/**
- * Serializes coverage data as XML fragments.
- */
-public final class XMLCoverageWriter {
-
- /**
- * Creates a child element with a name attribute.
- *
- * @param parent
- * parent element
- * @param tagname
- * name of the child tag
- * @param name
- * value of the name attribute
- * @return child element
- * @throws IOException
- */
- public static XMLElement createChild(final XMLElement parent,
- final String tagname, final String name) throws IOException {
- final XMLElement child = parent.element(tagname);
- child.attr("name", name);
- return child;
- }
-
- /**
- * Writes the structure of a given bundle.
- *
- * @param bundle
- * bundle coverage data
- * @param element
- * container element for the bundle data
- * @throws IOException
- */
- public static void writeBundle(final IBundleCoverage bundle,
- final XMLElement element) throws IOException {
- for (final IPackageCoverage p : bundle.getPackages()) {
- writePackage(p, element);
- }
- writeCounters(bundle, element);
- }
-
- private static void writePackage(final IPackageCoverage p,
- final XMLElement parent) throws IOException {
- final XMLElement element = createChild(parent, "package", p.getName());
- for (final IClassCoverage c : p.getClasses()) {
- writeClass(c, element);
- }
- for (final ISourceFileCoverage s : p.getSourceFiles()) {
- writeSourceFile(s, element);
- }
- writeCounters(p, element);
- }
-
- private static void writeClass(final IClassCoverage c,
- final XMLElement parent) throws IOException {
- final XMLElement element = createChild(parent, "class", c.getName());
- for (final IMethodCoverage m : c.getMethods()) {
- writeMethod(m, element);
- }
- writeCounters(c, element);
- }
-
- private static void writeMethod(final IMethodCoverage m,
- final XMLElement parent) throws IOException {
- final XMLElement element = createChild(parent, "method", m.getName());
- element.attr("desc", m.getDesc());
- final int line = m.getFirstLine();
- if (line != -1) {
- element.attr("line", line);
- }
- writeCounters(m, element);
- }
-
- private static void writeSourceFile(final ISourceFileCoverage s,
- final XMLElement parent) throws IOException {
- final XMLElement element = createChild(parent, "sourcefile",
- s.getName());
- writeLines(s, element);
- writeCounters(s, element);
- }
-
- /**
- * Writes all non-zero counters of the given node.
- *
- * @param node
- * node to retrieve counters from
- * @param parent
- * container for the counter elements
- * @throws IOException
- */
- public static void writeCounters(final ICoverageNode node,
- final XMLElement parent) throws IOException {
- for (final CounterEntity counterEntity : CounterEntity.values()) {
- final ICounter counter = node.getCounter(counterEntity);
- if (counter.getTotalCount() > 0) {
- final XMLElement counterNode = parent.element("counter");
- counterNode.attr("type", counterEntity.name());
- writeCounter(counterNode, "missed", "covered", counter);
- counterNode.close();
- }
- }
- }
-
- private static void writeLines(final ISourceNode source,
- final XMLElement parent) throws IOException {
- final int last = source.getLastLine();
- for (int nr = source.getFirstLine(); nr <= last; nr++) {
- final ILine line = source.getLine(nr);
- if (line.getStatus() != ICounter.EMPTY) {
- final XMLElement element = parent.element("line");
- element.attr("nr", nr);
- writeCounter(element, "mi", "ci", line.getInstructionCounter());
- writeCounter(element, "mb", "cb", line.getBranchCounter());
- }
- }
- }
-
- private static void writeCounter(final XMLElement element,
- final String missedattr, final String coveredattr,
- final ICounter counter) throws IOException {
- element.attr(missedattr, counter.getMissedCount());
- element.attr(coveredattr, counter.getCoveredCount());
- }
-
- private XMLCoverageWriter() {
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.xml;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.analysis.ICoverageNode;
+import org.jacoco.core.analysis.ICoverageNode.CounterEntity;
+import org.jacoco.core.analysis.ILine;
+import org.jacoco.core.analysis.IMethodCoverage;
+import org.jacoco.core.analysis.IPackageCoverage;
+import org.jacoco.core.analysis.ISourceFileCoverage;
+import org.jacoco.core.analysis.ISourceNode;
+
+/**
+ * Serializes coverage data as XML fragments.
+ */
+public final class XMLCoverageWriter {
+
+ /**
+ * Creates a child element with a name attribute.
+ *
+ * @param parent
+ * parent element
+ * @param tagname
+ * name of the child tag
+ * @param name
+ * value of the name attribute
+ * @return child element
+ * @throws IOException
+ */
+ public static XMLElement createChild(final XMLElement parent,
+ final String tagname, final String name) throws IOException {
+ final XMLElement child = parent.element(tagname);
+ child.attr("name", name);
+ return child;
+ }
+
+ /**
+ * Writes the structure of a given bundle.
+ *
+ * @param bundle
+ * bundle coverage data
+ * @param element
+ * container element for the bundle data
+ * @throws IOException
+ */
+ public static void writeBundle(final IBundleCoverage bundle,
+ final XMLElement element) throws IOException {
+ for (final IPackageCoverage p : bundle.getPackages()) {
+ writePackage(p, element);
+ }
+ writeCounters(bundle, element);
+ }
+
+ private static void writePackage(final IPackageCoverage p,
+ final XMLElement parent) throws IOException {
+ final XMLElement element = createChild(parent, "package", p.getName());
+ for (final IClassCoverage c : p.getClasses()) {
+ writeClass(c, element);
+ }
+ for (final ISourceFileCoverage s : p.getSourceFiles()) {
+ writeSourceFile(s, element);
+ }
+ writeCounters(p, element);
+ }
+
+ private static void writeClass(final IClassCoverage c,
+ final XMLElement parent) throws IOException {
+ final XMLElement element = createChild(parent, "class", c.getName());
+ for (final IMethodCoverage m : c.getMethods()) {
+ writeMethod(m, element);
+ }
+ writeCounters(c, element);
+ }
+
+ private static void writeMethod(final IMethodCoverage m,
+ final XMLElement parent) throws IOException {
+ final XMLElement element = createChild(parent, "method", m.getName());
+ element.attr("desc", m.getDesc());
+ final int line = m.getFirstLine();
+ if (line != -1) {
+ element.attr("line", line);
+ }
+ writeCounters(m, element);
+ }
+
+ private static void writeSourceFile(final ISourceFileCoverage s,
+ final XMLElement parent) throws IOException {
+ final XMLElement element = createChild(parent, "sourcefile",
+ s.getName());
+ writeLines(s, element);
+ writeCounters(s, element);
+ }
+
+ /**
+ * Writes all non-zero counters of the given node.
+ *
+ * @param node
+ * node to retrieve counters from
+ * @param parent
+ * container for the counter elements
+ * @throws IOException
+ */
+ public static void writeCounters(final ICoverageNode node,
+ final XMLElement parent) throws IOException {
+ for (final CounterEntity counterEntity : CounterEntity.values()) {
+ final ICounter counter = node.getCounter(counterEntity);
+ if (counter.getTotalCount() > 0) {
+ final XMLElement counterNode = parent.element("counter");
+ counterNode.attr("type", counterEntity.name());
+ writeCounter(counterNode, "missed", "covered", counter);
+ counterNode.close();
+ }
+ }
+ }
+
+ private static void writeLines(final ISourceNode source,
+ final XMLElement parent) throws IOException {
+ final int last = source.getLastLine();
+ for (int nr = source.getFirstLine(); nr <= last; nr++) {
+ final ILine line = source.getLine(nr);
+ if (line.getStatus() != ICounter.EMPTY) {
+ final XMLElement element = parent.element("line");
+ element.attr("nr", nr);
+ writeCounter(element, "mi", "ci", line.getInstructionCounter());
+ writeCounter(element, "mb", "cb", line.getBranchCounter());
+ }
+ }
+ }
+
+ private static void writeCounter(final XMLElement element,
+ final String missedattr, final String coveredattr,
+ final ICounter counter) throws IOException {
+ element.attr(missedattr, counter.getMissedCount());
+ element.attr(coveredattr, counter.getCoveredCount());
+ }
+
+ private XMLCoverageWriter() {
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLDocument.java b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLDocument.java
index 9fcb2012..7ca92636 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLDocument.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLDocument.java
@@ -1,111 +1,111 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.xml;
-
-import static java.lang.String.format;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-/**
- * Root element of an XML document. Each instance represents a separate output
- * document.
- *
- * @see XMLElement
- */
-public class XMLDocument extends XMLElement {
-
- /** XML header template */
- private static final String HEADER = "<?xml version=\"1.0\" encoding=\"%s\"?>";
-
- /** XML header template for standalone documents */
- private static final String HEADER_STANDALONE = "<?xml version=\"1.0\" encoding=\"%s\" standalone=\"yes\"?>";
-
- /** DOCTYPE declaration template */
- private static final String DOCTYPE = "<!DOCTYPE %s PUBLIC \"%s\" \"%s\">";
-
- /**
- * Writes a new document to the given writer. The document might contain a
- * document type declaration.
- *
- * @param rootnode
- * name of the root node
- * @param pubId
- * optional doctype identifier or <code>null</code>
- * @param system
- * system reference, required if doctype is given
- * @param encoding
- * encoding that will be specified in the header
- * @param standalone
- * <code>true</code> if this is a standalone document
- * @param writer
- * writer for content output
- * @throws IOException
- * in case of problems with the writer
- */
- public XMLDocument(final String rootnode, final String pubId,
- final String system, final String encoding,
- final boolean standalone, final Writer writer) throws IOException {
- super(writer, rootnode);
- writeHeader(rootnode, pubId, system, encoding, standalone, writer);
- beginOpenTag();
- }
-
- /**
- * Writes a new document to the given binary stream. The document might
- * contain a document type declaration.
- *
- * @param rootnode
- * name of the root node
- * @param pubId
- * optional doctype identifier or <code>null</code>
- * @param system
- * system reference, required if doctype is given
- * @param encoding
- * encoding of the XML document
- * @param standalone
- * <code>true</code> if this is a standalone document
- * @param output
- * output for content output
- * @throws IOException
- * in case of problems with the writer
- */
- public XMLDocument(final String rootnode, final String pubId,
- final String system, final String encoding,
- final boolean standalone, final OutputStream output)
- throws IOException {
- this(rootnode, pubId, system, encoding, standalone,
- new OutputStreamWriter(output, encoding));
- }
-
- @Override
- public void close() throws IOException {
- super.close();
- writer.close();
- }
-
- private static void writeHeader(final String rootnode, final String pubId,
- final String system, final String encoding,
- final boolean standalone, final Writer writer) throws IOException {
- if (standalone) {
- writer.write(format(HEADER_STANDALONE, encoding));
- } else {
- writer.write(format(HEADER, encoding));
- }
- if (pubId != null) {
- writer.write(format(DOCTYPE, rootnode, pubId, system));
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.xml;
+
+import static java.lang.String.format;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+/**
+ * Root element of an XML document. Each instance represents a separate output
+ * document.
+ *
+ * @see XMLElement
+ */
+public class XMLDocument extends XMLElement {
+
+ /** XML header template */
+ private static final String HEADER = "<?xml version=\"1.0\" encoding=\"%s\"?>";
+
+ /** XML header template for standalone documents */
+ private static final String HEADER_STANDALONE = "<?xml version=\"1.0\" encoding=\"%s\" standalone=\"yes\"?>";
+
+ /** DOCTYPE declaration template */
+ private static final String DOCTYPE = "<!DOCTYPE %s PUBLIC \"%s\" \"%s\">";
+
+ /**
+ * Writes a new document to the given writer. The document might contain a
+ * document type declaration.
+ *
+ * @param rootnode
+ * name of the root node
+ * @param pubId
+ * optional doctype identifier or <code>null</code>
+ * @param system
+ * system reference, required if doctype is given
+ * @param encoding
+ * encoding that will be specified in the header
+ * @param standalone
+ * <code>true</code> if this is a standalone document
+ * @param writer
+ * writer for content output
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public XMLDocument(final String rootnode, final String pubId,
+ final String system, final String encoding,
+ final boolean standalone, final Writer writer) throws IOException {
+ super(writer, rootnode);
+ writeHeader(rootnode, pubId, system, encoding, standalone, writer);
+ beginOpenTag();
+ }
+
+ /**
+ * Writes a new document to the given binary stream. The document might
+ * contain a document type declaration.
+ *
+ * @param rootnode
+ * name of the root node
+ * @param pubId
+ * optional doctype identifier or <code>null</code>
+ * @param system
+ * system reference, required if doctype is given
+ * @param encoding
+ * encoding of the XML document
+ * @param standalone
+ * <code>true</code> if this is a standalone document
+ * @param output
+ * output for content output
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public XMLDocument(final String rootnode, final String pubId,
+ final String system, final String encoding,
+ final boolean standalone, final OutputStream output)
+ throws IOException {
+ this(rootnode, pubId, system, encoding, standalone,
+ new OutputStreamWriter(output, encoding));
+ }
+
+ @Override
+ public void close() throws IOException {
+ super.close();
+ writer.close();
+ }
+
+ private static void writeHeader(final String rootnode, final String pubId,
+ final String system, final String encoding,
+ final boolean standalone, final Writer writer) throws IOException {
+ if (standalone) {
+ writer.write(format(HEADER_STANDALONE, encoding));
+ } else {
+ writer.write(format(HEADER, encoding));
+ }
+ if (pubId != null) {
+ writer.write(format(DOCTYPE, rootnode, pubId, system));
+ }
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLElement.java b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLElement.java
index 14b0a409..52f2b3c3 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLElement.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLElement.java
@@ -1,262 +1,262 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Marc R. Hoffmann - initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.internal.xml;
-
-import static java.lang.String.format;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * Simple API to create well formed XML streams. A {@link XMLElement} instance
- * represents a single element in a XML document.
- *
- * @see XMLDocument
- */
-public class XMLElement {
-
- private static final char SPACE = ' ';
-
- private static final char EQ = '=';
-
- private static final char LT = '<';
-
- private static final char GT = '>';
-
- private static final char QUOT = '"';
-
- private static final char AMP = '&';
-
- private static final char SLASH = '/';
-
- /** Writer for content output */
- protected final Writer writer;
-
- private final String name;
-
- private boolean openTagDone;
-
- private boolean closed;
-
- private XMLElement lastchild;
-
- /**
- * Creates a new element for a XML document.
- *
- * @param writer
- * all output will be written directly to this
- * @param name
- * element name
- */
- protected XMLElement(final Writer writer, final String name) {
- this.writer = writer;
- this.name = name;
- this.openTagDone = false;
- this.closed = false;
- this.lastchild = null;
- }
-
- /**
- * Emits the beginning of the open tag. This method has to be called before
- * other other methods are called on this element.
- *
- * @throws IOException
- * in case of problems with the writer
- */
- protected void beginOpenTag() throws IOException {
- writer.write(LT);
- writer.write(name);
- }
-
- private void finishOpenTag() throws IOException {
- if (!openTagDone) {
- writer.append(GT);
- openTagDone = true;
- }
- }
-
- /**
- * Adds the given child to this element. This will close all previous child
- * elements.
- *
- * @param child
- * child element to add
- * @throws IOException
- * in case of invalid nesting or problems with the writer
- */
- protected void addChildElement(final XMLElement child) throws IOException {
- if (closed) {
- throw new IOException(format("Element %s already closed.", name));
- }
- finishOpenTag();
- if (lastchild != null) {
- lastchild.close();
- }
- child.beginOpenTag();
- lastchild = child;
- }
-
- private void quote(final String text) throws IOException {
- final int len = text.length();
- for (int i = 0; i < len; i++) {
- final char c = text.charAt(i);
- switch (c) {
- case LT:
- writer.write("&lt;");
- break;
- case GT:
- writer.write("&gt;");
- break;
- case QUOT:
- writer.write("&quot;");
- break;
- case AMP:
- writer.write("&amp;");
- break;
- default:
- writer.write(c);
- }
- }
- }
-
- /**
- * Adds an attribute to this element. May only be called before an child
- * element is added or this element has been closed. The attribute value
- * will be quoted. If the value is <code>null</code> the attribute will not
- * be added.
- *
- * @param name
- * attribute name
- * @param value
- * attribute value or <code>null</code>
- *
- * @return this element
- * @throws IOException
- * in case of problems with the writer
- */
- public XMLElement attr(final String name, final String value)
- throws IOException {
- if (value == null) {
- return this;
- }
- if (closed || openTagDone) {
- throw new IOException(format("Element %s already closed.",
- this.name));
- }
- writer.write(SPACE);
- writer.write(name);
- writer.write(EQ);
- writer.write(QUOT);
- quote(value);
- writer.write(QUOT);
- return this;
- }
-
- /**
- * Adds an attribute to this element. May only be called before an child
- * element is added or this element has been closed. The attribute value is
- * the decimal representation of the given int value.
- *
- * @param name
- * attribute name
- * @param value
- * attribute value
- *
- * @return this element
- * @throws IOException
- * in case of problems with the writer
- */
- public XMLElement attr(final String name, final int value)
- throws IOException {
- return attr(name, String.valueOf(value));
- }
-
- /**
- * Adds an attribute to this element. May only be called before an child
- * element is added or this element has been closed. The attribute value is
- * the decimal representation of the given long value.
- *
- * @param name
- * attribute name
- * @param value
- * attribute value
- *
- * @return this element
- * @throws IOException
- * in case of problems with the writer
- */
- public XMLElement attr(final String name, final long value)
- throws IOException {
- return attr(name, String.valueOf(value));
- }
-
- /**
- * Adds the given text as a child to this node. The text will be quoted.
- *
- * @param text
- * text to add
- * @return this element
- * @throws IOException
- * in case of problems with the writer
- */
- public XMLElement text(final String text) throws IOException {
- if (closed) {
- throw new IOException(format("Element %s already closed.", name));
- }
- finishOpenTag();
- if (lastchild != null) {
- lastchild.close();
- }
- quote(text);
- return this;
- }
-
- /**
- * Creates a new child element for this element,
- *
- * @param name
- * name of the child element
- * @return child element instance
- * @throws IOException
- * in case of problems with the writer
- */
- public XMLElement element(final String name) throws IOException {
- final XMLElement element = new XMLElement(writer, name);
- addChildElement(element);
- return element;
- }
-
- /**
- * Closes this element if it has not been closed before.
- *
- * @throws IOException
- * in case of problems with the writer
- */
- public void close() throws IOException {
- if (!closed) {
- if (lastchild != null) {
- lastchild.close();
- }
- if (openTagDone) {
- writer.write(LT);
- writer.write(SLASH);
- writer.write(name);
- } else {
- writer.write(SLASH);
- }
- writer.write(GT);
- closed = true;
- openTagDone = true;
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.xml;
+
+import static java.lang.String.format;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Simple API to create well formed XML streams. A {@link XMLElement} instance
+ * represents a single element in a XML document.
+ *
+ * @see XMLDocument
+ */
+public class XMLElement {
+
+ private static final char SPACE = ' ';
+
+ private static final char EQ = '=';
+
+ private static final char LT = '<';
+
+ private static final char GT = '>';
+
+ private static final char QUOT = '"';
+
+ private static final char AMP = '&';
+
+ private static final char SLASH = '/';
+
+ /** Writer for content output */
+ protected final Writer writer;
+
+ private final String name;
+
+ private boolean openTagDone;
+
+ private boolean closed;
+
+ private XMLElement lastchild;
+
+ /**
+ * Creates a new element for a XML document.
+ *
+ * @param writer
+ * all output will be written directly to this
+ * @param name
+ * element name
+ */
+ protected XMLElement(final Writer writer, final String name) {
+ this.writer = writer;
+ this.name = name;
+ this.openTagDone = false;
+ this.closed = false;
+ this.lastchild = null;
+ }
+
+ /**
+ * Emits the beginning of the open tag. This method has to be called before
+ * other other methods are called on this element.
+ *
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ protected void beginOpenTag() throws IOException {
+ writer.write(LT);
+ writer.write(name);
+ }
+
+ private void finishOpenTag() throws IOException {
+ if (!openTagDone) {
+ writer.append(GT);
+ openTagDone = true;
+ }
+ }
+
+ /**
+ * Adds the given child to this element. This will close all previous child
+ * elements.
+ *
+ * @param child
+ * child element to add
+ * @throws IOException
+ * in case of invalid nesting or problems with the writer
+ */
+ protected void addChildElement(final XMLElement child) throws IOException {
+ if (closed) {
+ throw new IOException(format("Element %s already closed.", name));
+ }
+ finishOpenTag();
+ if (lastchild != null) {
+ lastchild.close();
+ }
+ child.beginOpenTag();
+ lastchild = child;
+ }
+
+ private void quote(final String text) throws IOException {
+ final int len = text.length();
+ for (int i = 0; i < len; i++) {
+ final char c = text.charAt(i);
+ switch (c) {
+ case LT:
+ writer.write("&lt;");
+ break;
+ case GT:
+ writer.write("&gt;");
+ break;
+ case QUOT:
+ writer.write("&quot;");
+ break;
+ case AMP:
+ writer.write("&amp;");
+ break;
+ default:
+ writer.write(c);
+ }
+ }
+ }
+
+ /**
+ * Adds an attribute to this element. May only be called before an child
+ * element is added or this element has been closed. The attribute value
+ * will be quoted. If the value is <code>null</code> the attribute will not
+ * be added.
+ *
+ * @param name
+ * attribute name
+ * @param value
+ * attribute value or <code>null</code>
+ *
+ * @return this element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public XMLElement attr(final String name, final String value)
+ throws IOException {
+ if (value == null) {
+ return this;
+ }
+ if (closed || openTagDone) {
+ throw new IOException(format("Element %s already closed.",
+ this.name));
+ }
+ writer.write(SPACE);
+ writer.write(name);
+ writer.write(EQ);
+ writer.write(QUOT);
+ quote(value);
+ writer.write(QUOT);
+ return this;
+ }
+
+ /**
+ * Adds an attribute to this element. May only be called before an child
+ * element is added or this element has been closed. The attribute value is
+ * the decimal representation of the given int value.
+ *
+ * @param name
+ * attribute name
+ * @param value
+ * attribute value
+ *
+ * @return this element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public XMLElement attr(final String name, final int value)
+ throws IOException {
+ return attr(name, String.valueOf(value));
+ }
+
+ /**
+ * Adds an attribute to this element. May only be called before an child
+ * element is added or this element has been closed. The attribute value is
+ * the decimal representation of the given long value.
+ *
+ * @param name
+ * attribute name
+ * @param value
+ * attribute value
+ *
+ * @return this element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public XMLElement attr(final String name, final long value)
+ throws IOException {
+ return attr(name, String.valueOf(value));
+ }
+
+ /**
+ * Adds the given text as a child to this node. The text will be quoted.
+ *
+ * @param text
+ * text to add
+ * @return this element
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public XMLElement text(final String text) throws IOException {
+ if (closed) {
+ throw new IOException(format("Element %s already closed.", name));
+ }
+ finishOpenTag();
+ if (lastchild != null) {
+ lastchild.close();
+ }
+ quote(text);
+ return this;
+ }
+
+ /**
+ * Creates a new child element for this element,
+ *
+ * @param name
+ * name of the child element
+ * @return child element instance
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public XMLElement element(final String name) throws IOException {
+ final XMLElement element = new XMLElement(writer, name);
+ addChildElement(element);
+ return element;
+ }
+
+ /**
+ * Closes this element if it has not been closed before.
+ *
+ * @throws IOException
+ * in case of problems with the writer
+ */
+ public void close() throws IOException {
+ if (!closed) {
+ if (lastchild != null) {
+ lastchild.close();
+ }
+ if (openTagDone) {
+ writer.write(LT);
+ writer.write(SLASH);
+ writer.write(name);
+ } else {
+ writer.write(SLASH);
+ }
+ writer.write(GT);
+ closed = true;
+ openTagDone = true;
+ }
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLGroupVisitor.java b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLGroupVisitor.java
index a012db89..e9867f85 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLGroupVisitor.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLGroupVisitor.java
@@ -1,70 +1,70 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Brock Janiczak - initial API and implementation
- * Marc R. Hoffmann - generalized structure, line info
- *
- *******************************************************************************/
-package org.jacoco.report.internal.xml;
-
-import java.io.IOException;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.report.ISourceFileLocator;
-import org.jacoco.report.internal.AbstractGroupVisitor;
-
-/**
- * A {@link org.jacoco.report.IReportGroupVisitor} that transforms the report
- * structure into XML elements.
- */
-public class XMLGroupVisitor extends AbstractGroupVisitor {
-
- /** XML element of this group */
- protected final XMLElement element;
-
- /**
- * New handler for a group with the given name.
- *
- * @param element
- * XML-Element representing this coverage node. The start tag
- * must not be closed yet to allow adding additional attributes.
- * @param name
- * name of the group
- * @throws IOException
- * in case of problems with the underlying writer
- */
- public XMLGroupVisitor(final XMLElement element, final String name)
- throws IOException {
- super(name);
- this.element = element;
- }
-
- @Override
- protected void handleBundle(final IBundleCoverage bundle,
- final ISourceFileLocator locator) throws IOException {
- final XMLElement child = createChild(bundle.getName());
- XMLCoverageWriter.writeBundle(bundle, child);
- }
-
- @Override
- protected AbstractGroupVisitor handleGroup(final String name)
- throws IOException {
- final XMLElement child = createChild(name);
- return new XMLGroupVisitor(child, name);
- }
-
- @Override
- protected void handleEnd() throws IOException {
- XMLCoverageWriter.writeCounters(total, element);
- }
-
- private XMLElement createChild(final String name) throws IOException {
- return XMLCoverageWriter.createChild(element, "group", name);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Brock Janiczak - initial API and implementation
+ * Marc R. Hoffmann - generalized structure, line info
+ *
+ *******************************************************************************/
+package org.jacoco.report.internal.xml;
+
+import java.io.IOException;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.report.ISourceFileLocator;
+import org.jacoco.report.internal.AbstractGroupVisitor;
+
+/**
+ * A {@link org.jacoco.report.IReportGroupVisitor} that transforms the report
+ * structure into XML elements.
+ */
+public class XMLGroupVisitor extends AbstractGroupVisitor {
+
+ /** XML element of this group */
+ protected final XMLElement element;
+
+ /**
+ * New handler for a group with the given name.
+ *
+ * @param element
+ * XML-Element representing this coverage node. The start tag
+ * must not be closed yet to allow adding additional attributes.
+ * @param name
+ * name of the group
+ * @throws IOException
+ * in case of problems with the underlying writer
+ */
+ public XMLGroupVisitor(final XMLElement element, final String name)
+ throws IOException {
+ super(name);
+ this.element = element;
+ }
+
+ @Override
+ protected void handleBundle(final IBundleCoverage bundle,
+ final ISourceFileLocator locator) throws IOException {
+ final XMLElement child = createChild(bundle.getName());
+ XMLCoverageWriter.writeBundle(bundle, child);
+ }
+
+ @Override
+ protected AbstractGroupVisitor handleGroup(final String name)
+ throws IOException {
+ final XMLElement child = createChild(name);
+ return new XMLGroupVisitor(child, name);
+ }
+
+ @Override
+ protected void handleEnd() throws IOException {
+ XMLCoverageWriter.writeCounters(total, element);
+ }
+
+ private XMLElement createChild(final String name) throws IOException {
+ return XMLCoverageWriter.createChild(element, "group", name);
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/xml/XMLFormatter.java b/org.jacoco.report/src/org/jacoco/report/xml/XMLFormatter.java
index d59c557c..18f24c51 100644
--- a/org.jacoco.report/src/org/jacoco/report/xml/XMLFormatter.java
+++ b/org.jacoco.report/src/org/jacoco/report/xml/XMLFormatter.java
@@ -1,110 +1,110 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Brock Janiczak -initial API and implementation
- *
- *******************************************************************************/
-package org.jacoco.report.xml;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.List;
-
-import org.jacoco.core.analysis.IBundleCoverage;
-import org.jacoco.core.data.ExecutionData;
-import org.jacoco.core.data.SessionInfo;
-import org.jacoco.report.IReportVisitor;
-import org.jacoco.report.ISourceFileLocator;
-import org.jacoco.report.internal.AbstractGroupVisitor;
-import org.jacoco.report.internal.xml.XMLCoverageWriter;
-import org.jacoco.report.internal.xml.XMLDocument;
-import org.jacoco.report.internal.xml.XMLElement;
-import org.jacoco.report.internal.xml.XMLGroupVisitor;
-
-/**
- * Report formatter that creates a single XML file for a coverage session
- */
-public class XMLFormatter {
-
- private static final String PUBID = "-//JACOCO//DTD Report 1.0//EN";
-
- private static final String SYSTEM = "report.dtd";
-
- private String outputEncoding = "UTF-8";
-
- /**
- * Sets the encoding used for generated XML document. Default is UTF-8.
- *
- * @param outputEncoding
- * XML output encoding
- */
- public void setOutputEncoding(final String outputEncoding) {
- this.outputEncoding = outputEncoding;
- }
-
- /**
- * Creates a new visitor to write a report to the given stream.
- *
- * @param output
- * output stream to write the report to
- * @return visitor to emit the report data to
- * @throws IOException
- * in case of problems with the output stream
- */
- public IReportVisitor createVisitor(final OutputStream output)
- throws IOException {
- final XMLElement root = new XMLDocument("report", PUBID, SYSTEM,
- outputEncoding, true, output);
- class RootVisitor extends XMLGroupVisitor implements IReportVisitor {
-
- RootVisitor(final XMLElement element) throws IOException {
- super(element, null);
- }
-
- private List<SessionInfo> sessionInfos;
-
- public void visitInfo(final List<SessionInfo> sessionInfos,
- final Collection<ExecutionData> executionData)
- throws IOException {
- this.sessionInfos = sessionInfos;
- }
-
- @Override
- protected void handleBundle(final IBundleCoverage bundle,
- final ISourceFileLocator locator) throws IOException {
- writeHeader(bundle.getName());
- XMLCoverageWriter.writeBundle(bundle, element);
- }
-
- @Override
- protected AbstractGroupVisitor handleGroup(final String name)
- throws IOException {
- writeHeader(name);
- return new XMLGroupVisitor(element, name);
- }
-
- private void writeHeader(final String name) throws IOException {
- element.attr("name", name);
- for (final SessionInfo i : sessionInfos) {
- final XMLElement sessioninfo = root.element("sessioninfo");
- sessioninfo.attr("id", i.getId());
- sessioninfo.attr("start", i.getStartTimeStamp());
- sessioninfo.attr("dump", i.getDumpTimeStamp());
- }
- }
-
- @Override
- protected void handleEnd() throws IOException {
- element.close();
- }
- }
- return new RootVisitor(root);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Brock Janiczak -initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.report.xml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.List;
+
+import org.jacoco.core.analysis.IBundleCoverage;
+import org.jacoco.core.data.ExecutionData;
+import org.jacoco.core.data.SessionInfo;
+import org.jacoco.report.IReportVisitor;
+import org.jacoco.report.ISourceFileLocator;
+import org.jacoco.report.internal.AbstractGroupVisitor;
+import org.jacoco.report.internal.xml.XMLCoverageWriter;
+import org.jacoco.report.internal.xml.XMLDocument;
+import org.jacoco.report.internal.xml.XMLElement;
+import org.jacoco.report.internal.xml.XMLGroupVisitor;
+
+/**
+ * Report formatter that creates a single XML file for a coverage session
+ */
+public class XMLFormatter {
+
+ private static final String PUBID = "-//JACOCO//DTD Report 1.0//EN";
+
+ private static final String SYSTEM = "report.dtd";
+
+ private String outputEncoding = "UTF-8";
+
+ /**
+ * Sets the encoding used for generated XML document. Default is UTF-8.
+ *
+ * @param outputEncoding
+ * XML output encoding
+ */
+ public void setOutputEncoding(final String outputEncoding) {
+ this.outputEncoding = outputEncoding;
+ }
+
+ /**
+ * Creates a new visitor to write a report to the given stream.
+ *
+ * @param output
+ * output stream to write the report to
+ * @return visitor to emit the report data to
+ * @throws IOException
+ * in case of problems with the output stream
+ */
+ public IReportVisitor createVisitor(final OutputStream output)
+ throws IOException {
+ final XMLElement root = new XMLDocument("report", PUBID, SYSTEM,
+ outputEncoding, true, output);
+ class RootVisitor extends XMLGroupVisitor implements IReportVisitor {
+
+ RootVisitor(final XMLElement element) throws IOException {
+ super(element, null);
+ }
+
+ private List<SessionInfo> sessionInfos;
+
+ public void visitInfo(final List<SessionInfo> sessionInfos,
+ final Collection<ExecutionData> executionData)
+ throws IOException {
+ this.sessionInfos = sessionInfos;
+ }
+
+ @Override
+ protected void handleBundle(final IBundleCoverage bundle,
+ final ISourceFileLocator locator) throws IOException {
+ writeHeader(bundle.getName());
+ XMLCoverageWriter.writeBundle(bundle, element);
+ }
+
+ @Override
+ protected AbstractGroupVisitor handleGroup(final String name)
+ throws IOException {
+ writeHeader(name);
+ return new XMLGroupVisitor(element, name);
+ }
+
+ private void writeHeader(final String name) throws IOException {
+ element.attr("name", name);
+ for (final SessionInfo i : sessionInfos) {
+ final XMLElement sessioninfo = root.element("sessioninfo");
+ sessioninfo.attr("id", i.getId());
+ sessioninfo.attr("start", i.getStartTimeStamp());
+ sessioninfo.attr("dump", i.getDumpTimeStamp());
+ }
+ }
+
+ @Override
+ protected void handleEnd() throws IOException {
+ element.close();
+ }
+ }
+ return new RootVisitor(root);
+ }
+
+}
diff --git a/org.jacoco.report/src/org/jacoco/report/xml/report.dtd b/org.jacoco.report/src/org/jacoco/report/xml/report.dtd
index 46b497b3..5e6184a8 100644
--- a/org.jacoco.report/src/org/jacoco/report/xml/report.dtd
+++ b/org.jacoco.report/src/org/jacoco/report/xml/report.dtd
@@ -1,84 +1,84 @@
-<!--
- Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
- Brock Janiczak - initial API and implementation
- Marc R. Hoffmann - generalized report structure, line info, documentation
-
- $Id: $
--->
-
-<!-- This DTD describes the JaCoCo XML report format. It is identified by the
- following identifiers:
-
- PUBID = "-//JACOCO//DTD Report 1.0//EN"
- SYSTEM = "report.dtd"
--->
-
-<!-- report root node -->
-<!ELEMENT report (sessioninfo*, (group* | package*), counter*)>
- <!ATTLIST report name CDATA #REQUIRED>
-
-<!-- information about a session which contributed execution data -->
-<!ELEMENT sessioninfo EMPTY>
- <!-- session id -->
- <!ATTLIST sessioninfo id CDATA #REQUIRED>
- <!-- start time stamp -->
- <!ATTLIST sessioninfo start CDATA #REQUIRED>
- <!-- dump time stamp -->
- <!ATTLIST sessioninfo dump CDATA #REQUIRED>
-
-<!-- representation of a group -->
-<!ELEMENT group ((group* | package*), counter*)>
- <!-- group name -->
- <!ATTLIST group name CDATA #REQUIRED>
-
-<!-- representation of a package -->
-<!ELEMENT package ((class | sourcefile)*, counter*)>
- <!-- package name in VM notation -->
- <!ATTLIST package name CDATA #REQUIRED>
-
-<!-- representation of a class -->
-<!ELEMENT class (method*, counter*)>
- <!-- fully qualified VM name -->
- <!ATTLIST class name CDATA #REQUIRED>
-
-<!-- representation of a method -->
-<!ELEMENT method (counter*)>
- <!-- method name -->
- <!ATTLIST method name CDATA #REQUIRED>
- <!-- method parameter description -->
- <!ATTLIST method desc CDATA #REQUIRED>
- <!-- first source line number of this method -->
- <!ATTLIST method line CDATA #IMPLIED>
-
-<!-- representation of a source file -->
-<!ELEMENT sourcefile (line*, counter*)>
- <!-- local source file name -->
- <!ATTLIST sourcefile name CDATA #REQUIRED>
-
-<!-- representation of a source line -->
-<!ELEMENT line EMPTY>
- <!-- line number -->
- <!ATTLIST line nr CDATA #REQUIRED>
- <!-- number of missed instructions -->
- <!ATTLIST line mi CDATA #IMPLIED>
- <!-- number of covered instructions -->
- <!ATTLIST line ci CDATA #IMPLIED>
- <!-- number of missed branches -->
- <!ATTLIST line mb CDATA #IMPLIED>
- <!-- number of covered branches -->
- <!ATTLIST line cb CDATA #IMPLIED>
-
-<!-- coverage data counter for different metrics -->
-<!ELEMENT counter EMPTY>
- <!-- metric type -->
- <!ATTLIST counter type (INSTRUCTION|BRANCH|LINE|COMPLEXITY|METHOD|CLASS) #REQUIRED>
- <!-- number of missed items -->
- <!ATTLIST counter missed CDATA #REQUIRED>
- <!-- number of covered items -->
+<!--
+ Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Brock Janiczak - initial API and implementation
+ Marc R. Hoffmann - generalized report structure, line info, documentation
+
+ $Id: $
+-->
+
+<!-- This DTD describes the JaCoCo XML report format. It is identified by the
+ following identifiers:
+
+ PUBID = "-//JACOCO//DTD Report 1.0//EN"
+ SYSTEM = "report.dtd"
+-->
+
+<!-- report root node -->
+<!ELEMENT report (sessioninfo*, (group* | package*), counter*)>
+ <!ATTLIST report name CDATA #REQUIRED>
+
+<!-- information about a session which contributed execution data -->
+<!ELEMENT sessioninfo EMPTY>
+ <!-- session id -->
+ <!ATTLIST sessioninfo id CDATA #REQUIRED>
+ <!-- start time stamp -->
+ <!ATTLIST sessioninfo start CDATA #REQUIRED>
+ <!-- dump time stamp -->
+ <!ATTLIST sessioninfo dump CDATA #REQUIRED>
+
+<!-- representation of a group -->
+<!ELEMENT group ((group* | package*), counter*)>
+ <!-- group name -->
+ <!ATTLIST group name CDATA #REQUIRED>
+
+<!-- representation of a package -->
+<!ELEMENT package ((class | sourcefile)*, counter*)>
+ <!-- package name in VM notation -->
+ <!ATTLIST package name CDATA #REQUIRED>
+
+<!-- representation of a class -->
+<!ELEMENT class (method*, counter*)>
+ <!-- fully qualified VM name -->
+ <!ATTLIST class name CDATA #REQUIRED>
+
+<!-- representation of a method -->
+<!ELEMENT method (counter*)>
+ <!-- method name -->
+ <!ATTLIST method name CDATA #REQUIRED>
+ <!-- method parameter description -->
+ <!ATTLIST method desc CDATA #REQUIRED>
+ <!-- first source line number of this method -->
+ <!ATTLIST method line CDATA #IMPLIED>
+
+<!-- representation of a source file -->
+<!ELEMENT sourcefile (line*, counter*)>
+ <!-- local source file name -->
+ <!ATTLIST sourcefile name CDATA #REQUIRED>
+
+<!-- representation of a source line -->
+<!ELEMENT line EMPTY>
+ <!-- line number -->
+ <!ATTLIST line nr CDATA #REQUIRED>
+ <!-- number of missed instructions -->
+ <!ATTLIST line mi CDATA #IMPLIED>
+ <!-- number of covered instructions -->
+ <!ATTLIST line ci CDATA #IMPLIED>
+ <!-- number of missed branches -->
+ <!ATTLIST line mb CDATA #IMPLIED>
+ <!-- number of covered branches -->
+ <!ATTLIST line cb CDATA #IMPLIED>
+
+<!-- coverage data counter for different metrics -->
+<!ELEMENT counter EMPTY>
+ <!-- metric type -->
+ <!ATTLIST counter type (INSTRUCTION|BRANCH|LINE|COMPLEXITY|METHOD|CLASS) #REQUIRED>
+ <!-- number of missed items -->
+ <!ATTLIST counter missed CDATA #REQUIRED>
+ <!-- number of covered items -->
<!ATTLIST counter covered CDATA #REQUIRED> \ No newline at end of file