ClassNode.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.CounterEntity;
   19import org.jacoco.report.IReportVisitor;
   20
   21/**
   22 * Wrapper for an {@link XMLElement} that contains class coverage data
   23 * 
   24 * @author Brock Janiczak
   25 * @version $Revision: $
   26 */
   27public class ClassNode extends NodeWithCoverage {
   28    private static final CounterEntity[] CLASS_COUNTERS = {
   29            CounterEntity.METHOD, CounterEntity.BLOCK, CounterEntity.LINE,
   30            CounterEntity.INSTRUCTION, };
   31
   32    /**
   33     * Creates a new Class coverage element for the supplied package and class
   34     * coverage node
   35     * 
   36     * @param parent
   37     *            Parent element that will own this class element
   38     * @param classNode
   39     *            Class coverage node
   40     * @throws IOException
   41     *             IO Error creating the element
   42     */
   43    public ClassNode(final PackageNode parent, final ICoverageNode classNode)
   44            throws IOException {
   45        super(parent, "class", classNode);
   46    }
   47
   48    public IReportVisitor visitChild(final ICoverageNode node)
   49            throws IOException {
   50
   51        return new MethodNode(this, node);
   52    }
   53
   54    @Override
   55    protected CounterEntity[] getCounterEntities() {
   56        return CLASS_COUNTERS;
   57    }
   58
   59}