jvanzyl     2002/11/24 22:00:42

  Modified:    src/plugins-build/jxr maven.xml plugin.jelly
                        plugin.properties project.xml
               src/plugins-build/jxr/src/java/org/apache/maven/jxr
                        DirectoryIndexer.java JxrBean.java
               src/plugins-build/jxr/src/java/org/apache/maven/jxr/pacman
                        PackageManager.java
  Log:
  o applying bhl's patches for jxr to get the look 'n' feel in line with
    the rest of maven. nice!
  
  Revision  Changes    Path
  1.9       +4 -0      jakarta-turbine-maven/src/plugins-build/jxr/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/jxr/maven.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- maven.xml 3 Sep 2002 03:02:12 -0000       1.8
  +++ maven.xml 25 Nov 2002 06:00:41 -0000      1.9
  @@ -38,6 +38,10 @@
         file="${maven.build.dir}/${maven.final.name}.jar"
         todir="${maven.repo.local}/maven/jars"
       />
  +    <copy
  +      file="${maven.build.dir}/${maven.final.name}.jar"
  +      todir="/opt/maven/plugins"
  +    />
   
     </goal>
   
  
  
  
  1.5       +21 -4     jakarta-turbine-maven/src/plugins-build/jxr/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/jxr/plugin.jelly,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- plugin.jelly      5 Aug 2002 13:22:49 -0000       1.4
  +++ plugin.jelly      25 Nov 2002 06:00:41 -0000      1.5
  @@ -32,13 +32,28 @@
         />
       </define:taglib>
   
  +    <property
  +      name="copyright"
  +      value="Copyright &amp;copy; ${year} ${pom.organization.name}. All Rights 
Reserved."
  +    />
  +
  +    <property
  +      name="title"
  +      value="${pom.name} ${pom.currentVersion} Reference"
  +    />
  +
  +    <copy file="${maven.jxr.stylesheet}"
  +          tofile="${maven.jxr.destdir}/stylesheet.css"/>
  +        
       <jxr:jxr
         basedir="${basedir}"
         sourceDir="${pom.build.sourceDirectory}"
         destDir="${maven.jxr.destdir}"
  +      templateDir="${maven.jxr.templateDir}"
         javadocDir="${maven.javadoc.destdir}"
  -      imageFolder="${plugin.dir}/images/folder.gif"
  -      imageFile="${plugin.dir}/images/file.gif">
  +      windowTitle="${title}"
  +      docTitle="${title}"
  +      bottom="${copyright}">
       </jxr:jxr>
   
       <j:if test="${unitTestSourcesPresent == 'true'}">
  @@ -47,9 +62,11 @@
         basedir="${basedir}"
         sourceDir="${pom.build.unitTestSourceDirectory}"
         destDir="${maven.jxr.destdir}"
  +      templateDir="${maven.jxr.templateDir}"
         javadocDir="${maven.javadoc.destdir}"
  -      imageFolder="${plugin.dir}/images/folder.gif"
  -      imageFile="${plugin.dir}/images/file.gif">
  +      windowTitle="${title}"
  +      docTitle="${title}"
  +      bottom="${copyright}">
       </jxr:jxr>
   
       </j:if>
  
  
  
  1.3       +2 -0      jakarta-turbine-maven/src/plugins-build/jxr/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/jxr/plugin.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- plugin.properties 4 Aug 2002 20:58:52 -0000       1.2
  +++ plugin.properties 25 Nov 2002 06:00:41 -0000      1.3
  @@ -17,3 +17,5 @@
   
   maven.jxr.destdir = ${maven.docs.dest}/xref
   #maven.jxr.destdir.tests = ${maven.docs.dest}/xref-tests
  +maven.jxr.stylesheet = ${plugin.dir}/stylesheet.css
  +maven.jxr.templateDir = ${plugin.dir}/templates
  
  
  
  1.12      +56 -0     jakarta-turbine-maven/src/plugins-build/jxr/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/jxr/project.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- project.xml       16 Sep 2002 08:19:08 -0000      1.11
  +++ project.xml       25 Nov 2002 06:00:41 -0000      1.12
  @@ -64,6 +64,14 @@
       </dependency>
   
       <dependency>
  +      <id>commons-jelly</id>
  +      <version>SNAPSHOT</version>   
  +      <properties>
  +        <classloader>root.maven</classloader>
  +      </properties>
  +    </dependency>
  +
  +    <dependency>
         <id>commons-lang</id>
         <version>1.0-b1.1</version>
         <properties>
  @@ -72,10 +80,58 @@
       </dependency>
   
       <dependency>
  +      <id>dom4j</id>
  +      <version>1.4-dev-8</version>
  +      <properties>
  +        <classloader>root.maven</classloader>
  +      </properties>
  +    </dependency>
  +
  +    <dependency>
  +      <id>xerces</id>
  +      <version>2.0.2</version>
  +      <properties>
  +        <classloader>root.maven</classloader>
  +      </properties>
  +    </dependency>
  +
  +    <dependency>
  +      <id>oro</id>
  +      <version>2.0.6</version>
  +      <properties>
  +        <classloader>root.maven</classloader>
  +      </properties>
  +    </dependency>
  +
  +    <dependency>
  +      <id>sax</id>
  +      <version>2.0.1</version>
  +      <properties>
  +        <classloader>root.maven</classloader>
  +      </properties>
  +    </dependency>
  +
  +    <dependency>
  +      <id>jaxp</id>
  +      <version>1.2</version>
  +      <properties>
  +        <classloader>root.maven</classloader>
  +      </properties>
  +    </dependency>
  +    
  +    <dependency>
         <id>commons-logging</id>
         <version>1.0</version>
       </dependency>
   
  +    <dependency>
  +      <id>xml-apis</id>
  +      <version>1.0.b2</version>
  +      <properties>
  +        <classloader>root.maven</classloader>
  +      </properties>
  +    </dependency>
  +    
     </dependencies>
   
     <build>
  
  
  
  1.3       +208 -380  
jakarta-turbine-maven/src/plugins-build/jxr/src/java/org/apache/maven/jxr/DirectoryIndexer.java
  
  Index: DirectoryIndexer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/jxr/src/java/org/apache/maven/jxr/DirectoryIndexer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DirectoryIndexer.java     2 Aug 2002 02:21:34 -0000       1.2
  +++ DirectoryIndexer.java     25 Nov 2002 06:00:41 -0000      1.3
  @@ -54,464 +54,292 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.maven.jxr.pacman.PackageManager;
  +import org.apache.maven.jxr.pacman.PackageType;
  +import org.apache.maven.jxr.pacman.ClassType;
  +
   import java.io.File;
  -import java.io.FileInputStream;
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  -import java.io.PrintWriter;
  -import java.text.DateFormat;
  -import java.util.Collections;
  -import java.util.Date;
  -import java.util.StringTokenizer;
  -import java.util.Vector;
  +import java.util.Enumeration;
  +import java.util.TreeMap;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.Map;
  +
  +import org.apache.oro.text.perl.Perl5Util;
   
  -import org.apache.commons.lang.StringUtils;
  +import org.apache.commons.jelly.JellyContext;
  +import org.apache.commons.jelly.XMLOutput;
   
   /**
  - * Handles building a directory index of files and directories.
  + * This class creates the navigational pages for jxr's cross-referenced source
  + * files.  The navigation is inspired by javadoc, so it should have a familiar feel.
  + *
  + * Creates the following files:
  + * <ul>
  + *   <li>index.html            main index containing the frameset</li>
  + *   <li>overview-frame.html   list of the project's packages              (top 
left)</li>
  + *   <li>allclasses-frame.html list of all classes in the project          (bottom 
left)</li>
  + *   <li>overview-summary.html top-level listing of the project's packages (main 
frame)</li>
    *
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Kevin A. Burton</a>
  + *   <ul>
  + *   Package specific:
  + *     <li>package-summary.html listing of all classes in this package    (main 
frame)</li>
  + *     <li>package-frame.html   listing of all classes in this package    (bottom 
left)</li>
  + *   </ul>
  + * </ul>
  + *
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Brian Leonard</a>
    * @version $Id$
    */
   public class DirectoryIndexer
   {
  +    /*
  +     * CodeTransform uses this to cross-reference package references
  +     * with that package's main summary page.
  +     */
  +    final static String INDEX = "package-summary.html";
   
  -    /**
  -     * Description of the Field
  +    /*
  +     * Path to the root output directory.
        */
  -    public final static int MODE_FULL = 1;
  -    
  -    /**
  -     * Description of the Field
  +    private String root;
  +
  +    /*
  +     * Package Manager for this project.
        */
  -    public final static int MODE_JAVA = 2;
  +    private PackageManager packageManager;
       
  -    /**
  -     * Description of the Field
  +    /*
  +     * see the getter/setter docs for these properties
        */
  -    public final static int MODE_DEFAULT = MODE_JAVA;
  +    private String templateDir;
  +    private String windowTitle;
  +    private String docTitle;
  +    private String bottom;
  +    
   
       /**
  -     * Description of the Field
  +     * Constructor for the DirectoryIndexer object
  +     *
  +     * @param packageManager  PackageManager for this project
  +     * @param root            Path of the root output directory
        */
  -    public final static String INDEX = "index.html";
  +    public DirectoryIndexer(PackageManager packageManager, String root)
  +    {
  +        this.packageManager = packageManager;
  +        this.root = root;
  +    }
   
       /**
  -     * Description of the Field
  -     */
  -    public final static String IMAGE_FOLDER = "./folder.gif";
  -    
  -    /**
  -     * Description of the Field
  +     * TemplateDir is the location of the jelly template files used
  +     * to generate the navigation pages.
  +     *
  +     * @param templateDir location of the template directory
        */
  -    
  -    public final static String IMAGE_FILE = "./file.gif";
  +    public void setTemplateDir(String templateDir)
  +    {
  +        this.templateDir = templateDir;
  +    }
  +
       /**
  -     * Description of the Field
  +     * see setTemplateDir(String)
  +     *
  +     * @see setTemplateDir(String)
        */
  +    public String getTemplateDir()
  +    {
  +        return templateDir;
  +    }
       
  -    public final static int IMAGE_WIDTH = 15;
  -
  -    private File directory = null;
  -
  -    private String image_folder = "";
  -
  -    private String image_file = "";
  -
       /**
  -     * Optionally specify the global root for a DirectoryIndexer.
  +     * WindowTitle is used in the output's &lt;title&gt; tags
  +     * see the javadoc documentation for the property of the same name
  +     *
  +     * @param windowTitle the &lt;title&gt; attribute
        */
  -    private String root = null;
  +    public void setWindowTitle(String windowTitle)
  +    {
  +        this.windowTitle = windowTitle;
  +    }
   
       /**
  -     * Relative link to the (optional) root xref directory
  +     * see setWindowTitle(String)
  +     *
  +     * @see #setWindowTitle(String) setWindowTitle
        */
  -    private StringBuffer rootLink = new StringBuffer();
  -
  -
  -    private int mode = MODE_DEFAULT;
  -
  -
  -    /**
  -     * @see DirectoryIndexer
  -     * @param directory
  -     * @param image_folder
  -     * @param image_file
  -     * @exception IOException
  -     */
  -    public DirectoryIndexer(String directory,
  -                            String image_folder,
  -                            String image_file)
  -        throws IOException
  +    public String getWindowTitle()
       {
  -
  -        this(directory, image_folder, image_file, MODE_JAVA);
  -
  +        return windowTitle;
       }
   
       /**
  -     * Create a given DirectoryIndexer with the given dir, images, etc
  +     * DocTitle is used as a page heading for the summary files
  +     * see the javadoc documentation for the property of the same name
        *
  -     * @param directory
  -     * @param image_folder
  -     * @param image_file
  -     * @param mode
  -     * @exception IOException
  -     */
  -    public DirectoryIndexer(String directory,
  -                            String image_folder,
  -                            String image_file,
  -                            int mode)
  -        throws IOException
  +     * @param docTitle major page heading
  +     */
  +    public void setDocTitle(String docTitle)
       {
  -
  -        this(null, directory, image_folder, image_file, mode);
  -
  +        this.docTitle = docTitle;
       }
   
       /**
  -     * Constructor for the DirectoryIndexer object
  +     * see setDocTitle(String)
        *
  -     * @param root
  -     * @param directory
  -     * @param image_folder
  -     * @param image_file
  -     * @param mode
  -     * @exception IOException
  -     */
  -    public DirectoryIndexer(String root,
  -                            String directory,
  -                            String image_folder,
  -                            String image_file,
  -                            int mode)
  -        throws IOException
  +     * @see #setDocTitle(String) setDocTitle
  +     */
  +    public String getDocTitle()
       {
  -
  -        this.root = root;
  -
  -        this.directory = new File(new File(directory).getCanonicalPath());
  -        this.image_folder = image_folder;
  -        this.image_file = image_file;
  -
  -        // copy image files to the root directory only, or
  -        // to each subdirectory if no root is specified
  -        if ((root != null &&
  -            new File(root).getCanonicalPath()
  -             .equals(this.directory.getCanonicalPath())) ||
  -            root == null)
  -        {
  -            copy(image_folder,
  -                 directory + System.getProperty("file.separator") + 
  -                 DirectoryIndexer.IMAGE_FOLDER);
  -        
  -            copy(image_file,
  -                 directory + System.getProperty("file.separator") + 
  -                 DirectoryIndexer.IMAGE_FILE);
  -        }
  -
  -        this.process();
  +        return docTitle;
       }
   
       /**
  -     * Process the directory
  +     * Bottom is a footer for the navigation pages, usually a copyright
  +     * see the javadoc documentation for the property of the same name
  +     *
  +     * @param bottom page footer
        */
  -    private final void process()
  -        throws IOException
  +    public void setBottom(String bottom)
       {
  -
  -        if (!directory.isDirectory())
  -        {
  -            throw new IOException("Not a directory");
  -        }
  -
  -        String index = directory.getAbsolutePath() +
  -            System.getProperty("file.separator") +
  -            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)
  -            {
  -                rootLink.append("../");
  -                
  -                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=\"");
  -                        rootLink.append("../");
  -
  -                        for (int i = 0; i < toke.countTokens(); i++)
  -                        {
  -                            out.print("../");
  -                        }
  -                        out.print(INDEX + "\">" + subpkg + "</a>.");
  -                    }
  -                    else
  -                    {
  -                        out.print(subpkg);
  -                    }
  -                }
  -
  -                pkg = StringUtils.replace(pkg, 
System.getProperty("file.separator"), ".");
  -
  -                out.println("</b></p>");
  -
  -            }
  -
  -        }
  -        
  -        out.println("<a href=\"../" + INDEX + "\">[parent]</a>");
  -        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();
  -
  +        this.bottom = bottom;
       }
   
       /**
  -     * Make an href for a file
  +     * see setBottom(String)
  +     *
  +     * @see #setBottom(String) setBottom
        */
  -    private final String getItem(File item)
  +    public String getBottom()
       {
  -
  -        String image = IMAGE_FILE;
  -        String href = item.getName();
  -        String name = item.getName();
  -
  -        if (item.isDirectory())
  -        {
  -
  -            href = item.getName() + "/" + INDEX;
  -
  -            image = rootLink + IMAGE_FOLDER;
  -        }
  -
  -        //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) + ".java";
  -            }
  -
  -            image = rootLink + 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>";
  +        return bottom;
       }
  -
  +    
       /**
  -     * Get the directories
  +     * Does the actual indexing.
  +     *
  +     * @throws Exception If something went wrong with jelly's processing.
        */
  -    private final String[] getDirs()
  -        throws IOException
  +    public void process()
  +        throws Exception
       {
  +        Map info = getPackageInfo();
   
  -        Vector v = new Vector();
  -
  -        String[] list = directory.list();
  +        JellyContext mainContext = new JellyContext();
  +        mainContext.setVariable("windowTitle", getWindowTitle());
  +        mainContext.setVariable("docTitle", getDocTitle());
  +        mainContext.setVariable("bottom", getBottom());
  +        mainContext.setVariable("info", info);
  +        
  +        doJellyFile("index",            root, mainContext);
  +        doJellyFile("overview-frame",   root, mainContext);
  +        doJellyFile("allclasses-frame", root, mainContext);
  +        doJellyFile("overview-summary", root, mainContext);
   
  -        for (int i = 0; i < list.length; ++i)
  +        Iterator iter = ((Map)info.get("allPackages")).values().iterator();
  +        while (iter.hasNext())
           {
  +            Map pkgInfo = (Map)iter.next();
   
  -            String item = directory.getAbsolutePath() +
  -                System.getProperty("file.separator") +
  -                list[i];
  -
  -            if (new File(item).isDirectory())
  -            {
  -                v.addElement(item);
  -            }
  +            JellyContext subContext = mainContext.newJellyContext();
  +            subContext.setVariable("pkgInfo", pkgInfo);
   
  +            String outDir = root + "/" + (String)pkgInfo.get("dir");
  +            doJellyFile("package-summary", outDir, subContext);
  +            doJellyFile("package-frame",   outDir, subContext);
           }
  -
  -        Collections.sort(v);
  -        String[] found = new String[v.size()];
  -        v.copyInto(found);
  -        return found;
       }
   
  -    /**
  -     * Get the files
  +    /*
  +     * executes a given jelly file with the given context and places the
  +     * generated file in outDir.  File names are assumed to be
  +     * {templateName}.jelly for input and {templateName}.html for output
  +     *
        */
  -    private final String[] getFiles()
  -        throws IOException
  +    private void doJellyFile(String templateName, String outDir, JellyContext 
context)
  +        throws Exception
       {
  -        Vector v = new Vector();
  +        String outFile = outDir + "/" + templateName + ".html";
  +        String templateFileName = getTemplateDir() + "/" + templateName + ".jelly";
  +        File templateFile = new File(templateFileName);
  +        
  +        OutputStream out = new FileOutputStream(outFile);
  +        XMLOutput xmlOutput = XMLOutput.createXMLOutput(out, false);
  +        context.runScript(templateFile, xmlOutput);
  +        xmlOutput.flush();
  +        out.close();
  +    }        
  +        
   
  -        String[] list = directory.list();
  +    /*
  +     * Creates a Map of other Maps containing information about
  +     * this project's packages and classes, obtained from the PackageManager.
  +     *
  +     * allPackages collection of Maps with package info, with the following format
  +     *   {name}    package name (e.g., "org.apache.maven.jxr")
  +     *   {dir}     package dir relative to the root output dir (e.g., 
"org/apache/maven/jxr")
  +     *   {rootRef} relative link to root output dir (e.g., "../../../../") note 
trailing slash
  +     *   {classes} collection of Maps with class info
  +     *      {name}  class name (e.g., "DirectoryIndexer")
  +     *      {dir}   duplicate of package {dir}
  +     *
  +     * allClasses collection of Maps with class info, format as above
  +     *
  +     */
  +    private Map getPackageInfo()
  +    {
  +        TreeMap allPackages = new TreeMap();
  +        TreeMap allClasses  = new TreeMap();
  +        Perl5Util perl = new Perl5Util();
   
  -        for (int i = 0; i < list.length; ++i)
  +        Enumeration packages = packageManager.getPackageTypes();
  +        while (packages.hasMoreElements())
           {
  -
  -            String item = directory.getAbsolutePath() +
  -                System.getProperty("file.separator") +
  -                list[i];
  -
  -            //don't process the index file
  -            if (list[i].equals(INDEX))
  +            PackageType pkg = (PackageType)packages.nextElement();
  +            String pkgName = pkg.getName();
  +            String pkgDir  = perl.substitute("s/\\./\\//g", pkgName);
  +            String rootRef = perl.substitute("s/[^\\.]*(\\.|$)/\\.\\.\\//g", 
pkgName);
  +            
  +            // special case for the default package
  +            // javadoc doesn't deal with it, but it's easy for us
  +            if (pkgName.length() == 0)
               {
  -                continue;
  +                pkgName = "(default package)";
  +                pkgDir = ".";
  +                rootRef = "./";
               }
   
  -            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())
  +            TreeMap pkgClasses = new TreeMap();
  +            Enumeration classes = pkg.getClassTypes();
  +            while (classes.hasMoreElements())
               {
  +                ClassType clazz = (ClassType)classes.nextElement();
  +                
  +                String className = clazz.getName();
  +                Map classInfo = new HashMap();
  +                classInfo.put("name", className);
  +                classInfo.put("dir", pkgDir);
   
  -                v.addElement(item);
  -
  -            }
  -            else if (this.getMode() == MODE_DEFAULT &&
  -                filename.equals(INDEX) == false &&
  -                filename.equals(new File(IMAGE_FOLDER).getName()) == false &&
  -                filename.equals(new File(IMAGE_FILE).getName()) == false &&
  -                new File(item).isFile())
  -            {
  -
  -                v.addElement(item);
  -
  +                pkgClasses.put(className, classInfo);
  +                allClasses.put(className, classInfo);
               }
   
  +            Map pkgInfo = new HashMap();
  +            pkgInfo.put("name", pkgName);
  +            pkgInfo.put("dir", pkgDir);
  +            pkgInfo.put("classes", pkgClasses);
  +            pkgInfo.put("rootRef", rootRef);
  +            allPackages.put(pkgName, pkgInfo);
           }
   
  -        Collections.sort(v);
  -        String[] found = new String[v.size()];
  -        v.copyInto(found);
  -        return found;
  -    }
  -
  +        Map info = new HashMap();
  +        info.put("allPackages", allPackages);
  +        info.put("allClasses",  allClasses);
   
  -    /**
  -     * Copy one file to another file
  -     */
  -    public void copy(String source, String dest)
  -        throws IOException
  -    {
  -
  -                             InputStream is = null;
  -                             OutputStream os = null;
  -                             try {
  -             is = new FileInputStream(source);
  -             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);
  -             }
  -                             } finally {
  -             if (is != null) {is.close();}
  -             if (os != null) {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();
  +        return info;
       }
   }
  -
  
  
  
  1.3       +126 -75   
jakarta-turbine-maven/src/plugins-build/jxr/src/java/org/apache/maven/jxr/JxrBean.java
  
  Index: JxrBean.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/jxr/src/java/org/apache/maven/jxr/JxrBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JxrBean.java      24 Jul 2002 05:54:39 -0000      1.2
  +++ JxrBean.java      25 Nov 2002 06:00:41 -0000      1.3
  @@ -59,6 +59,12 @@
   import org.apache.maven.jxr.JXR;
   import org.apache.maven.jxr.DirectoryIndexer;
   import org.apache.maven.jxr.pacman.PackageManager;
  +
  +import org.apache.maven.jxr.pacman.PackageManager;
  +import org.apache.maven.jxr.pacman.PackageType;
  +import org.apache.maven.jxr.pacman.ClassType;
  +import java.util.Enumeration;
  +
   import java.util.List;
   import java.util.LinkedList;
   import java.util.Iterator;
  @@ -85,36 +91,17 @@
        */
       private static final Log log = LogFactory.getLog(JxrBean.class);
   
  -    /**
  -     * Base directory to work from.
  +    /*
  +     * See the doc comments for the corresponding getter/setter methods
        */
       private File basedir;
  -
  -    /**
  -     * Directories to be cross-referenced
  -     */
       private List sourceDirs;
  -
  -    /**
  -     * the destination directory
  -     */
       private String destDir;
  -
  -    /**
  -     * Root javadocs directory
  -     */
       private String javadocDir;
  -
  -    /**
  -     * the location of the folder.gif
  -     */
  -    private String imageFolder;
  -
  -    /**
  -     * the location of the file.gif
  -     */
  -    private String imageFile;
  -
  +    private String windowTitle;
  +    private String docTitle;;
  +    private String bottom;;
  +    private String templateDir;;
   
       /**
        * Default constructor
  @@ -126,21 +113,20 @@
   
       /**
        * Starts the cross-referencing and indexing.
  +     *
        * @throws IOException when any error occurs
        */
       public void xref()
  -        throws IOException
  +        throws Exception
       {
           // get a relative link to the javadocs
           String javadocLinkDir = null;
           javadocLinkDir = getRelativeLink(destDir, javadocDir);
           
  -        // go through each source directory and xref the java files
  +        // first collect package and class info
           PackageManager pkgmgr = PackageManager.getInstance();
           
  -        log.debug("sourceDir: " + sourceDirs.get(0));
  -        log.debug("sourcdDirs: " + sourceDirs.size());
  -        
  +        // go through each source directory and xref the java files
           for (Iterator i = sourceDirs.iterator(); i.hasNext();)
           {
               String path = (String) i.next();
  @@ -152,12 +138,18 @@
           }
           
           // once we have all the source files xref'd, create the index pages
  -        new DirectoryIndexer(destDir, destDir, imageFolder, imageFile,
  -                             DirectoryIndexer.MODE_JAVA);
  +        DirectoryIndexer indexer = new DirectoryIndexer(pkgmgr, destDir);
  +        indexer.setTemplateDir(getTemplateDir());
  +        indexer.setWindowTitle(getWindowTitle());
  +        indexer.setDocTitle(getDocTitle());
  +        indexer.setBottom(getBottom());
  +        indexer.process();
       }
       
       /**
  -     * Set the base dir
  +     * Set the base directory to which the sourceDirs are relative
  +     *
  +     * @param basedir base directory
        */
       public void setBasedir(File basedir)
       {
  @@ -165,7 +157,9 @@
       }
       
       /**
  -     * Get the basedir
  +     * see setBaseDir(File)
  +     *
  +     * @see setBasedir(File)
        */
       public File getBasedir()
       {
  @@ -245,97 +239,154 @@
       }
   
       /**
  -     * Sets the imageFile attribute
  -     * @param imageFile the image to be used for the {@link DirectoryIndexer}
  +     * Sets a single source directory to be cross-referenced.
  +     *
  +     * @param sourceDir The source directory to be cross-referenced.
        */
  -    public void setImageFile(String imageFile)
  +    public void setSourceDir(String sourceDir)
       {
  -        this.imageFile = imageFile;
  +        if (!sourceDirs.isEmpty())
  +        {
  +            sourceDirs.clear();
  +        }
  +        addSourceDir(sourceDir);
       }
   
       /**
  -     * Gets the imageFile attribute
  +     * Adds a directory to the list of those to be cross-referenced.
  +     *
  +     * @param sourceDir The source directory to be cross-referenced.
        */
  -    public String getImageFile()
  +    public void addSourceDir(String sourceDir)
       {
  -        return imageFile;
  +        sourceDirs.add(sourceDir);
       }
   
   
       /**
  -     * Sets the imageFolder attribute
  -     * @param imageFolder the folder for the {@link #imageFile}
  +     * DestDir is the directory in which jxr will write its output
  +     *
  +     * @param destDir the destination directory for jxr output
        */
  -    public void setImageFolder(String imageFolder)
  +    public void setDestDir(String destDir)
       {
  -        this.imageFolder = imageFolder;
  +        this.destDir = destDir;
       }
   
       /**
  -     * Gets the imageFolder attribute
  +     * see setDestDir(String)
  +     *
  +     * @see setDestDir(String)
        */
  -    public String setImageFolder()
  +    public String getDestDir()
       {
  -        return imageFolder;
  +        return destDir;
       }
   
   
       /**
  -     * Sets a single source directory to be cross-referenced.
  -     * @param sourceDir The source directory to be cross-referenced.
  +     * JavadocDir is used to cross-reference the source code with
  +     * the appropriate javadoc pages.
  +     *
  +     * @param javadocDir The root directory containing javadocs
        */
  -    public void setSourceDir(String sourceDir)
  +    public void setJavadocDir(String javadocDir)
       {
  -        if (!sourceDirs.isEmpty())
  -        {
  -            sourceDirs.clear();
  -        }
  -        addSourceDir(sourceDir);
  +        this.javadocDir = javadocDir;
       }
   
       /**
  -     * Adds a source directory to be cross-referenced.
  -     * @param sourceDir The source directory to be cross-referenced.
  +     * see setJavadocDir(String)
  +     *
  +     * @see setJavadocDir(String)
        */
  -    public void addSourceDir(String sourceDir)
  +    public String getJavadocDir()
       {
  -        sourceDirs.add(sourceDir);
  +        return javadocDir;
       }
   
  +    /**
  +     * see DirectoryIndexer
  +     *
  +     * @param windowTitle used by DirectoryIndexer
  +     * @see DirectoryIndexer#setWindowTitle(String) setWindowTitle(String)
  +     */
  +    public void setWindowTitle(String windowTitle)
  +    {
  +        this.windowTitle = windowTitle;
  +    }
   
       /**
  -     * Sets the destDir attribute
  -     * @param destDir the destination directory for jxr output
  +     * see DirectoryIndexer
  +     *
  +     * @see DirectoryIndexer#setWindowTitle(String) setWindowTitle(String)
        */
  -    public void setDestDir(String destDir)
  +    public String getWindowTitle()
       {
  -        this.destDir = destDir;
  +        return windowTitle;
       }
   
       /**
  -     * Gets the destDir attribute
  +     * see DirectoryIndexer
  +     *
  +     * @param docTitle used by DirectoryIndexer
  +     * @see DirectoryIndexer#setDocTitle(String) setDocTitle(String)
        */
  -    public String getDestDir()
  +    public void setDocTitle(String docTitle)
       {
  -        return destDir;
  +        this.docTitle = docTitle;
       }
   
  +    /**
  +     * see DirectoryIndexer
  +     *
  +     * @see DirectoryIndexer#setDocTitle(String) setDocTitle(String)
  +     */
  +    public String getDocTitle()
  +    {
  +        return docTitle;
  +    }
   
       /**
  -     * Sets the javadocDir attribute of the JxrTask object
  -     * @param javadocDir The root directory containing javadocs
  +     * see DirectoryIndexer
  +     *
  +     * @param bottom used by DirectoryIndexer
  +     * @see DirectoryIndexer#setBottom(String) setBottom(String)
        */
  -    public void setJavadocDir(String javadocDir)
  +    public void setBottom(String bottom)
       {
  -        this.javadocDir = javadocDir;
  +        this.bottom = bottom;
       }
   
       /**
  -     * Gets the javadocDir attribute of the JxrTask object
  +     * see DirectoryIndexer
  +     *
  +     * @see DirectoryIndexer#setBottom(String) setBottom(String)
        */
  -    public String setJavadocDir()
  +    public String getBottom()
       {
  -        return javadocDir;
  +        return bottom;
  +    }
  +
  +    /**
  +     * TemplateDir is where the navigation templates are located
  +     *
  +     * @param templateDir the template directory
  +     */
  +    public void setTemplateDir(String templateDir)
  +    {
  +        this.templateDir = templateDir;
  +    }
  +
  +    /**
  +     * see setTemplateDir(String)
  +     *
  +     * @see setTemplateDir(String) setTemplateDir(String)
  +     */
  +    public String getTemplateDir()
  +    {
  +        return templateDir;
       }
  +
   }
   
  
  
  
  1.2       +5 -21     
jakarta-turbine-maven/src/plugins-build/jxr/src/java/org/apache/maven/jxr/pacman/PackageManager.java
  
  Index: PackageManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/jxr/src/java/org/apache/maven/jxr/pacman/PackageManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageManager.java       14 Jul 2002 19:09:26 -0000      1.1
  +++ PackageManager.java       25 Nov 2002 06:00:41 -0000      1.2
  @@ -107,25 +107,9 @@
       /**
        * Get all of the packages in the PackageManager
        */
  -    public PackageType[] getPackageTypes()
  +    public Enumeration 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;
  +       return packages.elements();
       }
   
       /**
  @@ -231,13 +215,13 @@
   
           log("Dumping out PackageManager structure");
   
  -        PackageType[] pts = this.getPackageTypes();
  +        Enumeration pts = this.getPackageTypes();
   
  -        for (int i = 0; i < pts.length; ++i)
  +        while (pts.hasMoreElements())
           {
   
               //get the current package and print it.
  -            PackageType current = pts[i];
  +            PackageType current = (PackageType)pts.nextElement();
   
               log(current.getName());
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to