You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2006/11/13 14:17:06 UTC

svn commit: r474296 - in /maven/jxr/trunk/src/main/java/org/apache/maven/jxr: JXR.java JavaCodeTransform.java

Author: vsiveton
Date: Mon Nov 13 05:17:05 2006
New Revision: 474296

URL: http://svn.apache.org/viewvc?view=rev&rev=474296
Log:
o starting to refactoring JavaCodeTransform (JXR-22)
o improved code lisibility
o updated some javadoc

Modified:
    maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java
    maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java

Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java
URL: http://svn.apache.org/viewvc/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java?view=diff&rev=474296&r1=474295&r2=474296
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java Mon Nov 13 05:17:05 2006
@@ -1,20 +1,19 @@
 package org.apache.maven.jxr;
 
-/* ====================================================================
- *   Copyright 2001-2004 The Apache Software Foundation.
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *       http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- * ====================================================================
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 import org.apache.maven.jxr.ant.DirectoryScanner;
@@ -39,12 +38,12 @@
 public class JXR
 {
     /**
-     * Log.
+     * The Log
      */
     private Log log;
 
     /**
-     * Description of the Field
+     * Description of the Notice
      */
     public static final String NOTICE = "This page was automatically generated by " +
         "<a href=\"http://maven.apache.org/\">Maven</a>";
@@ -78,6 +77,10 @@
 
     /**
      * Now that we have instantiated everythign. Process this JXR task.
+     *
+     * @param packageManager
+     * @param source
+     * @throws IOException
      */
     public void processPath( PackageManager packageManager, String source )
         throws IOException
@@ -121,9 +124,7 @@
      * Check to see if the file is a Java source file
      *
      * @param filename The name of the file to check
-     * @return <code>true
-     *         </true>
-     *         if the file is a Java file
+     * @return <code>true</true> if the file is a Java file
      */
     public static boolean isJavaFile( String filename )
     {
@@ -135,9 +136,7 @@
      * Check to see if the file is a HTML file
      *
      * @param filename The name of the file to check
-     * @return <code>true
-     *         </true>
-     *         if the file is a HTML file
+     * @return <code>true</true> if the file is a HTML file
      */
     public static boolean isHtmlFile( String filename )
     {
@@ -145,57 +144,6 @@
     }
 
     /**
-     * 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.
-     *
-     * @param source
-     * @param filename
-     * @return A String with the store destination.
-     */
-    private String getDestination( String source, String filename )
-    {
-        //remove the source directory from the filename.
-
-        String dest = filename.substring( source.length(), filename.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.
-     *
-     * @param source The jave source file
-     * @param dest The directory to put the HTML into
-     * @throws IOException Thrown if the transform can't happen for some reason.
-     */
-    private void transform( String source, String dest )
-        throws IOException
-    {
-        log.debug( source + " -> " + dest );
-
-        // get a relative link to the javadocs
-        String javadoc = javadocLinkDir != null ? getRelativeLink( dest, javadocLinkDir ) : null;
-        transformer.transform( source, dest, locale, inputEncoding, outputEncoding, javadoc, this.revision );
-    }
-
-    /**
      * Get the path to the destination files
      *
      * @return The path to the destination files
@@ -205,48 +153,166 @@
         return this.dest;
     }
 
+    /**
+     * @param dest
+     */
     public void setDest( String dest )
     {
         this.dest = dest;
     }
 
+    /**
+     * @param locale
+     */
     public void setLocale( Locale locale )
     {
         this.locale = locale;
     }
 
+    /**
+     * @param inputEncoding
+     */
     public void setInputEncoding( String inputEncoding )
     {
         this.inputEncoding = inputEncoding;
     }
 
+    /**
+     * @param outputEncoding
+     */
     public void setOutputEncoding( String outputEncoding )
     {
         this.outputEncoding = outputEncoding;
     }
 
+    /**
+     * @param javadocLinkDir
+     */
     public void setJavadocLinkDir( String javadocLinkDir )
     {
         // get a relative link to the javadocs
         this.javadocLinkDir = javadocLinkDir;
     }
 
+    /**
+     * @param transformer
+     */
     public void setTransformer( JavaCodeTransform transformer )
     {
         this.transformer = transformer;
     }
 
+    /**
+     * @param revision
+     */
     public void setRevision( String revision )
     {
         this.revision = revision;
     }
 
+    /**
+     * @param log
+     */
     public void setLog( Log log )
     {
         this.log = log;
     }
 
     /**
+     * @param sourceDirs
+     * @param templateDir
+     * @param windowTitle
+     * @param docTitle
+     * @param bottom
+     * @throws IOException
+     * @throws JxrException
+     */
+    public void xref( List sourceDirs, String templateDir, String windowTitle, String docTitle, String bottom )
+        throws IOException, JxrException
+    {
+        // first collect package and class info
+        FileManager fileManager = new FileManager();
+        fileManager.setEncoding( inputEncoding );
+
+        PackageManager pkgmgr = new PackageManager( log, fileManager );
+
+        // go through each source directory and xref the java files
+        for ( Iterator i = sourceDirs.iterator(); i.hasNext(); )
+        {
+            String path = (String) i.next();
+            path = new File( path ).getCanonicalPath();
+
+            pkgmgr.process( path );
+
+            processPath( pkgmgr, path );
+        }
+
+        // once we have all the source files xref'd, create the index pages
+        DirectoryIndexer indexer = new DirectoryIndexer( pkgmgr, dest );
+        indexer.setOutputEncoding( outputEncoding );
+        indexer.setTemplateDir( templateDir );
+        indexer.setWindowTitle( windowTitle );
+        indexer.setDocTitle( docTitle );
+        indexer.setBottom( bottom );
+        indexer.process( log );
+    }
+
+    // ----------------------------------------------------------------------
+    // private methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * 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.
+     *
+     * @param source
+     * @param filename
+     * @return A String with the store destination.
+     */
+    private String getDestination( String source, String filename )
+    {
+        //remove the source directory from the filename.
+
+        String dest = filename.substring( source.length(), filename.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.
+     *
+     * @param source The jave source file
+     * @param dest The directory to put the HTML into
+     * @throws IOException Thrown if the transform can't happen for some reason.
+     */
+    private void transform( String source, String dest )
+        throws IOException
+    {
+        log.debug( source + " -> " + dest );
+
+        // get a relative link to the javadocs
+        String javadoc = javadocLinkDir != null ? getRelativeLink( dest, javadocLinkDir ) : null;
+        transformer.transform( source, dest, locale, inputEncoding, outputEncoding, javadoc, this.revision );
+    }
+
+    /**
      * Creates a relative link from one directory to another.
      *
      * Example:
@@ -278,10 +344,10 @@
 
         // walk up fromDir to find the common parent
         f = new File( fromDir );
-		if ( !f.isDirectory() ) {
-			// Passed in a fromDir with a filename on the end - strip it
-			f = f.getParentFile();
-		}
+        if ( !f.isDirectory() ) {
+            // Passed in a fromDir with a filename on the end - strip it
+            f = f.getParentFile();
+        }
         f = f.getCanonicalFile();
         f = f.getParentFile();
         boolean found = false;
@@ -314,35 +380,4 @@
 
         return fromLink.append( toLink.toString() ).toString();
     }
-
-    public void xref( List sourceDirs, String templateDir, String windowTitle, String docTitle, String bottom )
-        throws IOException, JxrException
-    {
-        // first collect package and class info
-        FileManager fileManager = new FileManager();
-        fileManager.setEncoding( inputEncoding );
-
-        PackageManager pkgmgr = new PackageManager( log, fileManager );
-
-        // go through each source directory and xref the java files
-        for ( Iterator i = sourceDirs.iterator(); i.hasNext(); )
-        {
-            String path = (String) i.next();
-            path = new File( path ).getCanonicalPath();
-
-            pkgmgr.process( path );
-
-            processPath( pkgmgr, path );
-        }
-
-        // once we have all the source files xref'd, create the index pages
-        DirectoryIndexer indexer = new DirectoryIndexer( pkgmgr, dest );
-        indexer.setOutputEncoding( outputEncoding );
-        indexer.setTemplateDir( templateDir );
-        indexer.setWindowTitle( windowTitle );
-        indexer.setDocTitle( docTitle );
-        indexer.setBottom( bottom );
-        indexer.process( log );
-    }
 }
-

Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java
URL: http://svn.apache.org/viewvc/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java?view=diff&rev=474296&r1=474295&r2=474296
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java Mon Nov 13 05:17:05 2006
@@ -88,6 +88,9 @@
 public class JavaCodeTransform
     implements Serializable
 {
+    // ----------------------------------------------------------------------
+    // public fields
+    // ----------------------------------------------------------------------
 
     /**
      * show line numbers
@@ -151,6 +154,10 @@
     public static final char[] VALID_URI_CHARS = {'?', '+', '%', '&', ':', '/', '.', '@', '_', ';', '=', '$', ',', '-',
         '!', '~', '*', '\'', '(', ')'};
 
+    // ----------------------------------------------------------------------
+    // private fields
+    // ----------------------------------------------------------------------
+
     /**
      * HashTable containing java reserved words
      */
@@ -191,48 +198,486 @@
      */
     private String sourcedir = null;
 
+    /**
+     * The input encoding
+     */
     private String inputEncoding = null;
 
+    /**
+     * The output encoding
+     */
     private String outputEncoding = null;
 
+    /**
+     * The wanted locale
+     */
     private Locale locale = null;
 
-    /**
-     * Relative path to javadocs, suitable for hyperlinking
-     */
-    private String javadocLinkDir;
+    /**
+     * Relative path to javadocs, suitable for hyperlinking
+     */
+    private String javadocLinkDir;
+
+    /**
+     * Package Manager for this project.
+     */
+    private PackageManager packageManager;
+
+    /**
+     * current file manager
+     */
+    private FileManager fileManager;
+
+    // ----------------------------------------------------------------------
+    // constructor
+    // ----------------------------------------------------------------------
+
+    /**
+     * Constructor for the JavaCodeTransform object
+     *
+     * @param packageManager PackageManager for this project
+     */
+    public JavaCodeTransform( PackageManager packageManager )
+    {
+        this.packageManager = packageManager;
+        loadHash();
+        this.fileManager = packageManager.getFileManager();
+    }
+
+    // ----------------------------------------------------------------------
+    // public methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * Now different method of seeing if at end of input stream, closes inputs
+     * stream at end.
+     *
+     * @param line String
+     * @return filtered line of code
+     */
+    public final String syntaxHighlight( String line )
+    {
+        return htmlFilter( line );
+    }
+
+    /**
+     * Gets the header attribute of the JavaCodeTransform object
+     *
+     * @return String
+     */
+    public String getHeader()
+    {
+        StringBuffer buffer = new StringBuffer();
+
+        String outputEncoding = this.outputEncoding;
+        if ( outputEncoding == null )
+        {
+            outputEncoding = "ISO-8859-1";
+        }
+
+        // header
+        buffer
+            .append(
+                "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" )
+            .append( "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"" ).append( locale )
+            .append( "\" lang=\"" ).append( locale ).append( "\">\n" ).append( "<head>\n" )
+            .append( "<meta http-equiv=\"content-type\" content=\"text/html; charset=" ).append( outputEncoding )
+            .append( "\" />" );
+
+        // title ("classname xref")
+        try
+        {
+            buffer.append( "<title>" ).append( fileManager.getFile( this.getCurrentFilename() )
+                .getClassType().getName() ).append( " xref</title>\n" );
+
+        }
+        catch ( IOException e )
+        {
+            buffer.append( "<title>xref</title>\n" );
+            e.printStackTrace();
+        }
+
+        // stylesheet link
+        buffer.append( "<link type=\"text/css\" rel=\"stylesheet\" href=\"" ).append( this.getPackageRoot() )
+            .append( STYLESHEET_FILENAME ).append( "\" />\n" );
+
+        buffer.append( "</head>\n" ).append( "<body>\n" ).append( this.getFileOverview() );
+
+        // start code section
+        buffer.append( "<pre>\n" );
+
+        return buffer.toString();
+    }
+
+    /**
+     * Gets the footer attribute of the JavaCodeTransform object
+     *
+     * @return String
+     */
+    public final String getFooter()
+    {
+        return "</pre>\n" + "<hr/>" + "<div id=\"footer\">" + JXR.NOTICE + "</div>" + "</body>\n" + "</html>\n";
+    }
+
+    /**
+     * This is the public method for doing all transforms of code.
+     *
+     * @param sourceReader Reader
+     * @param destWriter Writer
+     * @param locale String
+     * @param inputEncoding String
+     * @param outputEncoding String
+     * @param javadocLinkDir String
+     * @param revision String
+     * @param showHeader boolean
+     * @param showFooter boolean
+     * @throws IOException
+     */
+    public final void transform( Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding,
+                                 String outputEncoding, String javadocLinkDir, String revision, boolean showHeader,
+                                 boolean showFooter )
+        throws IOException
+    {
+        this.locale = locale;
+        this.inputEncoding = inputEncoding;
+        this.outputEncoding = outputEncoding;
+        this.javadocLinkDir = javadocLinkDir;
+        this.revision = revision;
+
+        BufferedReader in = new BufferedReader( sourceReader );
+
+        PrintWriter out = new PrintWriter( destWriter );
+
+        String line = "";
+
+        if ( showHeader )
+        {
+            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;
+        }
+
+        if ( showFooter )
+        {
+            out.println( getFooter() );
+        }
+
+        out.flush();
+    }
+
+    /**
+     * This is the public method for doing all transforms of code.
+     *
+     * @param sourcefile String
+     * @param destfile String
+     * @param locale String
+     * @param inputEncoding String
+     * @param outputEncoding String
+     * @param javadocLinkDir String
+     * @param revision String
+     * @throws IOException
+     */
+    public final void transform( String sourcefile, String destfile, Locale locale, String inputEncoding,
+                                 String outputEncoding, String javadocLinkDir, String revision )
+        throws IOException
+    {
+        this.setCurrentFilename( sourcefile );
+
+        this.sourcefile = sourcefile;
+        this.destfile = destfile;
+
+        //make sure that the parent directories exist...
+        new File( new File( destfile ).getParent() ).mkdirs();
+
+        Reader fr = null;
+        Writer fw = null;
+        try
+        {
+            if ( inputEncoding != null )
+            {
+                fr = new InputStreamReader( new FileInputStream( sourcefile ), inputEncoding );
+            }
+            else
+            {
+                fr = new FileReader( sourcefile );
+            }
+            if ( outputEncoding != null )
+            {
+                fw = new OutputStreamWriter( new FileOutputStream( destfile ), outputEncoding );
+            }
+            else
+            {
+                fw = new FileWriter( destfile );
+            }
+
+            transform( fr, fw, locale, inputEncoding, outputEncoding, javadocLinkDir, revision, true, true );
+        }
+        catch ( RuntimeException e )
+        {
+            System.out.println( "Unable to processPath " + sourcefile + " => " + destfile );
+            throw e;
+        }
+        finally
+        {
+            if ( fr != null )
+            {
+                try
+                {
+                    fr.close();
+                }
+                catch ( Exception ex )
+                {
+                    ex.printStackTrace();
+                }
+            }
+            if ( fw != null )
+            {
+                try
+                {
+                    fw.close();
+                }
+                catch ( Exception ex )
+                {
+                    ex.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * Get the current filename
+     *
+     * @return String
+     */
+    public final String getCurrentFilename()
+    {
+        return this.currentFilename;
+    }
+
+    /**
+     * Set the current filename
+     *
+     * @param filename String
+     */
+    public final void setCurrentFilename( String filename )
+    {
+        this.currentFilename = filename;
+    }
+
+    /**
+     * From the current file, determine the package root based on the current
+     * path.
+     *
+     * @return String
+     */
+    public final String getPackageRoot()
+    {
+        StringBuffer buff = new StringBuffer();
+
+        JavaFile jf = null;
+
+        try
+        {
+            jf = fileManager.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
+     *
+     * @param line String
+     * @return String
+     */
+    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 ) && 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 = StringUtils.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 && !inJavadocComment )
+        {
+            return jxrFilter( line );
+        }
+
+        return line;
+    }
+
+    /**
+     * The current revision of the CVS module
+     *
+     * @return String
+     */
+    public final String getRevision()
+    {
+        return this.revision;
+    }
+
+    /**
+     * The current source file being read
+     *
+     * @return source file name
+     */
+    public final String getSourcefile()
+    {
+        return this.sourcefile;
+    }
+
+    /**
+     * The current dest file being written
+     *
+     * @return destination file name
+     */
+    public final String getDestfile()
+    {
+        return this.destfile;
+    }
+
+    /**
+     * The current source directory being read from.
+     *
+     * @return source directory
+     */
+    public final String getSourceDirectory()
+    {
+        return this.sourcedir;
+    }
+
+    /**
+     * Cross Reference the given line with JXR returning the new content.
+     *
+     * @param line String
+     * @param packageName String
+     * @param classType ClassType
+     * @return String
+     */
+    public final String xrLine( String line, String packageName, ClassType classType )
+    {
+        StringBuffer buff = new StringBuffer( line );
+
+        String link = null;
+        String find = null;
+        String href = null;
+
+        if ( classType != null )
+        {
+            href = this.getHREF( packageName, classType );
+            find = classType.getName();
+        }
+        else
+        {
+            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
+
+        //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();
 
-    /**
-     * Package Manager for this project.
-     */
-    private PackageManager packageManager;
+            buff.replace( start, end, replace );
 
-    private FileManager fileManager;
+        }
 
-    /**
-     * Constructor for the JavaCodeTransform object
-     *
-     * @param packageManager PackageManager for this project
-     */
-    public JavaCodeTransform( PackageManager packageManager )
-    {
-        this.packageManager = packageManager;
-        loadHash();
-        this.fileManager = packageManager.getFileManager();
+        return buff.toString();
     }
 
     /**
-     * Now different method of seeing if at end of input stream, closes inputs
-     * stream at end.
+     * Highlight the package in this line.
      *
-     * @param line String
-     * @return filtered line of code
+     * @param line input line
+     * @param packageName package name
+     * @return input line with linked package
      */
-    public final String syntaxHighlight( String line )
+    public final String xrLine( String line, String packageName )
     {
-        return htmlFilter( line );
+        String href = this.getHREF( packageName );
+
+        String find = packageName;
+
+        //build out what the link would be.
+        String link = "<a href=\"" + href + "\">" + find + "</a>";
+
+        return StringUtils.replace( line, find, link );
     }
 
+    // ----------------------------------------------------------------------
+    // private methods
+    // ----------------------------------------------------------------------
+
     /**
      * Filter html tags into more benign text.
      *
@@ -386,6 +831,7 @@
         {
             buf.append( stringFilter( line ) );
         }
+
         return buf.toString();
     }
 
@@ -397,7 +843,6 @@
      */
     private final String stringFilter( String line )
     {
-
         if ( line == null || line.equals( "" ) )
         {
             return "";
@@ -481,6 +926,7 @@
             }
         }
         buf.append( line );
+
         return uriFilter( buf.toString() );
     }
 
@@ -622,204 +1068,6 @@
     }
 
     /**
-     * Gets the header attribute of the JavaCodeTransform object
-     *
-     * @return String
-     */
-    public String getHeader()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        String outputEncoding = this.outputEncoding;
-        if ( outputEncoding == null )
-        {
-            outputEncoding = "ISO-8859-1";
-        }
-
-        // header
-        buffer
-            .append(
-                "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" )
-            .append( "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"" ).append( locale )
-            .append( "\" lang=\"" ).append( locale ).append( "\">\n" ).append( "<head>\n" )
-            .append( "<meta http-equiv=\"content-type\" content=\"text/html; charset=" ).append( outputEncoding )
-            .append( "\" />" );
-
-        // title ("classname xref")
-        try
-        {
-            buffer.append( "<title>" ).append( fileManager.getFile( this.getCurrentFilename() )
-                .getClassType().getName() ).append( " xref</title>\n" );
-
-        }
-        catch ( IOException e )
-        {
-            buffer.append( "<title>xref</title>\n" );
-            e.printStackTrace();
-        }
-
-        // stylesheet link
-        buffer.append( "<link type=\"text/css\" rel=\"stylesheet\" href=\"" ).append( this.getPackageRoot() )
-            .append( STYLESHEET_FILENAME ).append( "\" />\n" );
-
-        buffer.append( "</head>\n" ).append( "<body>\n" ).append( this.getFileOverview() );
-
-        // start code section
-        buffer.append( "<pre>\n" );
-
-        return buffer.toString();
-    }
-
-    /**
-     * Gets the footer attribute of the JavaCodeTransform object
-     *
-     * @return String
-     */
-    public final String getFooter()
-    {
-        return "</pre>\n" + "<hr/>" + "<div id=\"footer\">" + JXR.NOTICE + "</div>" + "</body>\n" + "</html>\n";
-    }
-
-    /**
-     * This is the public method for doing all transforms of code.
-     *
-     * @param sourceReader Reader
-     * @param destWriter Writer
-     * @param locale String
-     * @param inputEncoding String
-     * @param outputEncoding String
-     * @param javadocLinkDir String
-     * @param revision String
-     * @param showHeader boolean
-     * @param showFooter boolean
-     * @throws IOException
-     */
-    public final void transform( Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding,
-                                 String outputEncoding, String javadocLinkDir, String revision, boolean showHeader,
-                                 boolean showFooter )
-        throws IOException
-    {
-        this.locale = locale;
-        this.inputEncoding = inputEncoding;
-        this.outputEncoding = outputEncoding;
-        this.javadocLinkDir = javadocLinkDir;
-        this.revision = revision;
-
-        BufferedReader in = new BufferedReader( sourceReader );
-
-        PrintWriter out = new PrintWriter( destWriter );
-
-        String line = "";
-
-        if ( showHeader )
-        {
-            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;
-        }
-
-        if ( showFooter )
-        {
-            out.println( getFooter() );
-        }
-
-        out.flush();
-    }
-
-    /**
-     * This is the public method for doing all transforms of code.
-     *
-     * @param sourcefile String
-     * @param destfile String
-     * @param locale String
-     * @param inputEncoding String
-     * @param outputEncoding String
-     * @param javadocLinkDir String
-     * @param revision String
-     * @throws IOException
-     */
-    public final void transform( String sourcefile, String destfile, Locale locale, String inputEncoding,
-                                 String outputEncoding, String javadocLinkDir, String revision )
-        throws IOException
-    {
-
-        this.setCurrentFilename( sourcefile );
-
-        this.sourcefile = sourcefile;
-        this.destfile = destfile;
-
-        //make sure that the parent directories exist...
-        new File( new File( destfile ).getParent() ).mkdirs();
-
-        Reader fr = null;
-        Writer fw = null;
-        try
-        {
-            if ( inputEncoding != null )
-            {
-                fr = new InputStreamReader( new FileInputStream( sourcefile ), inputEncoding );
-            }
-            else
-            {
-                fr = new FileReader( sourcefile );
-            }
-            if ( outputEncoding != null )
-            {
-                fw = new OutputStreamWriter( new FileOutputStream( destfile ), outputEncoding );
-            }
-            else
-            {
-                fw = new FileWriter( destfile );
-            }
-
-            transform( fr, fw, locale, inputEncoding, outputEncoding, javadocLinkDir, revision, true, true );
-        }
-        catch ( RuntimeException e )
-        {
-            System.out.println( "Unable to processPath " + sourcefile + " => " + destfile );
-            throw e;
-        }
-        finally
-        {
-            if ( fr != null )
-            {
-                try
-                {
-                    fr.close();
-                }
-                catch ( Exception ex )
-                {
-                    ex.printStackTrace();
-                }
-            }
-            if ( fw != null )
-            {
-                try
-                {
-                    fw.close();
-                }
-                catch ( Exception ex )
-                {
-                    ex.printStackTrace();
-                }
-            }
-        }
-
-    }
-
-    /**
      * Get an overview header for this file.
      *
      * @return String
@@ -831,7 +1079,6 @@
         // only add the header if javadocs are present
         if ( javadocLinkDir != null )
         {
-
             overview.append( "<div id=\"overview\">" );
             //get the URI to get Javadoc info.
             StringBuffer javadocURI = new StringBuffer().append( javadocLinkDir );
@@ -865,6 +1112,7 @@
 
             overview.append( "</div>" );
         }
+
         return overview.toString();
     }
 
@@ -900,12 +1148,10 @@
      */
     private final String jxrFilter( String line )
     {
-
         JavaFile jf = null;
 
         try
         {
-
             //if the current file isn't set then just return
             if ( this.getCurrentFilename() == null )
             {
@@ -940,13 +1186,11 @@
         //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.
 
@@ -970,7 +1214,6 @@
 
                 if ( wordName.indexOf( "." ) != -1 )
                 {
-
                     //if there is a "." in the string then we have to assume
                     //it is a package.
 
@@ -988,7 +1231,6 @@
 
                     if ( pt != null )
                     {
-
                         ClassType ct = pt.getClassType( fqpn_class );
 
                         if ( ct != null )
@@ -998,57 +1240,28 @@
                             //link to it.
 
                             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.
                         line = xrLine( line, packages[j], currentImport.getClassType( fqpn_class ) );
-
                     }
-
                 }
                 else if ( currentImport.getClassType( wordName ) != null )
                 {
-
                     line = xrLine( line, packages[j], currentImport.getClassType( wordName ) );
-
                 }
-
             }
-
         }
 
         return importFilter( line );
     }
 
     /**
-     * Get the current filename
-     *
-     * @return String
-     */
-    public final String getCurrentFilename()
-    {
-        return this.currentFilename;
-    }
-
-    /**
-     * Set the current filename
-     *
-     * @param filename String
-     */
-    public final void setCurrentFilename( String filename )
-    {
-        this.currentFilename = filename;
-    }
-
-    /**
      * Given the current package, get an HREF to the package and class given
      *
      * @param dest String
@@ -1057,7 +1270,6 @@
      */
     private final String getHREF( String dest, ClassType jc )
     {
-
         StringBuffer href = new StringBuffer();
 
         //find out how to go back to the root
@@ -1101,19 +1313,16 @@
      */
     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 )
@@ -1139,7 +1348,6 @@
      */
     private final String importFilter( String line )
     {
-
         int start = -1;
 
         /*
@@ -1154,15 +1362,12 @@
 
         if ( isImport || 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.
@@ -1170,13 +1375,10 @@
 
             if ( pkg.indexOf( ".*" ) != -1 )
             {
-
                 pkg = StringUtils.replace( pkg, ".*", "" );
-
             }
             else if ( !isPackage )
             {
-
                 //this is an explicit Class import
 
                 String packageLine = pkg.toString();
@@ -1197,7 +1399,6 @@
                     classname = packageLine.substring( packageLine.lastIndexOf( "." ) + 1, packageLine.length() - 1 );
 
                     int end = pkg.lastIndexOf( "." );
-
                     if ( end == -1 )
                     {
                         end = pkg.length() - 1;
@@ -1205,7 +1406,6 @@
 
                     pkg = pkg.substring( 0, end );
                 }
-
             }
 
             pkg = StringUtils.replace( pkg, ";", "" );
@@ -1214,14 +1414,11 @@
 
             if ( packageManager.getPackageType( pkg ) != null || isPackage )
             {
-
                 //Create an HREF for explicit classname imports
                 if ( classname != null )
                 {
-
                     line = StringUtils.replace( line, classname, "<a href=\"" + pkgHREF + "/" + classname + ".html" +
                         "\">" + classname + "</a>" );
-
                 }
 
                 //now replace the given package with a href
@@ -1234,104 +1431,6 @@
         return line;
     }
 
-    /**
-     * From the current file, determine the package root based on the current
-     * path.
-     *
-     * @return String
-     */
-    public final String getPackageRoot()
-    {
-
-        StringBuffer buff = new StringBuffer();
-
-        JavaFile jf = null;
-
-        try
-        {
-            jf = fileManager.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
-     *
-     * @param line String
-     * @return String
-     */
-    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 ) && 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 = StringUtils.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 && !inJavadocComment )
-        {
-            return jxrFilter( line );
-        }
-        else
-        {
-            return line;
-        }
-
-    }
 
     /**
      * if the given char is not one of the following in VALID_URI_CHARS then
@@ -1342,7 +1441,6 @@
      */
     private final boolean isInvalidURICharacter( char c )
     {
-
         for ( int i = 0; i < VALID_URI_CHARS.length; ++i )
         {
             if ( VALID_URI_CHARS[i] == c )
@@ -1353,117 +1451,4 @@
 
         return true;
     }
-
-    /**
-     * The current revision of the CVS module
-     *
-     * @return String
-     */
-    public final String getRevision()
-    {
-        return this.revision;
-    }
-
-    /**
-     * The current source file being read
-     *
-     * @return source file name
-     */
-    public final String getSourcefile()
-    {
-        return this.sourcefile;
-    }
-
-    /**
-     * The current dest file being written
-     *
-     * @return destination file name
-     */
-    public final String getDestfile()
-    {
-        return this.destfile;
-    }
-
-    /**
-     * The current source directory being read from.
-     *
-     * @return source directory
-     */
-    public final String getSourceDirectory()
-    {
-        return this.sourcedir;
-    }
-
-    /**
-     * Cross Reference the given line with JXR returning the new content.
-     *
-     * @param line String
-     * @param packageName String
-     * @param classType ClassType
-     * @return String
-     */
-    public final String xrLine( String line, String packageName, ClassType classType )
-    {
-
-        StringBuffer buff = new StringBuffer( line );
-
-        String link = null;
-        String find = null;
-        String href = null;
-
-        if ( classType != null )
-        {
-            href = this.getHREF( packageName, classType );
-            find = classType.getName();
-        }
-        else
-        {
-            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
-
-        //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.
-     *
-     * @param line input line
-     * @param packageName package name
-     * @return input line with linked package
-     */
-    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>";
-
-        return StringUtils.replace( line, find, link );
-    }
-
 }