001/**
002 * www.jcoverage.com
003 * Copyright (C)2003 jcoverage ltd.
004 *
005 * This file is part of jcoverage.
006 *
007 * jcoverage is free software; you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published
009 * by the Free Software Foundation; either version 2 of the License,
010 * or (at your option) any later version.
011 *
012 * jcoverage is distributed in the hope that it will be useful, but
013 * WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with jcoverage; if not, write to the Free Software
019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020 * USA
021 *
022 */
023package com.jcoverage.coverage.reporting.html;
024
025import java.io.*;
026import java.util.*;
027
028import org.apache.log4j.Logger;
029
030import com.jcoverage.coverage.reporting.collation.JavaFileLine;
031import com.jcoverage.coverage.reporting.collation.JavaFilePage;
032import com.jcoverage.coverage.reporting.collation.PackageSummaryPage;
033import com.jcoverage.reporting.FormattingContext;
034import com.jcoverage.reporting.Page;
035import com.jcoverage.reporting.ReportingException;
036import com.jcoverage.reporting.ViewFormattingContext;
037import com.jcoverage.reporting.html.*;
038import com.jcoverage.reporting.html.AbstractHtmlFormat;
039import com.jcoverage.reporting.html.HtmlFormatHelper;
040
041/**
042 *
043 */
044public class JavaFilePageFormat extends CommonFormat {
045  
046  static Logger logger=Logger.getLogger(JavaFilePageFormat.class);
047  
048  public void formatPage(ViewFormattingContext ctx,Page abstractPage) throws ReportingException {
049    throw new IllegalStateException(getClass().getName()+" formatPage method does not handle views");
050  }
051
052  public void formatPage(FormattingContext ctx,Page abstractPage) throws ReportingException {
053
054    JavaFilePage page=(JavaFilePage)abstractPage;
055    JavaFileLine masterLine=page.getJavaFileLine();
056
057    String name=(String)page.getMasterLine().getField(JavaFileLine.COLUMN_FILE_NAME);
058
059    Html html=new Html();
060    html.setTitle("jcoverage details for "+name);
061    buildHeader(html);
062
063    NavigationBar navbar=new NavigationBar(ctx,page);
064    html.add(navbar);
065
066    html.add(new H1("Coverage details for "+name));
067    html.add(new SourceTable(masterLine.getSourceFile(),page));
068
069    html.add("<p>");
070    html.add(navbar);
071    buildFooter(html);
072    html.writeTo(getWriter(ctx,page));
073  }
074  
075}