Return-Path: Delivered-To: apmail-maven-m2-dev-archive@www.apache.org Received: (qmail 67726 invoked from network); 22 Feb 2005 01:48:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 22 Feb 2005 01:48:31 -0000 Received: (qmail 10263 invoked by uid 500); 22 Feb 2005 01:48:31 -0000 Delivered-To: apmail-maven-m2-dev-archive@maven.apache.org Received: (qmail 10248 invoked by uid 500); 22 Feb 2005 01:48:30 -0000 Mailing-List: contact m2-dev-help@maven.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: "Maven 2 Developers List" Reply-To: "Maven 2 Developers List" Delivered-To: mailing list m2-dev@maven.apache.org Received: (qmail 10235 invoked by uid 500); 22 Feb 2005 01:48:30 -0000 Delivered-To: apmail-maven-components-cvs@apache.org Received: (qmail 10232 invoked by uid 99); 22 Feb 2005 01:48:30 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 21 Feb 2005 17:48:29 -0800 Received: (qmail 67701 invoked by uid 1717); 22 Feb 2005 01:48:28 -0000 Date: 22 Feb 2005 01:48:28 -0000 Message-ID: <20050222014828.67700.qmail@minotaur.apache.org> From: brett@apache.org To: maven-components-cvs@apache.org Subject: cvs commit: maven-components/maven-reporting-api/src/main/java/org/apache/maven/reporting AbstractMavenReportRenderer.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N brett 2005/02/21 17:48:28 Added: maven-reporting-api/src/main/java/org/apache/maven/reporting AbstractMavenReportRenderer.java Log: add abstract renderer from doxia Revision Changes Path 1.1 maven-components/maven-reporting-api/src/main/java/org/apache/maven/reporting/AbstractMavenReportRenderer.java Index: AbstractMavenReportRenderer.java =================================================================== package org.apache.maven.reporting; /* * Copyright 2004-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.doxia.sink.Sink; /** * @author Jason van Zyl * @version $Id: AbstractMavenReportRenderer.java,v 1.1 2005/02/22 01:48:27 brett Exp $ */ public abstract class AbstractMavenReportRenderer { protected Sink sink; private int section = 0; public AbstractMavenReportRenderer( Sink sink ) { this.sink = sink; } public void render() { sink.head(); sink.title(); sink.text( getTitle() ); sink.title_(); sink.head_(); sink.body(); renderBody(); sink.body_(); } protected void startTable() { sink.table(); } protected void endTable() { sink.table_(); } protected void startSection( String name ) { section = section + 1; switch ( section ) { case 1: sink.section1(); break; case 2: sink.section2(); break; case 3: sink.section3(); break; case 4: sink.section4(); break; case 5: sink.section5(); break; default: // TODO: warning - just don't start a section break; } sink.sectionTitle(); sink.text( name ); sink.sectionTitle_(); } protected void endSection() { switch ( section ) { case 1: sink.section1_(); break; case 2: sink.section2_(); break; case 3: sink.section3_(); break; case 4: sink.section4_(); break; case 5: sink.section5_(); break; default: // TODO: warning - just don't start a section break; } section = section - 1; if ( section < 0 ) { throw new IllegalStateException( "Too many closing sections" ); } } protected void tableHeaderCell( String text ) { sink.tableHeaderCell(); sink.text( text ); sink.tableHeaderCell_(); } protected void tableCell( String text ) { sink.tableCell(); sink.text( text ); sink.tableCell_(); } protected void tableRow( String[] content ) { sink.tableRow(); for ( int i = 0; i < content.length; i++ ) { tableCell( content[i] ); } sink.tableRow_(); } protected void tableHeader( String[] content ) { sink.tableRow(); for ( int i = 0; i < content.length; i++ ) { tableHeaderCell( content[i] ); } sink.tableRow_(); } protected abstract String getTitle(); protected abstract void renderBody(); protected void tableCaption( String caption ) { sink.tableCaption(); sink.text( caption ); sink.tableCaption_(); } }