You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2002/02/23 21:18:08 UTC

cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/jxr/util FileUtils.java MetaData.java SimpleWordTokenizer.java StringEntry.java StringUtil.java Util.java

jvanzyl     02/02/23 12:18:08

  Added:       src/java/org/apache/maven/jxr CodeTransform.java
                        DirectoryIndexer.java JXR.java JxrTask.java
               src/java/org/apache/maven/jxr/pacman BaseType.java
                        ClassType.java FileManager.java ImportType.java
                        JavaFile.java JavaFileImpl.java PackageManager.java
                        PackageType.java
               src/java/org/apache/maven/jxr/util FileUtils.java
                        MetaData.java SimpleWordTokenizer.java
                        StringEntry.java StringUtil.java Util.java
  Log:
  - got the cross referencer to work with the maven object model instead
    of the generated alexandria one. not terribly pretty and it definitely
    needs some work but it cross references within maven.
  
    Josh Lucas will probably be interested in this.
  
    I'm going to integrate this into the build-docs.xml and republish the
    site.
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/CodeTransform.java
  
  Index: CodeTransform.java
  ===================================================================
  /*
   * CodeViewer.java
   * CoolServlets.com
   * March 2000
   *
   * Copyright (C) 2000 CoolServlets.com
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions are met:
   * 1) Redistributions of source code must retain the above copyright notice,
   *   this list of conditions and the following disclaimer.
   * 2) Redistributions in binary form must reproduce the above copyright notice,
   *   this list of conditions and the following disclaimer in the documentation
   *   and/or other materials provided with the distribution.
   * 3) Neither the name CoolServlets.com nor the names of its contributors may be
   *   used to endorse or promote products derived from this software without
   *   specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY COOLSERVLETS.COM AND CONTRIBUTORS ``AS IS'' AND
   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL COOLSERVLETS.COM OR CONTRIBUTORS BE LIABLE FOR
   * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
  package org.apache.maven.jxr;
  
  //alexandria stuff
  import org.apache.maven.jxr.util.*;
  import org.apache.maven.jxr.pacman.*;
  
  
  //java stuff
  import java.io.*;
  import java.util.*;
  import java.text.*;
  
  /**
   * Syntax highlights java by turning it into html.
   *
   * A codeviewer object is created and then keeps state as lines are passed
   * in. Each line passed in as java test, is returned as syntax highlighted
   * html text.
   *
   * Users of the class can set how the java code will be highlighted with setter
   * methods.
   *
   * Only valid java lines should be passed in since the object maintains state
   * and may not handle illegal code gracefully.
   *
   * The actual system is implemented as a series of filters that deal with
   * specific portions of the java code. The filters are as follows:
   *
   * <pre>
   *  htmlFilter
   *     |__
   *        multiLineCommentFilter -> uriFilter
   *           |___
   *                inlineCommentFilter
   *                   |___
   *                        stringFilter
   *                           |__
   *                               keywordFilter
   *                                   |__
   *                                      uriFilter
   *                                        |__
   *                                          jxrFilter
   *                                            |__
   *                                               importFilter
   * </pre>
   */
  public class CodeTransform implements Serializable {
  
      public static final boolean LINE_NUMBERS            = true;
      
      public static final String BACKGROUND_COLOR         = "#ffffff";
  
  
  
      public static final String COMMENT_START            = "<font color=\"#329900\"><i>";
  
      public static final String COMMENT_END              = "</font></i>";    
      
      public static final String JAVADOC_COMMENT_START    = "<font color=\"#AA0000\"><i>";
  
      public static final String JAVADOC_COMMENT_END      = "</font></i>";    
  
  
      
  
      public static final String STRING_START             = "<font color=\"#000099\">";
  
      public static final String STRING_END               = "</font>";
  
      public static final String RESERVED_WORD_START      = "<b>";
  
      public static final String RESERVED_WORD_END        = "</b>";
  
      public static final String[] VALID_URI_SCHEMES      = { "http://", "mailto:" };
  
      /**
      Specify the only characters that are allowed in a URI besides alpha and
      numeric characters.
      */
      public static final char[] VALID_URI_CHARS          = { '?', '+', '%', '&', ':', '/', '.', '@', '_' };
      
      private BufferedReader in;
      private StringBuffer out;
      //private HashMap reservedWords = new HashMap();
      private Hashtable reservedWords = new Hashtable();
  
      private boolean inMultiLineComment      = false;
  
      private boolean inJavadocComment      = false;
      
      /**
      Keep a handle on the current metadata
      */
      private MetaData metadata;
  
  
      /**
      Set the filename that is currently being processed.
      */
      private String currentFilename = null;
  
      /**
      The current CVS revision of the currently transformed documnt
      */
      private String revision = null;
      
      /**
      The currently being transformed source file
      */
      private String sourcefile = null;
      
      /**
      The currently being written destfile
      */
      private String destfile = null;
      
      /**
      The virtual source directory that is being read from: src/java
      */
      private String sourcedir = null;
      
      
      public CodeTransform() {
          loadHash();
      }
      /*
      public void setCommentStart(String COMMENT_START) {
          this.COMMENT_START = COMMENT_START;
      }
  
      public void setCommentEnd(String COMMENT_END) {
          this.COMMENT_END = COMMENT_END;
      }
  
      public void setStringStart(String STRING_START) {
          this.STRING_START = STRING_START;
      }
  
      public void setStringEnd(String STRING_END) {
          this.STRING_END = STRING_END;
      }
  
      public void setReservedWordStart(String RESERVED_WORD_START) {
          this.RESERVED_WORD_START = RESERVED_WORD_START;
      }
  
      public void setReservedWordEnd(String RESERVED_WORD_END) {
          this.RESERVED_WORD_END = RESERVED_WORD_END;
      }
  
      public String getCommentStart() { return COMMENT_START; }
      public String getCommentEnd() { return COMMENT_END; }
      public String getStringStart() { return STRING_START; }
      public String getStringEnd() { return STRING_END; }
      public String getReservedWordStart() { return RESERVED_WORD_START; }
      public String getReservedWordEnd() { return RESERVED_WORD_END; }
      */
      /**
       * Now different method of seeing if at end of input stream,
       * closes inputs stream at end.
       */
      public final String syntaxHighlight(String line) {
         return htmlFilter(line);
      }
  
      /**
       * Filter html tags into more benign text.
       */ 
      private final String htmlFilter( String line ) {
          StringBuffer buf = new StringBuffer();
          if( line == null || line.equals("") ) {
              return "";
          }
          line = replace(line,"<","&lt;");
          line = replace(line,">","&gt;");
          line = replace( line, "\\\\", "&#47;&#47;" );
          line = replace( line, "\\\"", "\\&quot;" );
          line = replace( line, "'\"'", "'&quot;'" );
          return multiLineCommentFilter(line);
      }
  
      
      
      /**
       * Filter out multiLine comments. State is kept with a private boolean
       * variable.
       */     
      private final String multiLineCommentFilter(String line) {
          if (line == null || line.equals("")) {
              return "";
          }
          StringBuffer buf = new StringBuffer();
          int index;
  
  
          
          //First, check for the end of a java comment.
          if ( inJavadocComment && 
              (index = line.indexOf("*/")) > -1 && !isInsideString(line,index) ) {
              inJavadocComment = false;               
              buf.append( JAVADOC_COMMENT_START );
              buf.append( line.substring(0,index) );
              buf.append("*/").append( JAVADOC_COMMENT_END );
              if (line.length() > index + 2) {
                  buf.append( inlineCommentFilter( line.substring( index + 2 ) ) );
              }
  
              return uriFilter( buf.toString() );
          }
          
          
          
          //Second, check for the end of a multi-line comment.
          if (inMultiLineComment && (index = line.indexOf("*/")) > -1 && !isInsideString(line,index)) {
              inMultiLineComment = false;               
              buf.append( COMMENT_START );
              buf.append(line.substring(0,index));
              buf.append("*/").append( COMMENT_END );
              if (line.length() > index+2) {
                  buf.append(inlineCommentFilter(line.substring( index + 2)));
              }
              return uriFilter( buf.toString() );
          } 
  
          //If there was no end detected and we're currently in a multi-line
          //comment, we don't want to do anymore work, so return line.
          else if (inMultiLineComment) {
  
              StringBuffer buffer = new StringBuffer( line );
              buffer.insert(0, COMMENT_START );
              buffer.append( COMMENT_END );
              return uriFilter( buffer.toString() );
          } 
          
          else if (inJavadocComment) {
  
              StringBuffer buffer = new StringBuffer( line );
              buffer.insert(0, JAVADOC_COMMENT_START );
              buffer.append( JAVADOC_COMMENT_END );
              return uriFilter( buffer.toString() );
  
          }
  
          //We're not currently in a Javadoc comment, so check to see if the start
          //of a multi-line Javadoc comment is in this line.
          else if ((index = line.indexOf("/**")) > -1 && !isInsideString( line,index )) {
              inJavadocComment = true;
              //Return result of other filters + everything after the start
              //of the multiline comment. We need to pass the through the
              //to the multiLineComment filter again in case the comment ends
              //on the same line.
              buf.append( inlineCommentFilter(line.substring(0,index)) );
              buf.append( JAVADOC_COMMENT_START ).append("/**");
              buf.append( multiLineCommentFilter( line.substring( index+2 ) ) );
              buf.append( JAVADOC_COMMENT_END );
              return uriFilter( buf.toString() );
          }
          
          //We're not currently in a comment, so check to see if the start
          //of a multi-line comment is in this line.
          else if ((index = line.indexOf("/*")) > -1 && !isInsideString(line,index)) {
              inMultiLineComment = true;
              //Return result of other filters + everything after the start
              //of the multiline comment. We need to pass the through the
              //to the multiLineComment filter again in case the comment ends
              //on the same line.
              buf.append(inlineCommentFilter(line.substring(0,index)));
              buf.append(COMMENT_START).append("/*");
              buf.append( multiLineCommentFilter(line.substring(index+2)) );
              buf.append( COMMENT_END );
              return uriFilter( buf.toString() );
          }
  
  
          //Otherwise, no useful multi-line comment information was found so
          //pass the line down to the next filter for processesing.
          else {
              return inlineCommentFilter(line);
          }
      }      
  
      /**
       * Filter inline comments from a line and formats them properly.
       *
       * One problem we'll have to solve here: comments contained in a string
       * should be ignored... this is also true of the multiline comments. So,
       * we could either ignore the problem, or implement a function called
       * something like isInsideString(line, index) where index points to
       * some point in the line that we need to check... started doing this
       * function below.
       */
      private final String inlineCommentFilter(String line) {
          if (line == null || line.equals("")) {
              return "";
          }
          StringBuffer buf = new StringBuffer();
          int index;
          if ( (index = line.indexOf("//")) > -1 && !isInsideString(line,index) ) {
              buf.append(stringFilter(line.substring(0,index)));
              buf.append(COMMENT_START);
              buf.append(line.substring(index));
              buf.append(COMMENT_END);
          }
          else {
              buf.append(stringFilter(line));
          }
          return buf.toString();
      } 
  
      /**
       * Filters strings from a line of text and formats them properly.
       */
      private final String stringFilter(String line) {
  
          if (line == null || line.equals("")) {
              return "";
          }
          StringBuffer buf = new StringBuffer();
          if (line.indexOf("\"") <= -1) {
              return keywordFilter(line);
          }
          int start = 0;
          int startStringIndex = -1;
          int endStringIndex = -1;
          int tempIndex;
          //Keep moving through String characters until we want to stop...
          while ((tempIndex = line.indexOf("\"")) > -1) {
              //We found the beginning of a string
              if (startStringIndex == -1) {
                  startStringIndex = 0;
                  buf.append( stringFilter(line.substring(start,tempIndex)) );
                  buf.append(STRING_START).append("\"");
                  line = line.substring(tempIndex+1);
              }
              //Must be at the end
              else {
                  startStringIndex = -1;
                  endStringIndex = tempIndex;
                  buf.append(line.substring(0,endStringIndex+1));
                  buf.append(STRING_END);
                  line = line.substring(endStringIndex+1);
              }
          }
  
          buf.append( keywordFilter(line) );
  
          return buf.toString();
  
      }
  
      /**
       * Filters keywords from a line of text and formats them properly.
       */
      private final String keywordFilter( String line ) {
          if( line == null || line.equals("") ) {
              return "";
          }
          StringBuffer buf = new StringBuffer();
          //HashMap usedReservedWords = new HashMap();
          Hashtable usedReservedWords = new Hashtable();
          int i=0, startAt=0;
          char ch;
          StringBuffer temp = new StringBuffer();
          while( i < line.length() ) {
              temp.setLength(0);
              ch = line.charAt(i);
              startAt = i;
              while( i<line.length() && ( ( ch >= 65 && ch <= 90 )
                      || ( ch >= 97 && ch <= 122 ) ) ) {
                  temp.append(ch);
                  i++;
                  if( i < line.length() ) {
                      ch = line.charAt(i);
                  }
              }
              String tempString = temp.toString();
              if( reservedWords.containsKey(tempString) && !usedReservedWords.containsKey(tempString)) {
                  usedReservedWords.put(tempString,tempString);
                  line = replace( line, tempString, ( RESERVED_WORD_START + tempString + RESERVED_WORD_END ) );
                  i += (RESERVED_WORD_START.length() + RESERVED_WORD_END.length());
              }
              else {
                  i++;
              }            
          }
          buf.append(line);
          return uriFilter( buf.toString() );
      }
  
      /**
       *  Replace...
       *
       *  I made it use a stringBuffer... hope it still works :)
       */
      private final String replace( String line, String oldString, String newString ) {
          int i=0;
          while( ( i=line.indexOf( oldString, i ) ) >= 0 ) {
              line = (new StringBuffer().append(line.substring(0,i)).append(newString).append(line.substring(i+oldString.length()))).toString();
              i += newString.length();
          }
          return line;
      }
  
      /**
       * Checks to see if some position in a line is between String start and
       * ending characters. Not yet used in code or fully working :)
       */
      private final boolean isInsideString(String line, int position) {
          if (line.indexOf("\"") < 0) {
              return false;
          }
          int index;
          String left = line.substring(0,position);
          String right = line.substring(position);
          int leftCount = 0;
          int rightCount = 0;
          while ((index = left.indexOf("\"")) > -1) {
              leftCount ++;
              left = left.substring(index+1); 
          }
          while ((index = right.indexOf("\"")) > -1) {
              rightCount ++;
              right = right.substring(index+1); 
          }
          if (rightCount % 2 != 0 && leftCount % 2 != 0) {
              return true;
          }
          else {
              return false;
          }        
      }
  
      private final void loadHash() {
          reservedWords.put( "abstract", "abstract" );
          reservedWords.put( "do", "do" );
          reservedWords.put( "inner", "inner" );
          reservedWords.put( "public", "public" );
          reservedWords.put( "var", "var" );
          reservedWords.put( "boolean", "boolean" );
          reservedWords.put( "continue", "continue" );
          reservedWords.put( "int", "int" );
          reservedWords.put( "return", "return" );
          reservedWords.put( "void", "void" );
          reservedWords.put( "break", "break" );
          reservedWords.put( "else", "else" );
          reservedWords.put( "interface", "interface" );
          reservedWords.put( "short", "short" );
          reservedWords.put( "volatile", "volatile" );
          reservedWords.put( "byvalue", "byvalue" );
          reservedWords.put( "extends", "extends" );
          reservedWords.put( "long", "long" );
          reservedWords.put( "static", "static" );
          reservedWords.put( "while", "while" );
          reservedWords.put( "case", "case" );
          reservedWords.put( "final", "final" );
          reservedWords.put( "naive", "naive" );
          reservedWords.put( "super", "super" );
          reservedWords.put( "transient", "transient" );
          reservedWords.put( "cast", "cast" );
          reservedWords.put( "float", "float" );
          reservedWords.put( "new", "new" );
          reservedWords.put( "rest", "rest" );
          reservedWords.put( "catch", "catch" );
          reservedWords.put( "for", "for" );
          reservedWords.put( "null", "null" );
          reservedWords.put( "synchronized", "synchronized" );
          reservedWords.put( "char", "char" );
          reservedWords.put( "finally", "finally" );
          reservedWords.put( "operator", "operator" );
          reservedWords.put( "this", "this" );
          reservedWords.put( "class", "class" );
          reservedWords.put( "generic", "generic" );
          reservedWords.put( "outer", "outer" );
          reservedWords.put( "switch", "switch" );
          reservedWords.put( "const", "const" );
          reservedWords.put( "goto", "goto" );
          reservedWords.put( "package", "package" );
          reservedWords.put( "throw", "throw" );
          reservedWords.put( "double", "double" );
          reservedWords.put( "if", "if" );
          reservedWords.put( "private", "private" );
          reservedWords.put( "true", "true" );
          reservedWords.put( "default", "default" );
          reservedWords.put( "import", "import" );
          reservedWords.put( "protected", "protected" );
          reservedWords.put( "try", "try" );
      }
  
      final void writeObject(ObjectOutputStream oos) throws IOException {
          oos.defaultWriteObject();
      }
  
      final void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
          ois.defaultReadObject();
      }
  
      public final String getHeader() {
  
          //FIX ME: migrate this to use ECS
          return "<html>\n" +
                 "<body bgcolor=\"white\">\n" +
                 "<pre>\n" + this.getFileOverview();
      }
      
      public final String getFooter() {
  
          //FIX ME: migrate this to use ECS
          return "</pre>\n" +
                 "<hr>" + 
                 "<center>" + JXR.NOTICE + "</center>" +
                 "</body>\n" +
                 "</html>\n";
      }
  
      
      
      /**
      This is the public method for doing all transforms of code.
  
      */
      public final void transform( String sourcefile, 
                             String destfile,
                             String revision,
                             String sourcedir,
                             MetaData metadata ) 
          throws IOException 
      {
  
          this.setCurrentFilename( sourcefile );
          
          this.sourcefile = sourcefile;
          this.destfile = destfile;
          this.revision = revision;
          this.sourcedir = sourcedir;
          this.metadata = metadata;
          
          //make sure that the parent directories exist...
          new File( new File( destfile).getParent() ).mkdirs();
  
          
          BufferedReader in = new BufferedReader( new FileReader( sourcefile ) );;
          PrintWriter out = new PrintWriter( new FileWriter( destfile ) );
          
          String line = "";
  
          out.println( getHeader() );
  
          int linenumber = 1;
          while ( (line = in.readLine()) != null ) {
             if ( LINE_NUMBERS ) {
                  out.print( "<a name=\"" +  linenumber + "\" " +
                             "href=\"#" + linenumber + "\">" +
                             linenumber + 
                             "</a>" + getLineWidth( linenumber ) );
             }
  
             out.println( this.syntaxHighlight( line ) );
  
             ++linenumber;
          }
  
          out.println( getFooter() );        
          out.flush();
          
      }
  
      /**
      Get an overview header for this file.
      */
      private final String getFileOverview() {
          StringBuffer overview = new StringBuffer();
  
  
          overview.append( "<table bgcolor=\"#FFFFCC\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">" );
          
  
              
          //get the URI to get Javadoc info.
          StringBuffer javadocURI = new StringBuffer()
                  .append( getPackageRoot() )
                  .append( "../javadoc/" )
                  .append( this.metadata.getProject().getModule() )
                  .append( "/" )
                  .append( this.getRevision() );
         
          try {
              JavaFile jf = FileManager.getInstance().getFile( this.getCurrentFilename() );
  
              javadocURI.append( "/" );
              javadocURI.append( Util.replace( jf.getPackageType().getName(), ".", "/" ) );
              javadocURI.append( "/" );
              if(jf.getClassType()!=null){
                  javadocURI.append( jf.getClassType().getName() );
              }else{
                  System.out.println(this.getCurrentFilename());
              }
              javadocURI.append( ".html" );
              
          } catch ( IOException e ) {
              e.printStackTrace();
          }
          
          
          String javadocHREF = "<a href=\"" + javadocURI + "\">View Javadoc</a>";
                              
          
          //get the URI to download this file.
          /*
          StringBuffer sourceURI = new StringBuffer()
              .append( this.getPackageRoot() )
              .append( "../../cvs/" )
              .append( this.metadata.getModule().getCvsModuleName() )
              .append( "/" )
              .append( this.getRevision() )
              .append( "/" )
              .append( this.metadata.getModule().getCvsModuleName() )
              .append( "/" )
              .append( this.getSourceDirectory() )
              .append( "/" );
              
          try {
              JavaFile jf = FileManager.getInstance().getFile( this.getCurrentFilename() );
  
              javadocURI.append( new StringUtil( jf.getPackageType().getName() ).replace( ".", "/" ).toString() );
              javadocURI.append( "/" );
              javadocURI.append( jf.getClassType().getName() );
              javadocURI.append( ".html" );
              
          } catch ( IOException e ) {
              e.printStackTrace();
          }
              
              
                  
          String sourceHREF = "<a href=\"" + sourceURI.toString() + "\">View Source</a>";
          */
          
          //get the generation time...
          overview.append( getOverviewEntry( "Last generated on: ", 
                                              DateFormat.getDateTimeInstance().format( new Date() ),
                                              javadocHREF ) );
  
          String home = "";
          
          if( this.metadata.getProject().getHomePage() != null ) {
              home = this.metadata.getProject().getHomePage();
          } else if ( this.metadata.getRepository().getHomePage() != null ) {
              home = this.metadata.getRepository().getHomePage();
          }
          
          home = "<a href=\"" + home + "\">" + home + "</a>";
          
          overview.append( getOverviewEntry( "Home: ", home ) );
                                              
          overview.append( getOverviewEntry( "License: " , this.metadata.getProject().getLicense() ) );
          overview.append( getOverviewEntry( "CVSROOT: ", this.metadata.getRepository().getRoot() ) );
          overview.append( getOverviewEntry( "Module: ", this.metadata.getProject().getModule() ) );
                                              
                                              
          overview.append( "</table>" );
          return overview.toString();
      }
  
      private final String getOverviewEntry( String name, String value ) {
  
          StringBuffer buff = new StringBuffer();
          
          buff.append( "<tr>" );
  
          buff.append( "<td NOWRAP>" );
          buff.append( "<b>" + name + "</b> " );
          buff.append( "</td>" );
         
          //border...
  
          buff.append( "<td width=\"30\" NOWRAP>&nbsp;</td>" );
  
  
          buff.append( "<td width=\"100%\" colspan=\"2\"NOWRAP>" );        
          
          buff.append( value );
          
          buff.append( "</td>" );
  
          buff.append( "</tr>" );
          
          return buff.toString();
      }
  
      private final String getOverviewEntry( String name, String value, String right ) {
          
  
          StringBuffer buff = new StringBuffer();
          
          buff.append( "<tr>" );
  
          buff.append( "<td NOWRAP>" );
          buff.append( "<b>" + name + "</b> " );
          buff.append( "</td>" );
         
          //border...
  
          buff.append( "<td width=\"30\" NOWRAP>&nbsp;</td>" );
  
  
          buff.append( "<td width=\"100%\" NOWRAP>" );        
          
          buff.append( value );
          
          buff.append( "</td>" );
  
  
          //BEGIN RIGHT SIDE
          
          buff.append( "<td width=\"100%\" align=\"right\" NOWRAP>" );
          
          buff.append( right );
          
          buff.append( "&nbsp;&nbsp;</td>" );
          
          
          //END RIGHT SIDE
          
          buff.append( "</tr>" );
          
          return buff.toString();
          
      }
      
      /**
      Handles line width which may need to change depending on which line number you are on.
      */
      private final String getLineWidth( int linenumber ) {
          if ( linenumber < 10 ) {
              return "   ";            
          } else if ( linenumber < 100 ) {
              return "  ";
          } else {
              return " ";
          }
      }
      
      /**
      Handles finding classes based on the current filename and then makes HREFs 
      for you to link to them with.
      */
      private final String jxrFilter( String line ) {
  
          JavaFile jf = null;
          
          try {
  
              //if the current file isn't set then just return
              if ( this.getCurrentFilename() == null ) { 
                  return line;
              }
  
              jf = FileManager.getInstance().getFile( this.getCurrentFilename() );
          } catch ( IOException e ) {
              e.printStackTrace();
              return line;
          }
          
  
          Vector v = new Vector();
  
          //get the imported packages
          ImportType[] imports = jf.getImportTypes();
          for ( int j = 0; j < imports.length; ++j ) {
              v.addElement( imports[j].getPackage() );
          }
              
          //add the current package.
          v.addElement( jf.getPackageType().getName() );
  
          String[] packages = new String[v.size()];
          v.copyInto( packages );
  
          
          StringEntry[] words = SimpleWordTokenizer.tokenize( line );
          
          //go through each word and then match them to the correct class if necessary.
          for ( int i = 0; i < words.length; ++i ) {
              
              //each word
              StringEntry word = words[i];
              
              for ( int j = 0; j < packages.length; ++j ) {
  
                  //get the package from teh PackageManager because this will hold
                  //the version with the classes also.
  
                  PackageType currentImport = PackageManager.getInstance()
                      .getPackageType( packages[j] );
  
                  //the package here might in fact be null because it wasn't parsed out
                  //this might be something that is either not included or os part
                  //of another package and wasn't parsed out.
                  
                  if ( currentImport == null ) {
                      continue;
                  }
                      
  
                  //see if the current word is within the package 
                  
                  
                  //at this point the word could be a fully qualified package name
                  //(FQPN) or an imported package name.
  
                  String wordName = word.toString();
                  
                 
                  if ( wordName.indexOf( "." ) != -1 ) {
                      
                      //if there is a "." in the string then we have to assume
                      //it is a package.
  
                      //System.out.println( "FIX ME: Currently working in package mode" );
  
                      
                      String fqpn_package = null;
                      String fqpn_class = null;
                      
                      fqpn_package = wordName.substring( 0, wordName.lastIndexOf( "." ) );
                      fqpn_class = wordName.substring( wordName.lastIndexOf( "." ) + 1, wordName.length() );
  
                      //System.out.println( "fqpn_package -> " + fqpn_package );
                      //System.out.println( "fqpn_class -> " + fqpn_class );                    
                      
                      //note. since this is a reference to a full package then 
                      //it doesn't have to be explicitly imported so this information
                      //is useless.  Instead just see if it was parsed out.
                      
                      PackageType pt = PackageManager.getInstance().getPackageType( fqpn_package );
                      
                      if ( pt != null ) {
                          
                          ClassType ct = pt.getClassType( fqpn_class );
                          
                          if ( ct != null ) {
                              //OK.  the user specified a full package to be imported
                              //that is in the package manager so it is time to 
                              //link to it.
                              
                              //System.out.println( "FIX ME:  Found explicit class reference: " + wordName );
                              line = xrLine( line, pt.getName(), ct );
                              
                          }
                          
                      }
                      
                      if ( fqpn_package.equals( currentImport.getName() ) &&
                           currentImport.getClassType( fqpn_class ) != null ) { 
  
                          //then the package we are currently in is the one specified in the string
                          //and the import class is correct.
  
                          //System.out.println( "FIX ME: found class: " + wordName );
                          line = xrLine( line, packages[j], currentImport.getClassType( fqpn_class ) );
  
                      }
                      
                      
                  } else if ( currentImport.getClassType( wordName ) != null ) {
  
                      //System.out.println( "FIX ME: found imported class: "+ wordName  );
                      line = xrLine( line, packages[j], currentImport.getClassType( wordName ) );
                          
                  } 
                  
                  
                  
              }
              
              
          }
          
          
          return importFilter( line );
          
      }
      
      /**
      Get the current filename
      */
      public final String getCurrentFilename() {
          return this.currentFilename;
      }
      
      /**
      Set the current filename
      */
      public final void setCurrentFilename( String filename ) {
          this.currentFilename = filename;
      }
  
      /**
      Given the current package, get an HREF to the package and class given 
      */
      private final String getHREF( String dest,
                              ClassType jc ) {
  
          StringBuffer href = new StringBuffer();
                                  
          //find out how to go back to the root
  
          href.append( this.getPackageRoot() );
          
          //now find out how to get to the dest package
          dest = Util.replace( dest, ".*", "" );
          dest = Util.replace( dest, ".", "/" );
          
          href.append( dest );
          
          //now append the classname.html file
          if ( jc != null ) {
              href.append( "/" );
              href.append( jc.getName() );
              href.append( ".html" );
          } 
          
          return href.toString();
          
      }
      
      /**
      Based on the destination package, get the HREF.
      */
      private final String getHREF( String dest ) {
          return getHREF( dest, null );
      }
      
      /**
      <p>
      Given the name of a package... get the number of subdirectories/subpackages
      there would be.  
      </p>
  
      <p>
      EX: org.apache.maven == 3
      </p>
      */
      private final int getPackageCount( String packageName ) {
  
          if ( packageName == null ) {
              return 0;
          }
          
          int count = 0;
          
          int index = 0;
  
          while (true) {
  
              index = packageName.indexOf( ".", index );
              
              if ( index == -1 ) {
                  break;
              }
              ++index;
              ++count;
          }
          
          //need to increment this by one 
          count = ++count;
          
          return count;
      }
      
      /**
      Parse out the current link and look for package/import statements and then
      create HREFs for them
      */
      private final String importFilter( String line ) {
          
          int start = -1;
  
          /*
          Used for determining if this is a package declaration.  If it is 
          then we can make some additional assumptions:
              - that this isn't a Class import so the full String is valid
              - that it WILL be on the disk since this is based on the current 
              - file.
          */
          boolean isPackage = line.indexOf( "package" ) != -1;
          
          //
          if ( line.indexOf( "import" ) != -1 || 
               isPackage ) {
  
              start = line.trim().indexOf( " " );
          }
          
          if ( start != -1 ) {
              
              //filter out this packagename...
  
              String pkg = line.substring( start, line.length() ).trim();
      
              //specify the classname of this import if any.
              String classname = null;
              
              if ( pkg.indexOf( ".*" ) != -1 ) {
  
                  pkg = Util.replace( pkg, ".*", "" );
  
              } else if ( isPackage == false ) {
  
                  //this is an explicit Class import
  
                  String packageLine = pkg.toString();
                  
                  classname = packageLine.substring( packageLine.lastIndexOf( "." ) + 1, packageLine.length() - 1 );
  
                  
                  int end = pkg.lastIndexOf( "." );
  
                  if ( end == -1 ) {
                      end = pkg.length() - 1;
                  }
                  
                  pkg = pkg.substring( 0, end );
                  
              }
              
              
              pkg = Util.replace( pkg, ";", "" );
              
              //if this package is within the PackageManager then you can create an HREF for it.
              
              if ( PackageManager.getInstance().getPackageType( pkg.toString() ) != null || 
                   isPackage ) { 
  
      
                  //Create an HREF for explicit classname imports
                  if ( classname != null ) {
                  
                      line = Util.replace( line, classname, "<a href=\"" + 
                                                            this.getHREF( pkg.toString() ) + 
                                                            "/" + 
                                                            classname +
                                                            ".html" + 
                                                            "\">" + 
                                                            classname +
                                                            "</a>" );
                                           
                  }
                       
                       
                  //now replace the given package with a href
                  line = Util.replace( line, pkg.toString(), "<a href=\"" + 
                                                             this.getHREF( pkg.toString() ) + 
                                                             "/" + 
                                                             DirectoryIndexer.INDEX +
                                                             "\">" + 
                                                             pkg.toString() + 
                                                             "</a>" );
              }
              
          }
          
          
          return line;
      }
  
  
      /**
      From the current file, determine the package root based on the current path.
      */
      public final String getPackageRoot() {
  
          StringBuffer buff = new StringBuffer();
  
          JavaFile jf = null;
          
          try {
              jf = FileManager.getInstance().getFile( this.getCurrentFilename() );
          } catch ( IOException e ) {
              e.printStackTrace();
              return null;
          }
  
          String current = jf.getPackageType().getName();
          
          
          int count = this.getPackageCount( current );
          
          for( int i = 0; i < count; ++i ) {
              buff.append( "../" );
          }
  
          return buff.toString();
      }
      
      /**
      Given a line of text, search for URIs and make href's out of them
      */
      public final String uriFilter( String line ) {
  
          for ( int i = 0; i < VALID_URI_SCHEMES.length; ++i ) {
              
              String scheme = VALID_URI_SCHEMES[i];
              
              int index = line.indexOf( scheme );
  
              if ( index != -1 ) {
                  
                  int start = index;
                  
                  int end = -1;
                  
                  for ( int j = start; j < line.length(); ++j ) {
                  
                      char current = line.charAt( j );
                  
                      if ( Character.isLetterOrDigit( current ) == false && 
                           isInvalidURICharacter( current ) ) {
                          end = j;
                          break;
                      }
  
                      end = j;
  
                  }
  
                  //now you should have the full URI so you can replace this 
                  //in the current buffer
                  
                  if ( end != -1 ) {
                      
                      String uri = line.substring( start, end );
                      
                      line = Util.replace( line, uri, "<a href=\"" +
                                                      uri +
                                                      "\" target=\"alexandria_uri\">" +
                                                      uri + 
                                                      "</a>" );
                                   
  
                  }
                  
              }
              
          }
          
          //if we are in a multiline comment we should not call JXR here.
          if ( inMultiLineComment == false && 
               inJavadocComment == false ) {
              return jxrFilter( line );
          } else {
              return line;
          }
          
      }
      
      
      
      /**
      if the given char is not one of the following in VALID_URI_CHARS
      then return true
      */
      private final boolean isInvalidURICharacter( char c ) {
          
          for ( int i = 0; i < VALID_URI_CHARS.length; ++i ) {
              
              if ( VALID_URI_CHARS[i] == c ) {
                  return false;
              }
              
          }
          
          return true;
          
      }
      
      /**
      The current revision of the CVS module
      */
      public final String getRevision() {
          return this.revision;
      }
      
      /**
      The current source file being read
      */
      public final String getSourcefile() {
          return this.sourcefile;
      }
  
      /**
      The current dest file being written
      */
      public final String getDestfile() {
          return this.destfile;
      }
      
      /**
      The current source directory being read from.
      */    
      public final String getSourceDirectory() {
          return this.sourcedir;
      }
      
      
      /**
      Cross Reference the given line with JXR returning the new content.
      */
      public final String xrLine( String line,
                            String packageName, 
                            ClassType classType ) {
  
          StringBuffer buff = new StringBuffer( line );
  
          String link = null;
          String find = null;
  
          if ( classType != null ) {
                                
              String href = this.getHREF( packageName, classType );
  
              //find = packageName + "." + classType.getName();
              find = classType.getName();
                                                      
              //build out what the link would be.
              link = "<a href=\"" + href + "\">" + find + "</a>";
              
          } else {
              
              String href = this.getHREF( packageName );
  
              find = packageName;
                                                      
              //build out what the link would be.
              link = "<a href=\"" + href + "\">" + find + "</a>";
  
          }
                          
          //use the SimpleWordTokenizer to find all entries
          //that match word.  Then replace these with the link
                          
          //StringEntry se = SimpleWordTokenizer.tokenize( buff.toString(), 
                          
          //now replace the word in the buffer with the link
  
  
          String replace = link;
  
          StringEntry[] tokens = SimpleWordTokenizer.tokenize( buff.toString(), find );
  
              
          for( int l = 0; l < tokens.length; ++l ) {
                  
              int start = tokens[l].getIndex();
              int end = tokens[l].getIndex() + find.length();
  
                              
              buff.replace( start, end, replace );
  
          }
          
          return buff.toString();
          
      }
      
      /**
      Highlight the package in this line.
      */
      public final String xrLine( String line, 
                            String packageName ) {
  
          String href = this.getHREF( packageName );
  
          String find = packageName;
                                                      
          //build out what the link would be.
          String link = "<a href=\"" + href + "\">" + find + "</a>";
          
          
          //System.out.println( "find" );
          
          return Util.replace( line, find, link );
  
      }
      
  }
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/DirectoryIndexer.java
  
  Index: DirectoryIndexer.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
  
  package org.apache.maven.jxr;
  
  import org.apache.maven.jxr.util.*;
  
  //java stuff
  import java.io.*;
  import java.util.*;
  import java.text.*;
  
  /**
  Handles building a directory index of files and directories.
  
  @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
  */
  public class DirectoryIndexer {
  
      public static final int MODE_FULL = 1;
      public static final int MODE_JAVA = 2;
      public static final int MODE_DEFAULT = MODE_JAVA;
      
      public static final String INDEX = "alexandria.index.html";
  
      public static final String IMAGE_DIRECTORY = "./folder.gif";
      public static final String IMAGE_FILE      = "./file.gif";
      public static final int    IMAGE_WIDTH     = 15;
      
      private File directory = null;
  
      private String image_folder = "";
  
      private String image_file = "";
  
      /**
      Optionally specify the global root for a DirectoryIndexer.
      */
      private String root = null;
      
      private int mode = MODE_DEFAULT;
      
      
      /**
      @see DirectoryIndexer
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public DirectoryIndexer( String directory,
                               String image_folder,
                               String image_file ) throws IOException {
  
          this( directory, image_folder, image_file, MODE_JAVA );
  
      }
      
      /**
      Create a given DirectoryIndexer with the given dir, images, etc
      
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public DirectoryIndexer( String directory,
                               String image_folder,
                               String image_file,
                               int mode ) throws IOException {
  
          this( null, directory, image_folder, image_file, mode );
  
      }
  
      public DirectoryIndexer( String root,
                               String directory,
                               String image_folder,
                               String image_file,
                               int mode ) 
          throws IOException 
      {
          
          this.root = root;
  
          this.directory = new File( directory );
          this.image_folder = image_folder;
          this.image_file = image_file;
  
          copy( image_folder, directory + System.getProperty("file.separator") + DirectoryIndexer.IMAGE_DIRECTORY );
          copy( image_file, directory + System.getProperty("file.separator") + DirectoryIndexer.IMAGE_FILE );
          
          this.process();
      }
      
      /**
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private final void process() throws IOException {
          
          if ( ! directory.isDirectory() ) {
              throw new IOException("Not a directory");
          }
          
  
          String index =  directory.getAbsolutePath() + 
                          System.getProperty( "file.separator" ) +
                          INDEX;
          
          //System.out.println("\tWriting index file -> " + index);
  
          PrintWriter out = new PrintWriter( new FileOutputStream( index ) );
          
          //write the dirs first...
          
          out.println("<html>");
          out.println("<body bgcolor=\"white\">");
  
          //if the mode is MODE_JAVA then provide a package header for this dir.
          if ( this.getMode() == MODE_JAVA &&
               this.getRoot() != null ) {
              
              String dir = this.getDirectory();
              
              String root = this.getRoot();
  
              int start = dir.indexOf( root ) + root.length() + 1;
              int end = dir.length();
              
              if ( start != -1 &&
                   end != -1 &&
                   start < end ) {
  
                  String pkg = dir.substring( start, end );
      
                  out.print( "<br><p><b>Package:  ");
  		StringTokenizer toke = new StringTokenizer(pkg, System.getProperty("file.separator"));
  		while(toke.hasMoreElements()){
  		    String subpkg = (String)toke.nextElement();
  
  		    if(toke.hasMoreTokens()){
  		        out.print("<a href=\"");
  		        for(int i = 0;i<toke.countTokens();i++){
  		            out.print("../");
  		        }
  		        out.print( INDEX + "\">" + subpkg +"</a>.");
  		    }else{
  		        out.print( subpkg );
  		    }
  		}
                  pkg = Util.replace( pkg, System.getProperty("file.separator"), "." );
              
                  out.println( "</b></p>" );
  
              }
              
          }
  
          out.println("<hr>");
          out.println("<table width=\"100%\">");
  
  
          out.println("<tr>");
          out.println("<td><b>Name</b></td>");
          out.println("<td><b>Size</b></td>");        
          out.println("<td><b>Last Modified</b></td>");
          out.println("</tr>");
  
          
          String[] items;
          
          items = this.getDirs();
          
          for (int i = 0; i < items.length; ++i) {
  
              String directory = items[i];
  
              out.println( getItem( new File( directory ) ) );
              new DirectoryIndexer( this.getRoot(),
                                    directory,
                                    image_folder,
                                    image_file,
                                    this.getMode() );
  
          }
          
          items = this.getFiles();
          
          for (int i = 0; i < items.length; ++i) {
              out.println( getItem( new File( items[i] ) ) );
          }
  
  
          
  
          out.println("</table>");
          out.println("<hr>");
          out.println("<center>" + JXR.NOTICE + "</center>");
          out.println("</body>");
          out.println("</html>");
  
          out.flush();
          out.close();
          
          
      }
  
      /**
      Make an href for a file
      
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private final String getItem(File item) {
          
          String image    = IMAGE_FILE;
          String href     = item.getName();
          String name     = item.getName();
  
          if ( item.isDirectory() ) {
              
              href = item.getName() + "/" + INDEX;
              
              image = IMAGE_DIRECTORY;
          }
          
          //potentially rip off.html links on names
          if ( item.isFile() ) {
  
              int start = 0;
              int end = item.getName().indexOf(".html");
  
              if (end != -1) {
                  name = item.getName().substring( start, end );
              }
  
              image = IMAGE_FILE;
          }
  
          //"<td width=\"" + IMAGE_WIDTH + "\"><img src=\"" + image + "\" border=\"0\"></td>" +
          return "<tr valign=\"middle\">" + 
                 "<td valign=\"middle\" NOWRAP><img src=\"" + image + "\" valign=\"middle\" border=\"0\">&nbsp;<a href=\"" + href + "\">" + name + "</a></td>" + 
                 "<td valign=\"middle\" NOWRAP>" + item.length() + " (in bytes) </td>" +
                 "<td valign=\"middle\" NOWRAP>" + DateFormat.getDateInstance().format( new Date( item.lastModified() ) ) + "</td>" +
                 "</tr>";
      }
      
      /**
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private final String[] getDirs() throws IOException {
          
          Vector v = new Vector();
          
          String[] list = directory.list();
          
          for ( int i = 0; i < list.length; ++i ) {
  
              String item = directory.getAbsolutePath() +
                            System.getProperty( "file.separator" ) +
                            list[i];
              
              if ( new File( item ).isDirectory() ) {
                  v.addElement( item );
              }
  
          }
          
          Collections.sort(v);
          String[] found = new String[v.size()];
          v.copyInto(found);
          return found;
          
      }
  
      /**
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private final String[] getFiles() throws IOException {
          Vector v = new Vector();
          
          String[] list = directory.list();
          
          for ( int i = 0; i < list.length; ++i ) {
  
              String item = directory.getAbsolutePath() +
                            System.getProperty( "file.separator" ) +
                            list[i];
              
              //don't process the index file
              if ( list[i].equals( INDEX ) ) {
                  continue;
              }
  
              
              String filename = new File( item ).getName();
              
              //if the mode is JAVA only return .html files else return all
              if ( this.getMode() == MODE_JAVA && 
                   JXR.isHtmlFile( item ) && 
                   new File( item ).isFile() ) {
              
                  v.addElement( item );
  
              } else if ( this.getMode() == MODE_DEFAULT &&
                          filename.equals( INDEX ) == false && 
                          filename.equals( new File( IMAGE_DIRECTORY ).getName() ) == false && 
                          filename.equals( new File( IMAGE_FILE ).getName() ) == false &&                         
                          new File( item ).isFile() ) {
  
                  v.addElement( item );                            
  
              }
  
          }
          
  
          Collections.sort(v);
          String[] found = new String[v.size()];
          v.copyInto(found);
          return found;
          
      }
  
  
      /**
      Copy one file to another file
      
      @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
      @version $Id: DirectoryIndexer.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public void copy(String source, String dest) throws IOException {
  
          InputStream is = new FileInputStream( source );
          OutputStream os = new FileOutputStream( dest );
  
          //now process the InputStream...
          byte bytes[] = new byte[200];
  
          int readCount = 0;
          while( ( readCount = is.read( bytes )) > 0 ) {
              os.write(bytes, 0, readCount);
          }
  
          is.close();
          os.close();
  
      }
  
      /**
      Return the mode that DirectoryIndexer is operating in
      @see MODE_DEFAULT
      @see MODE_JAVA
      */
      public int getMode() {
          return mode;
      }
      
      /**
      Get the root dir for directory indexing.
      */
      public String getRoot() {
          return this.root;
      }
  
      /**
      Get the directory
      */
      public String getDirectory() {
          return this.directory.getAbsolutePath();
      }
  }
      
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/JXR.java
  
  Index: JXR.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
  
  package org.apache.maven.jxr;
  
  
  //alexandria stuff
  import org.apache.maven.jxr.util.*;
  
  //ant stuff
  import org.apache.tools.ant.*;
  
  //java stuff
  import java.io.*;
  
  /**
  Main entry point into Alexandria used to kick off the XReference code building.
  
  @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
  */
  public class JXR {
  
      public static final String NOTICE = 
          "This page automatically generated by the JXR Engine within " +
          "<a href=\"http://relativity.yi.org/alexandria\" target=\"top\">" +
          "Alexandria</a> (burton@apache.org)";
      
      /**
       * This is a workspace file like workspace.xml
      */
      private String markup = "";
  
      /**
      Path to all source.files
      */
      private String source = "";
  
      /**
      Path to destination
      */
      private String dest   = "";
         
         
      /**
      Handles taking .java files and changing them into html.  "More than meets 
      the eye!" :)
      */       
      private CodeTransform transformer = new CodeTransform();
  
      private MetaData metadata;
  
      /**
      The revision of the module currently being processed.
      */
      private String revision;
         
      /**
      The source directory for all these files:  ./src/java
      */
      private String sourcedir;
         
      /**
      
      @param revision The CVS revision of this file.
      @param srcdir The directory that files are being read from (src/java)
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public JXR( String source,
                  String dest,
                  MetaData metadata,
                  String revision,
                  String sourcedir ) 
      {
          this.markup = markup;
          this.source = source;
          this.dest = dest;
          this.metadata = metadata;
          this.revision = revision;
          this.sourcedir = sourcedir;
  
          this.process();        
  
      }
  
  
      /**
      Now that we have instantiated everythign.  Process this JXR task.
      
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private void process() {
  
          DirectoryScanner ds = new DirectoryScanner();
          
          ds.addDefaultExcludes();
  
          File dir = new File( this.getSource() );
  
          if ( ! dir.exists() ) {
              if ( dir.mkdirs() == false ) {
                  throw new IllegalStateException( "Your source directory does not exist and could not be created:" + this.getSource() );
              }
          }
          
          ds.setBasedir( this.getSource() );
          ds.scan();
          
          //now get the list of included files
          
          String[] files = ds.getIncludedFiles();
          
          for (int i = 0; i < files.length; ++i) {
  
              if ( ! updated( files[i] ) ) {
                  
                  String source = this.getSource() + System.getProperty("file.separator") + files[i];
  
                  try {
  
                      if ( isJavaFile( source ) ) {
                          transform( source, getDestination( source ) );
                      }
  
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
  
              }
  
          }
  
      }
  
      /**
      @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public static boolean isJavaFile( String filename ) {
          return filename.indexOf( ".java" ) != -1;
      }
  
      /**
      @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public static boolean isHtmlFile( String filename ) {
          return filename.indexOf( ".html" ) != -1;
      }
      
      /**
      Given a filename get the destination on the filesystem of where to store 
      the to be generated HTML file.  Pay attention to the package name.
      
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private String getDestination( String filename ) {
          
          String dest = new String( filename );
          
          //remove the source directory from the filename.
          
          dest = dest.substring( this.getSource().length(), dest.length() );
          
  
          int start = 0; 
          int end = dest.indexOf( ".java" );
          
          if ( end != -1 ) {
              //remove the .java from the filename
              dest = dest.substring( start, end );
          }
          
          
          //add the destination directory to the filename.
          dest = this.getDest() + dest;
  
          
          //add .html to the filename
       
          dest = dest + ".html";
       
          return dest;
          
      }
      
      /**
      Given a source file transform it into HTML and write it to the destination
      (dest) file.
  
      @throws IOException Thrown if the transform can't happen for some reason.
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private void transform( String source, String dest ) throws IOException {
          
          log( source + " -> " + dest );
  
          transformer.transform( source, dest, this.revision, this.sourcedir, this.metadata );
          
      }
      
      /**
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private void log(String message) {
          System.out.println("\t" + message);
      }
      
      /**
      Get an array of files that you should act on.
      
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private String[] getFiles() {
          return new String[0];
      }
  
      /**
      <p>Given a java source file determine if this needs updating.  
      This is determined by:</p>
      
      <ul>
          <li>The class doesn't exist in the destination directory</li>
          <li>The file does exist in the destination directory but is older</li>
      </ul>
      
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private boolean updated(String file) {
          return false;
      }
      
      /**
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public String getSource() {
          return this.source;
      }
      
      /**
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: JXR.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public String getDest() {
          return this.dest;
      }
      
  }
      
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/JxrTask.java
  
  Index: JxrTask.java
  ===================================================================
  package org.apache.maven.jxr;
  
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
  
  import org.apache.maven.jxr.pacman.*;
  import org.apache.maven.jxr.util.*;
  import org.apache.maven.project.Project;
  import org.apache.maven.project.Repository;
  
  //Ant imports
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  //import org.apache.tools.ant.taskdefs.*;
  
  /**
    * 
    * @author <a href="mailto:lucas@collab.net";>Josh Lucas</a>
  * An Ant task which will create an html-based version of Java source code
    */
  
  public class JxrTask extends Task {
  
      /**
        * the starting directory housing the .java files
        */
      private String startDir;
      
      /**
        * the destination directory
        */
      private String destDir;
      
      /**
        * the location of the folder.gif
        */
      private String imageFolder;
      
      /**
        * the location of the file.gif
        */
      private String imageFile;
      
      public void execute() throws BuildException {
          try {
              PackageManager pkgmgr = PackageManager.getInstance();
              pkgmgr.setTask( this );
              pkgmgr.process( startDir );
              
              // markup -> global.xml
              // source
              // dest
              // metadata
              // revision -> cvs tag ???
              // sourcedir -> null ???
              MetaData meta = new MetaData(new Repository(), new Project());
              new JXR( startDir, destDir, meta, "HEAD", null);
              new DirectoryIndexer(destDir, destDir, imageFolder, 
                  imageFile, DirectoryIndexer.MODE_JAVA);
          }
          catch (Exception ex) 
          {
              throw new BuildException(ex);    
          }
      }
      
      public void setImageFile( String imageFile ) {
          this.imageFile = imageFile;   
      }
      
      public void setImageFolder( String imageFolder ) {
          this.imageFolder = imageFolder;   
      }
      
      public void setStartDir( String startDir ) {
          this.startDir = startDir;   
      }
      
      public void setDestDir( String destDir ) {
          this.destDir = destDir;
      }
  }    
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/BaseType.java
  
  Index: BaseType.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  public abstract class BaseType {
      
      private String name = null;
      
      /**
      Get the name for this type
      */
      public String getName() {
          if(name==null)return "";
          return this.name;
      }
      
      /**
      Set the name for this type
      */
      public void setName( String name ) {
          this.name = name;
      }
      
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/ClassType.java
  
  Index: ClassType.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  /**
  Represents a Java class or interface
  */
  public class ClassType extends BaseType {
  
      /**
      Create a new ClassType
      */
      public ClassType( String name ) {
          this.setName( name );
      }
      
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/FileManager.java
  
  Index: FileManager.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  import java.util.*;
  import java.io.IOException;
  
  /**
  <p>
  Singleton that handles holding references to JavaFiles.  This allows Alexandria 
  to lookup and see if a file has already been parsed out and then it can load 
  the information from memory instead of reparsing the file.
  </p>
  
  <p>
  Note.  This assumes that the file will not be modified on disk while Alexandria 
  is running.
  </p>
  
  */
  public class FileManager {
      
      /**
      The Singleton instance of this FileManager
      */
      private static FileManager instance = new FileManager();
      
      private Hashtable files = new Hashtable();
      
      /**
      Get an instance of the FileManager
      */
      public static FileManager getInstance() {
          return instance;
      }
      
      /**
      Get a file from it's name.  If the file does not exist within the FileManager,
      create a new one and return it.
      */
      public JavaFile getFile( String name ) throws IOException {
  
          JavaFile real = (JavaFile)this.files.get( name );
  
          if ( real == null ) {
              real = new JavaFileImpl( name );
              this.addFile( real );
          }
          
          return real;
      }
      
      /**
      Add a file to this filemanager.
      */    
      public void addFile( JavaFile file ) {
          this.files.put( file.getFilename(), file );
      }
      
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/ImportType.java
  
  Index: ImportType.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  
  /**
  Represents an entry in a java "import" statement
  */
  public class ImportType extends BaseType {
  
      private boolean isclass = false;
      private boolean ispackage = false;
      private String packagename = null;
      
      /**
      Create a new ImportType with the specified name
      */
      public ImportType( String name ) {
          this.setName( name );
          
          //compute member variables
          
          
          this.isclass = this.getName().indexOf( "*" ) == -1;
          
          this.ispackage = this.getName().indexOf( "*" ) != -1;
  
          int end = this.getName().lastIndexOf(".");
          if ( end != -1 ) {
              this.packagename = this.getName().substring( 0, end );
          }
          
      }
      
      /**
      Return true if this is a class import.  Ex:  test.Test
      */
      public boolean isClass() {
          return this.isclass;
      }
      
      /**
      Return true if this is a package import.  Ex: test.*
      */
      public boolean isPackage() {
          return this.ispackage;
      }
      
      
      /**
      Get the name of the package that this import is based on:
      
      EX: test.* will return "test"
      EX: test.Test will return "test"
      */
      public String getPackage() {
          return this.packagename;
      }
      
      
  }
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/JavaFile.java
  
  Index: JavaFile.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  import java.util.*;
  
  /**
  Interface for objects which wish to provide metainfo about a JavaFile.
  
  @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  @version $Id: JavaFile.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
  */
  public abstract class JavaFile {
      
      private Vector imports = new Vector();
      
      private ClassType classType = null;
      private PackageType packageType = new PackageType();
  
      private String filename = null;
      
      /**
      Get the imported packages/files that this package has.
      */
      public ImportType[] getImportTypes() {
          
          ImportType[] it = new ImportType[ this.imports.size() ];
          this.imports.copyInto( it );
          return it;
          
      }
      
      /**
      Get the name of this class.
      */
      public ClassType getClassType() {
          return this.classType;
      }
      
      /**
      Get the package of this class.
      */
      public PackageType getPackageType() {
          return this.packageType;
      }
  
      
      /**
      Add an ImportType to the current imports
      */
      public void addImportType( ImportType importType ) {
          this.imports.addElement( importType );
      }
      
      /**
      Set the name of this class.
      */
      public void setClassType( ClassType classType ) {
          this.classType = classType;
      }
      
      /**
      Set the PackageType of this class.
      */
      public void setPackageType( PackageType packageType ) {
          this.packageType = packageType;
      }
       
       
      public String getFilename() {
           return this.filename;
      }
      
      public void setFilename( String filename ) {
          this.filename = filename;
      }
     
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/JavaFileImpl.java
  
  Index: JavaFileImpl.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  import java.util.*;
  import java.io.*;
  
  /**
  PacMan implementation of a JavaFile.  This will parse out the file and 
  determine package, class, and imports
  
  @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  @version $Id: JavaFileImpl.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
  */
  public class JavaFileImpl extends JavaFile {
  
      /**
      Create a new JavaFileImpl that points to a given file...
      */
      public JavaFileImpl( String filename ) throws IOException {
          this.setFilename( filename );
  
          //always add java.lang.* to the package imports because the JVM always
          //does this implicitly.  Unless we add this to the ImportTypes JXR 
          //won't pick up on this.
          
          this.addImportType( new ImportType( "java.lang.*" ) );
          
          //now parse out this file.
          
          this.parse();
      }
      
      /**
      Open up the file and try to determine package, class and import statements.
      */
      private void parse() throws IOException {
  
          StreamTokenizer stok = this.getTokenizer();
          
          while( stok.nextToken() != StreamTokenizer.TT_EOF ) {
              
              if ( stok.sval == null )
                  continue;
              
              //set the package
              if ( stok.sval.equals( "package" ) ) {
                  stok.nextToken();
                  this.setPackageType( new PackageType( stok.sval ) );
              } 
              
              //set the imports
              if ( stok.sval.equals( "import" ) ) {
                  stok.nextToken();
  
                  String name = stok.sval;
                  
                  /*
                  WARNING: this is a bug/non-feature in the current 
                  StreamTokenizer.  We needed to set the comment char as "*"
                  and packages that are imported with this (ex "test.*") will be 
                  stripped( and become "test." ).  Here we need to test for this
                  and if necessary re-add the char.
                  */
                  
                  if ( name.charAt( name.length() -1 ) == '.' ) {
                      name = name + "*";
                  }
                  
                  this.addImportType( new ImportType( name ) );
              } 
              
              
              //set the Class... if the class is found no more information is 
              //valid so just break out of the while loop at this point.
              //set the imports
              if ( stok.sval.equals( "class" ) || 
                   stok.sval.equals( "interface" ) ) {
                  stok.nextToken();
                  this.setClassType( new ClassType( stok.sval ) );
                  break;
              } 
              
          }
  
          
      }
      
      /**
      Get a StreamTokenizer for this file.
      */
      private StreamTokenizer getTokenizer() throws IOException {
          
          if (! new File( this.getFilename() ).exists() ) {
              throw new IOException( this.getFilename() + " does not exist!" );
          }
  
  
          FileReader		reader = new FileReader( this.getFilename() );
  
          StreamTokenizer	stok = new StreamTokenizer( reader );
          int				tok;
          
          stok.commentChar('*');
  
          // set tokenizer to skip comments
          stok.slashStarComments(true);
          stok.slashSlashComments(true);
  
          return stok;
          
      }
  
      
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/PackageManager.java
  
  Index: PackageManager.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  import org.apache.maven.jxr.util.*;
  import java.util.*;
  import java.io.*;
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.Project;
  
  /**
  Given a list of directories, parse them out and store them as rendered packages,
  classes, imports, etc.
  */
  public class PackageManager {
      
      private Hashtable directories = new Hashtable();
  
      /**
      All the packages that have been parsed
      */
      private Hashtable packages = new Hashtable();
  
      /**
      The default Java package.
      */
      private PackageType defaultPackage = new PackageType();
  
      /**
      * Controling ant task;
      */
      private Task task = null;
  
      /**
      The SingletonInstance of this PackageManager.
      */
      public static PackageManager instance = new PackageManager();
      
      /**
      Given the name of a package (Ex: org.apache.maven.util) obtain it from
      the PackageManager
      */
      public PackageType getPackageType( String name ) {
  
          //return the default package if the name is null.
          if ( name == null ) {
              return defaultPackage;
          }
          
          return (PackageType)this.packages.get( name );
      }
      
      /**
      Add a package to the PackageManager
      */
      public void addPackageType( PackageType packageType ) {
          this.packages.put( packageType.getName(), packageType );
      }
  
      /**
      Get all of the packages in the PackageManager
      */
      public PackageType[] getPackageTypes() {
  
          Vector packages = new Vector();
  
          Enumeration enum = this.packages.elements();
          
          while ( enum.hasMoreElements() ) {
              packages.addElement( enum.nextElement() );
          }
          
          //now add the defaultPackage to the packages....
          
          packages.addElement( defaultPackage );
          
          PackageType[] found = new PackageType[packages.size()];
          packages.copyInto( found );
          return found;
      }
      
      /**
      Parse out all the directories on which this depends.
      */
      private void parse( String directory ) {
  
          String[] extensions = { "java" };
          
          //go through each directory.
              
              //get the java source files for this dir.
  
          String[] files = FileUtils.getFilesFromExtension( directory, extensions );
              
          for( int j = 0; j < files.length; ++j ) {
                  
              log( "parsing... " + files[j] );
                  
              //now parse out this file to get the packages/classname/etc
                  
              try {
          
                  JavaFile jfi = FileManager.getInstance().getFile( files[j] );
  
                  /* 
                  now that we have this parsed out blend its information
                  with the current package structure
                  */
  
                  PackageType jp = this.getPackageType( jfi.getPackageType().getName() );
                      
                  if ( jp == null ) {
                      this.addPackageType( jfi.getPackageType() );
                      jp = jfi.getPackageType();
                  }
                      
                  //add the current class to this global package.
                  if ( jfi.getClassType() != null &&
                       jfi.getClassType().getName() != null ) {
  
                      jp.addClassType( jfi.getClassType() );
  
                  }
                      
                      
              } catch ( IOException e ) {
                  e.printStackTrace();
              }
                  
          }
              
          
      }
  
      public void process( String directory ) {
          if ( this.directories.get( directory ) == null ) {
              this.parse( directory );
              this.directories.put( directory, directory );
          }
      }
  
      public void process( String[] directories ) {
          
          for ( int i = 0; i < directories.length; ++i ) {
              this.process( directories[i] );
          }
          
      }
      
      public static PackageManager getInstance() {
          return instance;
      }
  
      public void setTask(Task task){
          this.task = task;
      }
      
      /**
      Simple logging facility
      */
      public final static void log( String message ) {
          
          if(instance.task==null){
              System.out.println( " PackageManager -> " + message );        
          }else{
              instance.task.log(message, Project.MSG_VERBOSE);
          }
          
      }
      
      
      /**
      Dump the package information to STDOUT.  FOR DEBUG ONLY  
      */
      
      public void dump() {
          
          log( "Dumping out PackageManager structure" );
          
          PackageType[] pts = this.getPackageTypes();
          
          for( int i = 0; i < pts.length; ++i ) {
              
              //get the current package and print it.
              PackageType current = pts[i];
              
              log( current.getName() );
              
              //get the classes under the package and print those too.
              Enumeration classes = current.getClassTypes();
  
              while( classes.hasMoreElements() ) {
                  
                  ClassType currentClass = (ClassType)classes.nextElement();
                  
                  log( "\t" + currentClass.getName() );
                  
              }
          }
          
      }
  }
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/pacman/PackageType.java
  
  Index: PackageType.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.pacman;
  
  import java.util.*;
  
  /**
  Represents a Java package and its subclasses.
  */
  public class PackageType extends BaseType {
  
      private Hashtable classes = new Hashtable();
      
      /**
      Create a Java package
      */
      public PackageType( String name ) {
          this.setName( name );
      }
      
      /**
      Create a Java package with no name IE the default Java package.
      */
      public PackageType() { }
      
      
      /**
      Get all the known classes
      */
      public Enumeration getClassTypes() {
          
          return classes.elements();
          
      }
      
      /**
      Add a class to this package.
      */
      public void addClassType( ClassType classType ) {
          
          this.classes.put( classType.getName(), classType );
          
      }
      
      /**
      Given the name of a class, get it from this package or null
      if it does not exist
      */
      public ClassType getClassType( String classType ) {
  
          return (ClassType) this.classes.get( classType );
  
      }
      
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/util/FileUtils.java
  
  Index: FileUtils.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
  
   
  package org.apache.maven.jxr.util; 
  
  import java.util.*;
  
  /**
  Misc utils for handing source files.
  
  @author <A HREF="mailto:burton@relativity.yi.org">Kevin A. Burton</A>
  @version $Id: FileUtils.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
  */
  public class FileUtils {
  
  
  
      /**
      return the extension of a file or null of it doesn't exist.
  
      If the extension is anything past the right of the last ".".  So for a file 
      like "test.java" the extension would be "java"
      
      @return the extension of a file or null of it doesn't exist.
      @author <A HREF="mailto:burton@relativity.yi.org">Kevin A. Burton</A>
      @version $Id: FileUtils.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public static String getExtension( String file ) {
          int begin = file.lastIndexOf(".");
          if (begin < 0) {
              return null;
          } else {
              
              return file.substring(begin + 1, file.length());
              
          }
      }
  
      /**
      <p>Given a directory and an array of extensions... return an array of compliant
      files.
      
      <p>The given extensions should be like "java" and not like ".java"
      
      
      @author <A HREF="mailto:burton@relativity.yi.org">Kevin A. Burton</A>    
      @version $Id: FileUtils.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public static String[] getFilesFromExtension(String directory, String[] extensions) {
  
          
          //
          Vector files = new Vector();
          
          //get the 
          java.io.File currentDir = new java.io.File(directory);
  
          String[] unknownFiles = currentDir.list();
  
          if (unknownFiles == null) {
              return new String[0];
          }
          
          for (int i = 0;i < unknownFiles.length;++i) {
              String currentFileName = directory + System.getProperty("file.separator") + unknownFiles[i];
              java.io.File currentFile = new java.io.File(currentFileName);
  
              if (currentFile.isDirectory()) {
  
  
                  //ignore all CVS directories...
                  if ( currentFile.getName().equals("CVS") ) {
                      continue;
                  }
  
  
                  //ok... transverse into this directory and get all the files... then combine
                  //them with the current list.
  
                  String[] fetchFiles = getFilesFromExtension(currentFileName, extensions);
                  files = blendFilesToVector( files, fetchFiles);
                  
              } else {
                  //ok... add the file
      
                  String add = currentFile.getAbsolutePath();
                  if ( isValidFile( add, extensions ) ) {
                      files.addElement( add );
                      
                  }
  
              }
          }
  
          //ok... move the Vector into the files list...
  
          String[] foundFiles = new String[files.size()];
          files.copyInto(foundFiles);
          
          return foundFiles;
  
      }
      
  
      /**
      @author <A HREF="mailto:burton@relativity.yi.org">Kevin A. Burton</A>    
      @version $Id: FileUtils.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private static Vector blendFilesToVector(Vector v, String[] files) {
          
          for (int i = 0; i < files.length; ++i) {
              v.addElement(files[i]);
          }
          
          return v;
      }
      
      /**
      @author <A HREF="mailto:burton@relativity.yi.org">Kevin A. Burton</A>    
      @version $Id: FileUtils.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      private static boolean isValidFile(String file, String[] extensions) {
  
  
          String extension = FileUtils.getExtension(file);
          if (extension == null) {
              return false;
          }
          
          //ok.. now that we have the "extension" go through the current know
          //excepted extensions and determine if this one is OK.
          
          for (int i = 0; i < extensions.length; ++i) {
              if (extensions[i].equals(extension)) 
                  return true;
          }
  
          return false;
          
      }
  
  
  }
   
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/util/MetaData.java
  
  Index: MetaData.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Jetspeed", "Apache Jetspeed" and "Apache Jetspeed 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * License version 1.0
   *
   */
  
  package org.apache.maven.jxr.util;
  
  //import org.apache.maven.xml.api.workspace.*;
  import org.apache.maven.project.*;
  
  /**
   * Contains MetaData about this Workspace..
   * 
   * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
   * @version $Id: MetaData.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
   */
  public class MetaData {
  
      private Repository repository;
      private Project project;
      
      public MetaData( Repository repository, 
                       Project project ) {
                           
          this.repository = repository;
          this.project = project;
      }
  
      public Repository getRepository() {
          return repository;
      }
  
      public Project getProject() {
          return this.project;
      }
      
  }
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/util/SimpleWordTokenizer.java
  
  Index: SimpleWordTokenizer.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Jetspeed", "Apache Jetspeed" and "Apache Jetspeed 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * License version 1.0
   *
   */
  
  package org.apache.maven.jxr.util;
  
  import java.util.*;
  
  /**
  This is a small and fast word tokenizer.  It has different characteristics from
  the normal Java tokenizer.  It only considers clear words that are only ended
  with spaces as strings.  EX:  "Flight" would be a word but "Flight()" would not.
  */
  public class SimpleWordTokenizer {
  
      public static final char[] BREAKERS = { '(', ')', '[', ' ', '{', '}' };
      
      /**
      Break the given line into multiple Strings
      */
      public static StringEntry[] tokenize( String line ) {
          
          /*
          determine where to start processing this String... this could 
          either be the start of the line or just keep going until the first
          */
  
          int start = getStart( line );
          
          //find the first non-BREAKER char and assume that is where you want to start
          
          
          if ( line == null || 
               line.length() == 0 ||
               start == -1 ) {
              return new StringEntry[0];
          }
              
          return tokenize( line, start, line.length() );
          
      }
  
  
      /** 
      Tokenize the given line but only return Strings that match the parameter
      find.
      
      @param line String to search in
      @param find String to match.
      */
      public static StringEntry[] tokenize( String line, String find ) {
          
          Vector v = new Vector();
          
          StringEntry[] se = tokenize( line );
          
          for( int i = 0; i < se.length; ++i ) {
              
              if ( se[i].toString().equals( find ) ) {
                  v.addElement( se[i] );
              }
              
          }
          
          
          StringEntry[] found = new StringEntry[v.size()];
          Collections.sort( v );
          v.copyInto( found );
          return found;
          
      }
      
      /**
      Internal impl.  Specify the start and end.
      */
      private static StringEntry[] tokenize( String line, int start, int end ) {
          
          Vector words = new Vector();
          
          //algorithm works like this... break the line out into segments 
          //that are separated by spaces, and if the entire String doesn't contain
          //a non-Alpha char then assume it is a word.
          while( true ) {
              
              int next = getNextBreak( line, start );
              
              if ( next < 0 ||
                   next <= start ) {
                  break;
              }
  
              String word = line.substring( start, next );
              
              if ( isWord( word ) ) {
                  words.addElement( new StringEntry( word, start ) );
              }
              
              start = next + 1;
          }
          
          StringEntry[] found = new StringEntry[words.size()];
          words.copyInto( found );
          return found;
          
      }
      
      
      /**
      Go through the entire String and if any character is not a 
      Letter( a, b, c, d, etc) then return false.
      */
      private static boolean isWord( String string ) {
          
          if ( string == null ||
               string.length() == 0 ) {
  
              return false;
              
          }
          
          for( int i = 0; i < string.length(); ++i ) {
  
              char c = string.charAt( i );
              
              if ( Character.isLetter( c ) == false &&
                   c != '.' ) {
                  return false;
              }
              
          }
          
          return true;
      }
      
      /**
      Go through the list of BREAKERS and find the closes one.
      */
      private static int getNextBreak( String string, int start ) {
          
          int breakPoint = -1;
          
          for( int i = 0; i < BREAKERS.length; ++i ) {
              
              int next = string.indexOf( BREAKERS[i], start );            
              
              if ( breakPoint == -1 ||
                  next < breakPoint && 
                  next != -1 ) {
  
                  breakPoint = next;
                  
              }
              
          }
          
          //if the breakPoint is still -1 go to the end of the string
          if ( breakPoint == -1 ) {
              breakPoint = string.length();
          }
          
          return breakPoint;
      }
      
      /**
      Go through the list of BREAKERS and find the closes one.
      */
      private static int getStart( String string ) {
          
          for ( int i = 0; i < string.length(); ++i ) {
              
              if ( isBreaker( string.charAt( i ) ) == false ) {
                  return i;
              }
              
          }
          
          return -1;
      }
  
      
      /**
      Return true if the given char is considered a breaker.
      */
      private static boolean isBreaker( char c ) {
          
          for ( int i = 0; i < BREAKERS.length; ++i ) {
              
              if ( BREAKERS[i] == c ) {
                  return true;
              }
              
          }
          
          return false;
      }
      
  }
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/util/StringEntry.java
  
  Index: StringEntry.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
   
  package org.apache.maven.jxr.util;
  
  
  /**
  A StringEntry represents a value found by the tokenizer.  The index is 
  where this StringEntry was found in the source string
  */
  public class StringEntry implements Comparable {
  
      private String value = null;
      private int index = 0;
      
      public StringEntry( String value,
                          int index ) {
          
          this.value = value;
          this.index = index;
      }
      
      public int getIndex() {
          return this.index;
      }
      
      public String toString() {
          return this.value;
      }
  
      /**
      Compare two objects for equality.
      */
      public int compareTo( Object obj ) {
          //right now only sort by the index.
          
          if ( obj instanceof StringEntry == false ) {
              
              throw new IllegalArgumentException( "object must be a StringEntry" );
          }
          
          
          StringEntry se = (StringEntry)obj;
          
          if ( se.getIndex() < this.getIndex() ) {
              return -1;
          } else if ( se.getIndex() == this.getIndex() ) {
              return 0;
          } else {
              return 1;
          }
          
      }
      
  }
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/util/StringUtil.java
  
  Index: StringUtil.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Jetspeed", "Apache Jetspeed" and "Apache Jetspeed 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
  
  package org.apache.maven.jxr.util;
  
  /**
  
  A class that provides a replace(int start, int end, String str) method similar
  to StringBuffer in JDK 1.2.2
  
  */
  public final class StringUtil {
  
      private char value[];
      private int count;
      private boolean shared;
  
      public StringUtil() {
          this(16);
      }
  
      public StringUtil(int length) {
          value = new char[length];
          shared = false;
      }
  
      public StringUtil(String str) {
  
          int length = 16;
          
          if ( str != null ) {
              length += str.length();            
          }
  
          value = new char[length];
          shared = false;
          
          append(str);
      }
  
      public int length() {
          return count;
      }
  
      public int capacity() {
          return value.length;
      }
  
      private final void copy() {
          char newValue[] = new char[value.length];
          System.arraycopy(value, 0, newValue, 0, count);
          value = newValue;
          shared = false;
      }
  
      private void expandCapacity(int minimumCapacity) {
          int newCapacity = (value.length + 1) * 2;
          if (minimumCapacity > newCapacity) {
              newCapacity = minimumCapacity;
          }
  	
          char newValue[] = new char[newCapacity];
          System.arraycopy(value, 0, newValue, 0, count);
          value = newValue;
          shared = false;
      }
  
  
  
  
      public StringUtil append(String str) {
          if (str == null) {
              str = String.valueOf(str);
          }
  
          int len = str.length();
          int newcount = count + len;
          if (newcount > value.length) {
              expandCapacity(newcount);
          }
  
          str.getChars(0, len, value, count);
          count = newcount;
          return this;
      }
  
  
  
      public StringUtil replace(int start, int end, String str) {
          if (start < 0) {
              throw new StringIndexOutOfBoundsException(start);
          }
  
          if (end > count) {
              end = count;
          }
  
          if (start > end) {
              throw new StringIndexOutOfBoundsException();
          }
  
          int len = str.length();
          int newCount = count + len - (end - start);
  
          if (newCount > value.length) {
              expandCapacity(newCount);
          } else if (shared) {
              copy();
          }
  
          System.arraycopy(value, end, value, start + len, count - end);
          str.getChars(0, len, value, start);
          count = newCount;
          return this;
      }
  
      public String substring(int start) {
          return substring(start, count);
      }
  
      public String substring(int start, int end) {
  
          if (start < 0)
              throw new StringIndexOutOfBoundsException(start);
          if (end > count)
              throw new StringIndexOutOfBoundsException(end);
          if (start > end)
      	    throw new StringIndexOutOfBoundsException(end - start);
  
          return new String(value, start, end - start);
  
      }
  
      /**
      Get a string representation for this StringUtil
      */
      public String toString() {
          return this.substring(0);
      }
  
      final void setShared() { 
          shared = true; 
      } 
  
      final char[] getValue() { 
          return value; 
      }
      
      
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/jxr/util/Util.java
  
  Index: Util.java
  ===================================================================
  /*
   *
   * Copyright (c) 1998 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. Every modification must be notified to the Java Apache Project
   *    and redistribution of the modified code without prior notification
   *    is not permitted in any form.
   *
   * 4. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * 5. The names "Jetspeed", "Apache Jetspeed" and "Apache Jetspeed 
   *    Project" must not be used to endorse or promote products 
   *    derived from this software without prior written permission.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache Project
   *    (http://java.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   * License version 1.0
   *
   */
  
  package org.apache.maven.jxr.util;
  
  
  /**
  @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  @version $Id: Util.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
  */
  public class Util  {
  
   
      /**
      Given a string... replaces all occurences of "find" with "replacement" in "original"
  
      @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
      @version $Id: Util.java,v 1.1 2002/02/23 20:18:08 jvanzyl Exp $
      */
      public static String replace(String original, String find, String replacement) {
          
          StringBuffer buffer = new StringBuffer(original);
  
          int space_location = buffer.toString().indexOf(find);
  
          while( space_location != -1 ) {
  
              if ( space_location > buffer.toString().length() ) {
                  break;
              }
              
              buffer.replace( space_location, space_location + find.length(), replacement );
          
              //this speed could be improved by starting off where the last string was found...
              //this is why it starts off from space_location.. the length of the string you are finding.. plus 1 
              space_location = buffer.toString().indexOf( find, 
                                                          space_location + replacement.length() + 1 );
          }
  
          return buffer.toString();
  
      }
  
  }
  
  
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>