aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataWriter.java
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2009-07-02 16:18:35 +0000
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2009-07-02 16:18:35 +0000
commit260360576d9196be16ae620dabbe3ba9c14ba220 (patch)
treeb07b817387b1b8d24a7ae4ab33df7d24d68b1659 /org.jacoco.core/src/org/jacoco/core/data/ExecutionDataWriter.java
parentf9511d641bf33397907e7e61b599fe0979225df2 (diff)
downloadjacoco-260360576d9196be16ae620dabbe3ba9c14ba220.tar.gz
Serialization mechanism for execution data.
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/data/ExecutionDataWriter.java')
-rw-r--r--org.jacoco.core/src/org/jacoco/core/data/ExecutionDataWriter.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataWriter.java b/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataWriter.java
new file mode 100644
index 00000000..3af80971
--- /dev/null
+++ b/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataWriter.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Mountainminds GmbH & Co. KG and others
+ * 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.core.data;
+
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Serialization of execution data into binary streams.
+ *
+ * TODO: Add "magic number" header protocol version, more efficient storage
+ *
+ * @author Marc R. Hoffmann
+ * @version $Revision: $
+ */
+public class ExecutionDataWriter implements IExecutionDataVisitor {
+
+ private final DataOutput output;
+
+ /**
+ * Creates a new writer based on the given data output.
+ *
+ * @param output
+ * data output to write execution data to
+ */
+ public ExecutionDataWriter(final DataOutput output) {
+ this.output = output;
+ }
+
+ /**
+ * Creates a new writer based on the given output stream.
+ *
+ * @param output
+ * binary stream to write execution data to
+ */
+ public ExecutionDataWriter(final OutputStream output) {
+ this.output = new DataOutputStream(output);
+ }
+
+ public void visitClassExecution(final long id, final boolean[][] blockdata) {
+ try {
+ output.writeLong(id);
+ output.writeInt(blockdata.length);
+ for (final boolean[] m : blockdata) {
+ output.writeInt(m.length);
+ for (final boolean b : m) {
+ output.writeBoolean(b);
+ }
+ }
+ } catch (final IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}