maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-reporting-api/src/main/java/org/apache/maven/reporting AbstractMavenReportRenderer.java
Date Tue, 22 Feb 2005 01:48:28 GMT
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 <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @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_();
      }
  }
  
  
  

Mime
View raw message