IReportVisitor.java

    1/*******************************************************************************
    2 * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors
    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 *    Marc R. Hoffmann - initial API and implementation
   10 *    
   11 *******************************************************************************/
   12package org.jacoco.report;
   13
   14import java.io.IOException;
   15
   16import org.jacoco.core.analysis.ICoverageNode;
   17
   18/**
   19 * Output-Interface for hierarchical coverage data information. To allow data
   20 * streaming and to save memory {@link ICoverageNode}s are traversed in a
   21 * deep-first fashion. The interface is implemented by the different report
   22 * writers.
   23 * 
   24 * @author Marc R. Hoffmann
   25 * @version 0.4.1.20101007204400
   26 */
   27public interface IReportVisitor {
   28
   29    /**
   30     * Visitor without any operation.
   31     */
   32    public static final IReportVisitor NOP = new IReportVisitor() {
   33
   34        public IReportVisitor visitChild(final ICoverageNode node) {
   35            return NOP;
   36        }
   37
   38        public void visitEnd(final ISourceFileLocator sourceFileLocator) {
   39        }
   40
   41    };
   42
   43    /**
   44     * Called for every direct child.
   45     * 
   46     * @param node
   47     *            Node for the child in the implementation class specific to
   48     *            this type. The counters are may yet be populated.
   49     * 
   50     * @return visitor instance for processing the child node
   51     * 
   52     * @throws IOException
   53     *             in case of IO problems with the report writer
   54     */
   55    IReportVisitor visitChild(ICoverageNode node) throws IOException;
   56
   57    /**
   58     * Called at the very end, when all child node have been processed and the
   59     * counters for this node are properly populated.
   60     * 
   61     * @param sourceFileLocator
   62     *            source file locator valid for this node
   63     * @throws IOException
   64     *             in case of IO problems with the report writer
   65     */
   66    void visitEnd(ISourceFileLocator sourceFileLocator) throws IOException;
   67
   68}