More API usage examples.
diff --git a/org.jacoco.doc/docroot/doc/api.html b/org.jacoco.doc/docroot/doc/api.html
new file mode 100644
index 0000000..63ef3da
--- /dev/null
+++ b/org.jacoco.doc/docroot/doc/api.html
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ <link rel="stylesheet" href=".resources/doc.css" charset="ISO-8859-1" type="text/css" />
+ <link rel="stylesheet" href="../coverage/.resources/prettify.css" charset="ISO-8859-1" type="text/css" />
+ <script type="text/javascript" src="../coverage/.resources/prettify.js"></script>
+ <title>JaCoCo - API Usage Examples</title>
+</head>
+<body onload="prettyPrint()">
+
+<div class="breadcrumb">
+ <a href="../index.html" class="el_session">JaCoCo</a> >
+ <a href="index.html" class="el_group">Documentation</a> >
+ <span class="el_source">API Usage Examples</span>
+</div>
+<div id="content">
+
+<h1>API Usage Examples</h1>
+
+<p>
+ To get familiar with the API these examples demonstrate different aspects of
+ the JaCoCo API. Each example can be separately compiled and executed as a Java
+ main program. Some examples require additional command line arguments.
+</p>
+
+<table class="coverage">
+ <thead>
+ <tr>
+ <td>File</td>
+ <td>Description</td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="examples/CoreTutorial.java">CoreTutorial.java</a></td>
+ <td>This tutorial-like example instruments, executes and analyzes a single
+ target class. Finally line coverage information is printed to the
+ console.
+ </td>
+ </tr>
+ <tr>
+ <td><a href="examples/ClassInfo.java">ClassInfo.java</a></td>
+ <td>This example writes JaCoCo specific information for given Java class
+ files.
+ </td>
+ </tr>
+ <tr>
+ <td><a href="examples/ExecDump.java">ExecDump.java</a></td>
+ <td>Utility to dump the content of execution data files in readable form.
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+
+
+</div>
+<div class="footer">
+ <div class="versioninfo"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</div>
+ <a href="license.html">Copyright</a> © @copyright.years@ Mountainminds GmbH & Co. KG and Contributors
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.jacoco.doc/docroot/doc/index.html b/org.jacoco.doc/docroot/doc/index.html
index 9aff78f..fcca976 100644
--- a/org.jacoco.doc/docroot/doc/index.html
+++ b/org.jacoco.doc/docroot/doc/index.html
@@ -49,8 +49,8 @@
<ul>
<li><a href="implementation.html">Implementation Design</a></li>
<li><a href="flow.html">Control Flow Analysis</a></li>
- <li><a href="api/index.html">API Documentation (JavaDoc)</a></li>
- <li><a href="examples/CoreTutorial.java">API Usage Example</a></li>
+ <li><a href="api/index.html">API JavaDoc</a></li>
+ <li><a href="api.html">API Usage Examples</a></li>
<li><a href="report.dtd">XML Report DTD</a></li>
</ul>
diff --git a/org.jacoco.doc/docroot/index.html b/org.jacoco.doc/docroot/index.html
index f6f619e..79f0351 100644
--- a/org.jacoco.doc/docroot/index.html
+++ b/org.jacoco.doc/docroot/index.html
@@ -28,10 +28,11 @@
<h2>Implementation Status</h2>
<p>
- This first official release of JaCoCo is a fully functional prototype to
- verify the basic concepts and implementation strategies. It already produces
+ This release of JaCoCo is a fully functional prototype to verify the basic
+ concepts and implementation strategies. It already produces
<a href="coverage/index.html">neat coverage reports</a> and has been
- successfully tested with huge Eclipse RCP applications and web projects.
+ successfully tested with comprehensive JUnit test suites as well as huge
+ Eclipse RCP applications and J2EE projects.
</p>
<p class="hint">
diff --git a/org.jacoco.examples/src/org/jacoco/examples/ClassInfo.java b/org.jacoco.examples/src/org/jacoco/examples/ClassInfo.java
new file mode 100644
index 0000000..ce7e2c8
--- /dev/null
+++ b/org.jacoco.examples/src/org/jacoco/examples/ClassInfo.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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
+ *
+ * $Id: $
+ *******************************************************************************/
+package org.jacoco.examples;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.jacoco.core.instr.CRC64;
+import org.objectweb.asm.ClassReader;
+
+/**
+ * This example reads given Java class files and calculates the CRC64
+ * identifiers which are used by JaCoCo.
+ *
+ * @author Marc R. Hoffmann
+ * @version $Revision: $
+ */
+public class ClassInfo {
+
+ /**
+ * Reads all class file specified as the arguments and dumps information
+ * about it to <code>stdout</code>.
+ *
+ * @param args
+ * list of class files
+ * @throws IOException
+ */
+ public static void main(final String[] args) throws IOException {
+ for (final String file : args) {
+ dumpInfo(file);
+ }
+ }
+
+ private static void dumpInfo(final String file) throws IOException {
+ final FileInputStream in = new FileInputStream(file);
+ final ClassReader reader = new ClassReader(in);
+ in.close();
+
+ System.out.printf("class file: %s%n", file);
+ System.out.printf("class name: %s%n", reader.getClassName());
+ final long id = CRC64.checksum(reader.b);
+ System.out.printf("class id: %016x%n%n", Long.valueOf(id));
+ }
+
+}
diff --git a/org.jacoco.examples/src/org/jacoco/examples/ExecDump.java b/org.jacoco.examples/src/org/jacoco/examples/ExecDump.java
new file mode 100644
index 0000000..b9e214d
--- /dev/null
+++ b/org.jacoco.examples/src/org/jacoco/examples/ExecDump.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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
+ *
+ * $Id: $
+ *******************************************************************************/
+package org.jacoco.examples;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Date;
+
+import org.jacoco.core.data.ExecutionDataReader;
+import org.jacoco.core.data.IExecutionDataVisitor;
+import org.jacoco.core.data.ISessionInfoVisitor;
+import org.jacoco.core.data.SessionInfo;
+
+/**
+ * This example reads given execution data files and dumps their content.
+ *
+ * @author Marc R. Hoffmann
+ * @version $Revision: $
+ */
+public class ExecDump {
+
+ /**
+ * Reads all execution data files specified as the arguments and dumps the
+ * content.
+ *
+ * @param args
+ * list of execution data files
+ * @throws IOException
+ */
+ public static void main(final String[] args) throws IOException {
+ for (final String file : args) {
+ dumpContent(file);
+ }
+ }
+
+ private static void dumpContent(final String file) throws IOException {
+ System.out.printf("exec file: %s%n", file);
+ System.out.println("CLASS ID HITS/PROBES CLASS NAME");
+
+ final FileInputStream in = new FileInputStream(file);
+ final ExecutionDataReader reader = new ExecutionDataReader(in);
+ reader.setSessionInfoVisitor(new ISessionInfoVisitor() {
+ public void visitSessionInfo(final SessionInfo info) {
+ System.out.printf("Session \"%s\": %s - %s%n", info.getId(),
+ new Date(info.getStartTimeStamp()), new Date(info
+ .getDumpTimeStamp()));
+ }
+ });
+ reader.setExecutionDataVisitor(new IExecutionDataVisitor() {
+ public void visitClassExecution(final long id, final String name,
+ final boolean[] data) {
+ System.out.printf("%016x %3d of %3d %s%n", Long.valueOf(id),
+ Integer.valueOf(getHitCount(data)), Integer
+ .valueOf(data.length), name);
+ }
+ });
+ reader.read();
+ in.close();
+ System.out.println();
+ }
+
+ private static int getHitCount(final boolean[] data) {
+ int count = 0;
+ for (final boolean hit : data) {
+ if (hit) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+}