PackageNode.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;
16
17import org.jacoco.core.analysis.ICoverageNode;
18import org.jacoco.core.analysis.ICoverageNode.ElementType;
19import org.jacoco.report.IReportVisitor;
20import org.jacoco.report.ISourceFileLocator;
21
22/**
23 * Wrapper for an {@link XMLElement} that contains package coverage data
24 *
25 * @author Brock Janiczak
26 * @version $Revision: $
27 */
28public class PackageNode extends NodeWithCoverage {
29
30 /**
31 * Creates a new Package coverage element under the supplied group element
32 *
33 * @param parent
34 * Parent element that will own this class element
35 * @param packageNode
36 * Package coverage node
37 * @throws IOException
38 * IO Error creating the element
39 */
40 public PackageNode(final GroupNode parent, final ICoverageNode packageNode)
41 throws IOException {
42 super(parent, "package", packageNode);
43 }
44
45 public IReportVisitor visitChild(final ICoverageNode node)
46 throws IOException {
47 if (node.getElementType() == ElementType.CLASS) {
48 return new ClassNode(this, node);
49 } else if (node.getElementType() == ElementType.SOURCEFILE) {
50 return new IReportVisitor() {
51
52 public void visitEnd(final ISourceFileLocator sourceFileLocator)
53 throws IOException {
54 }
55
56 public IReportVisitor visitChild(final ICoverageNode node)
57 throws IOException {
58 return this;
59 }
60 };
61 }
62 return null;
63 }
64
65}