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