XMLReportFile.java
1/*******************************************************************************
2 * Copyright (c) 2009 Mountainminds GmbH & Co. KG and others
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Brock Janiczak -initial API and implementation
10 *
11 * $Id: $
12 *******************************************************************************/
13package org.jacoco.report.xml;
14
15import java.io.IOException;
16import java.io.OutputStream;
17
18import org.jacoco.core.analysis.ICoverageNode;
19import org.jacoco.report.IReportVisitor;
20import org.jacoco.report.ISourceFileLocator;
21
22/**
23 * Report visitor that will generate an XML report of the coverage data
24 *
25 * @author Brock Janiczak
26 * @version $Revision: $
27 */
28public class XMLReportFile extends XMLDocument implements IReportVisitor {
29
30 private static final String ROOT = "report";
31
32 private static final String PUBID = "-//JACOCO//DTD Report 1.0//EN";
33
34 private static final String SYSTEM = "report.dtd";
35
36 /**
37 * Creates a new Report file
38 *
39 * @param output
40 * Report output
41 * @param encoding
42 * Encoding of the XML file
43 * @throws IOException
44 * IO Error creating report file
45 */
46 public XMLReportFile(final String encoding, final OutputStream output)
47 throws IOException {
48 super(ROOT, PUBID, SYSTEM, encoding, true, output);
49 }
50
51 public IReportVisitor visitChild(final ICoverageNode node)
52 throws IOException {
53 return new GroupNode(this, node);
54 }
55
56 public void visitEnd(final ISourceFileLocator sourceFileLocator)
57 throws IOException {
58 this.close();
59 }
60
61}