switch to jxr library
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@292654 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
56a3ecf789
commit
4e5c47573b
@ -24,4 +24,4 @@ maven.jxr.destdir = ${maven.docs.dest}/xref
|
||||
maven.jxr.destdir.test = ${maven.docs.dest}/xref-test
|
||||
|
||||
maven.jxr.stylesheet = ${plugin.resources}/stylesheet.css
|
||||
maven.jxr.templateDir = ${plugin.resources}/templates
|
||||
maven.jxr.templateDir = templates
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
# -------------------------------------------------------------------
|
||||
# Copyright 2001-2004 The Apache Software Foundation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# P R O J E C T P R O P E R T I E S
|
||||
# -------------------------------------------------------------------
|
||||
@ -22,7 +22,7 @@
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>maven-jxr-plugin</id>
|
||||
<name>Maven JXR Plug-in</name>
|
||||
<currentVersion>1.4.3</currentVersion>
|
||||
<currentVersion>1.5-SNAPSHOT</currentVersion>
|
||||
<description>Create cross reference.</description>
|
||||
<shortDescription>Create cross reference</shortDescription>
|
||||
<url>http://maven.apache.org/reference/plugins/jxr/</url>
|
||||
@ -56,77 +56,36 @@
|
||||
</developers>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.5.3-1</version>
|
||||
<properties>
|
||||
<classloader>root</classloader>
|
||||
</properties>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly</artifactId>
|
||||
<version>1.0-beta-4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly-tags-jsl</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly-tags-xml</artifactId>
|
||||
<version>1.0</version>
|
||||
<url>http://jakarta.apache.org/commons/jelly/libs/xml/</url>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.4-dev-8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xerces</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>oro</groupId>
|
||||
<artifactId>oro</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-jxr</artifactId>
|
||||
<version>1.0-beta-1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<!-- Transitive deps -->
|
||||
<dependency>
|
||||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
<version>1.0.b2</version>
|
||||
<properties>
|
||||
<classloader>root</classloader>
|
||||
</properties>
|
||||
<groupId>oro</groupId>
|
||||
<artifactId>oro</artifactId>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils-core</artifactId>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jexl</groupId>
|
||||
<artifactId>commons-jexl</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<versions>
|
||||
<version>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,358 +0,0 @@
|
||||
package org.apache.maven.jxr;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.jelly.JellyContext;
|
||||
import org.apache.commons.jelly.XMLOutput;
|
||||
import org.apache.maven.jxr.pacman.ClassType;
|
||||
import org.apache.maven.jxr.pacman.PackageManager;
|
||||
import org.apache.maven.jxr.pacman.PackageType;
|
||||
import org.apache.oro.text.perl.Perl5Util;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*
|
||||
* <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:brian@brainslug.org">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";
|
||||
|
||||
/*
|
||||
* Path to the root output directory.
|
||||
*/
|
||||
private String root;
|
||||
|
||||
/*
|
||||
* Package Manager for this project.
|
||||
*/
|
||||
private PackageManager packageManager;
|
||||
|
||||
/*
|
||||
* see the getter/setter docs for these properties
|
||||
*/
|
||||
private String outputEncoding;
|
||||
private String templateDir;
|
||||
private String windowTitle;
|
||||
private String docTitle;
|
||||
private String bottom;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the DirectoryIndexer object
|
||||
*
|
||||
* @param packageManager PackageManager for this project
|
||||
* @param root Path of the root output directory
|
||||
*/
|
||||
public DirectoryIndexer(PackageManager packageManager, String root)
|
||||
{
|
||||
this.packageManager = packageManager;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
/**
|
||||
* OutputEncoding is the encoding of output files.
|
||||
*
|
||||
* @param outputEncoding output Encoding
|
||||
*/
|
||||
public void setOutputEncoding(String outputEncoding)
|
||||
{
|
||||
this.outputEncoding = outputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setOutputEncoding(String)
|
||||
*
|
||||
* @see setOutputEncoding(String)
|
||||
*/
|
||||
public String getOutputEncoding()
|
||||
{
|
||||
return outputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplateDir is the location of the jelly template files used
|
||||
* to generate the navigation pages.
|
||||
*
|
||||
* @param templateDir location of the template directory
|
||||
*/
|
||||
public void setTemplateDir(String templateDir)
|
||||
{
|
||||
this.templateDir = templateDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setTemplateDir(String)
|
||||
*
|
||||
* @see setTemplateDir(String)
|
||||
*/
|
||||
public String getTemplateDir()
|
||||
{
|
||||
return templateDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* WindowTitle is used in the output's <title> tags
|
||||
* see the javadoc documentation for the property of the same name
|
||||
*
|
||||
* @param windowTitle the <title> attribute
|
||||
*/
|
||||
public void setWindowTitle(String windowTitle)
|
||||
{
|
||||
this.windowTitle = windowTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setWindowTitle(String)
|
||||
*
|
||||
* @see #setWindowTitle(String) setWindowTitle
|
||||
*/
|
||||
public String getWindowTitle()
|
||||
{
|
||||
return windowTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* DocTitle is used as a page heading for the summary files
|
||||
* see the javadoc documentation for the property of the same name
|
||||
*
|
||||
* @param docTitle major page heading
|
||||
*/
|
||||
public void setDocTitle(String docTitle)
|
||||
{
|
||||
this.docTitle = docTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setDocTitle(String)
|
||||
*
|
||||
* @see #setDocTitle(String) setDocTitle
|
||||
*/
|
||||
public String getDocTitle()
|
||||
{
|
||||
return docTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public void setBottom(String bottom)
|
||||
{
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setBottom(String)
|
||||
*
|
||||
* @see #setBottom(String) setBottom
|
||||
*/
|
||||
public String getBottom()
|
||||
{
|
||||
return bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual indexing.
|
||||
*
|
||||
* @throws Exception If something went wrong with jelly's processing.
|
||||
*/
|
||||
public void process()
|
||||
throws Exception
|
||||
{
|
||||
Map info = getPackageInfo();
|
||||
|
||||
JellyContext mainContext = new JellyContext();
|
||||
mainContext.setVariable("outputEncoding", getOutputEncoding());
|
||||
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);
|
||||
|
||||
Iterator iter = ((Map)info.get("allPackages")).values().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Map pkgInfo = (Map)iter.next();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 void doJellyFile(String templateName, String outDir, JellyContext context)
|
||||
throws Exception
|
||||
{
|
||||
String outFile = outDir + "/" + templateName + ".html";
|
||||
OutputStream out = null;
|
||||
try
|
||||
{
|
||||
// Throws FileNotFoundException
|
||||
out = new FileOutputStream(outFile);
|
||||
|
||||
String templateFileName = getTemplateDir() + "/" + templateName + ".jelly";
|
||||
File templateFile = new File(templateFileName);
|
||||
|
||||
File theFile = new File(outFile);
|
||||
File dir = theFile.getParentFile();
|
||||
if (dir != null)
|
||||
{
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
XMLOutput xmlOutput = XMLOutput.createXMLOutput(out, false);
|
||||
context.runScript(templateFile, xmlOutput);
|
||||
xmlOutput.flush();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
System.out.println("IGNORING: Failed to process file [" + outFile + "]. Closing streams and moving on. Exception: " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (out != null)
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.out.println("Failed to close outputstream for file [" + outFile + "], which is a bad thing!");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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();
|
||||
|
||||
Enumeration packages = packageManager.getPackageTypes();
|
||||
while (packages.hasMoreElements())
|
||||
{
|
||||
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)
|
||||
{
|
||||
pkgName = "(default package)";
|
||||
pkgDir = ".";
|
||||
rootRef = "./";
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Map info = new HashMap();
|
||||
info.put("allPackages", allPackages);
|
||||
info.put("allClasses", allClasses);
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@ -1,277 +0,0 @@
|
||||
package org.apache.maven.jxr;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.maven.jxr.ant.DirectoryScanner;
|
||||
import org.apache.maven.jxr.pacman.PackageManager;
|
||||
|
||||
/**
|
||||
* Main entry point into Maven used to kick off the XReference code building.
|
||||
*
|
||||
* @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class JXR
|
||||
{
|
||||
/** Log. */
|
||||
private static final Log log = LogFactory.getLog(JxrBean.class);
|
||||
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public final static String NOTICE =
|
||||
"This page was automatically generated by " +
|
||||
"<a href=\"http://maven.apache.org/\">Maven</a>";
|
||||
|
||||
/**
|
||||
* Path to all source.files
|
||||
*/
|
||||
private String source = "";
|
||||
|
||||
/**
|
||||
* Path to destination
|
||||
*/
|
||||
private String dest = "";
|
||||
|
||||
private String lang;
|
||||
private String inputEncoding;
|
||||
private String outputEncoding;
|
||||
|
||||
/**
|
||||
* Relative path to javadocs, suitable for hyperlinking
|
||||
*/
|
||||
private String javadocLinkDir;
|
||||
|
||||
/**
|
||||
* Handles taking .java files and changing them into html. "More than meets
|
||||
* the eye!" :)
|
||||
*/
|
||||
private CodeTransform transformer;
|
||||
|
||||
/**
|
||||
* The revision of the module currently being processed.
|
||||
*/
|
||||
private String revision;
|
||||
|
||||
/**
|
||||
* The constructor for the JXR class.
|
||||
*
|
||||
* @param packageManager The Package Manager for this project
|
||||
* @param revision The CVS revision of this file.
|
||||
* @param source The directory that files are being read from (src/java)
|
||||
* @param source
|
||||
* @param dest
|
||||
*/
|
||||
public JXR(PackageManager packageManager,
|
||||
String source,
|
||||
String dest,
|
||||
String lang,
|
||||
String inputEncoding,
|
||||
String outputEncoding,
|
||||
String javadocLinkDir,
|
||||
String revision)
|
||||
{
|
||||
this.transformer = new CodeTransform(packageManager);
|
||||
this.source = source;
|
||||
this.dest = dest;
|
||||
this.lang = lang;
|
||||
this.inputEncoding = inputEncoding;
|
||||
this.outputEncoding = outputEncoding;
|
||||
this.javadocLinkDir = javadocLinkDir;
|
||||
this.revision = revision;
|
||||
|
||||
this.process();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Now that we have instantiated everythign. Process this JXR task.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static boolean isJavaFile(String filename)
|
||||
{
|
||||
File file = new File(filename);
|
||||
return filename.endsWith(".java") && file.length() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static boolean isHtmlFile(String filename)
|
||||
{
|
||||
return filename.endsWith(".html");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 filename The name of the file to find
|
||||
* @return A String with the store destination.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @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);
|
||||
|
||||
transformer.transform(source, dest, lang, inputEncoding, outputEncoding, javadocLinkDir, this.revision);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <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>
|
||||
*
|
||||
*/
|
||||
private boolean updated(String file)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the source files
|
||||
*
|
||||
* @return The path to the source files
|
||||
*/
|
||||
public String getSource()
|
||||
{
|
||||
return this.source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the destination files
|
||||
*
|
||||
* @return The path to the destination files
|
||||
*/
|
||||
public String getDest()
|
||||
{
|
||||
return this.dest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,23 +17,13 @@ package org.apache.maven.jxr;
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import org.apache.maven.jxr.JXR;
|
||||
import org.apache.maven.jxr.DirectoryIndexer;
|
||||
import org.apache.maven.jxr.pacman.FileManager;
|
||||
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;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Creates an html-based, cross referenced version of Java source code
|
||||
@ -46,23 +36,31 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class JxrBean
|
||||
{
|
||||
/** Log. */
|
||||
private static final Log log = LogFactory.getLog(JxrBean.class);
|
||||
|
||||
/*
|
||||
* See the doc comments for the corresponding getter/setter methods
|
||||
*/
|
||||
private List sourceDirs;
|
||||
|
||||
private String destDir;
|
||||
private String lang;
|
||||
|
||||
private Locale locale;
|
||||
|
||||
private String inputEncoding;
|
||||
|
||||
private String outputEncoding;
|
||||
|
||||
private String javadocDir;
|
||||
|
||||
private String windowTitle;
|
||||
|
||||
private String docTitle;
|
||||
|
||||
private String bottom;
|
||||
|
||||
private String templateDir;
|
||||
|
||||
private final Log log = LogFactory.getLog( JxrBean.class );
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
@ -73,109 +71,50 @@ public class JxrBean
|
||||
|
||||
/**
|
||||
* Starts the cross-referencing and indexing.
|
||||
*
|
||||
* @throws IOException when any error occurs
|
||||
*/
|
||||
public void xref()
|
||||
throws Exception
|
||||
throws JxrException
|
||||
{
|
||||
// get a relative link to the javadocs
|
||||
String javadocLinkDir = null;
|
||||
if (javadocDir != null) {
|
||||
javadocLinkDir = getRelativeLink(destDir, javadocDir);
|
||||
}
|
||||
|
||||
// first collect package and class info
|
||||
PackageManager pkgmgr = new PackageManager();
|
||||
|
||||
FileManager.getInstance().setEncoding(inputEncoding);
|
||||
|
||||
// go through each source directory and xref the java files
|
||||
for (Iterator i = sourceDirs.iterator(); i.hasNext();)
|
||||
org.apache.maven.jxr.log.Log logger = new org.apache.maven.jxr.log.Log()
|
||||
{
|
||||
String path = (String) i.next();
|
||||
path = new File(path).getCanonicalPath();
|
||||
|
||||
pkgmgr.process(path);
|
||||
|
||||
new JXR(pkgmgr, path, destDir, lang, inputEncoding, outputEncoding, javadocLinkDir, "HEAD");
|
||||
}
|
||||
|
||||
// once we have all the source files xref'd, create the index pages
|
||||
DirectoryIndexer indexer = new DirectoryIndexer(pkgmgr, destDir);
|
||||
indexer.setOutputEncoding(outputEncoding);
|
||||
indexer.setTemplateDir(getTemplateDir());
|
||||
indexer.setWindowTitle(getWindowTitle());
|
||||
indexer.setDocTitle(getDocTitle());
|
||||
indexer.setBottom(getBottom());
|
||||
indexer.process();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a relative link from one directory to another.
|
||||
*
|
||||
* Example:
|
||||
* given /foo/bar/baz/oink
|
||||
* and /foo/bar/schmoo
|
||||
*
|
||||
* this method will return a string of "../../schmoo/"
|
||||
*
|
||||
* @param fromDir The directory from which the link is relative.
|
||||
* @param toDir The directory into which the link points.
|
||||
* @throws IOException
|
||||
* If a problem is encountered while navigating through the directories.
|
||||
* @return a string of format "../../schmoo/"
|
||||
*/
|
||||
private String getRelativeLink(String fromDir, String toDir)
|
||||
throws IOException
|
||||
{
|
||||
StringBuffer toLink = new StringBuffer(); // up from fromDir
|
||||
StringBuffer fromLink = new StringBuffer(); // down into toDir
|
||||
|
||||
// create a List of toDir's parent directories
|
||||
LinkedList parents = new LinkedList();
|
||||
File f = new File(toDir);
|
||||
f = f.getCanonicalFile();
|
||||
while (f != null)
|
||||
{
|
||||
parents.add(f);
|
||||
f = f.getParentFile();
|
||||
}
|
||||
|
||||
// walk up fromDir to find the common parent
|
||||
f = new File(fromDir);
|
||||
f = f.getCanonicalFile();
|
||||
f = f.getParentFile();
|
||||
boolean found = false;
|
||||
while (f != null && !found)
|
||||
{
|
||||
for (int i = 0; i < parents.size(); ++i)
|
||||
public void info( String message )
|
||||
{
|
||||
File parent = (File) parents.get(i);
|
||||
if (f.equals(parent))
|
||||
{
|
||||
// when we find the common parent, add the subdirectories
|
||||
// down to toDir itself
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
File p = (File) parents.get(j);
|
||||
toLink.insert(0, p.getName() + "/");
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
log.info( message );
|
||||
}
|
||||
f = f.getParentFile();
|
||||
fromLink.append("../");
|
||||
}
|
||||
|
||||
if (!found)
|
||||
public void debug( String message )
|
||||
{
|
||||
log.info( message );
|
||||
}
|
||||
|
||||
public void warn( String message )
|
||||
{
|
||||
log.info( message );
|
||||
}
|
||||
|
||||
public void error( String message )
|
||||
{
|
||||
log.info( message );
|
||||
}
|
||||
};
|
||||
|
||||
JXR jxr = new JXR();
|
||||
jxr.setDest( destDir );
|
||||
jxr.setLocale( locale );
|
||||
jxr.setInputEncoding( inputEncoding );
|
||||
jxr.setOutputEncoding( outputEncoding );
|
||||
jxr.setJavadocLinkDir( javadocDir );
|
||||
jxr.setRevision( "HEAD" );
|
||||
jxr.setLog( logger );
|
||||
|
||||
try
|
||||
{
|
||||
throw new FileNotFoundException(fromDir + " and " + toDir +
|
||||
" have no common parent.");
|
||||
jxr.xref( sourceDirs, getTemplateDir(), getWindowTitle(), getDocTitle(), getBottom() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new JxrException( "Error processing files", e );
|
||||
}
|
||||
|
||||
return fromLink.append(toLink.toString()).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,13 +122,13 @@ public class JxrBean
|
||||
*
|
||||
* @param sourceDir The source directory to be cross-referenced.
|
||||
*/
|
||||
public void setSourceDir(String sourceDir)
|
||||
public void setSourceDir( String sourceDir )
|
||||
{
|
||||
if (!sourceDirs.isEmpty())
|
||||
if ( !sourceDirs.isEmpty() )
|
||||
{
|
||||
sourceDirs.clear();
|
||||
}
|
||||
addSourceDir(sourceDir);
|
||||
addSourceDir( sourceDir );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,9 +136,9 @@ public class JxrBean
|
||||
*
|
||||
* @param sourceDir The source directory to be cross-referenced.
|
||||
*/
|
||||
public void addSourceDir(String sourceDir)
|
||||
public void addSourceDir( String sourceDir )
|
||||
{
|
||||
sourceDirs.add(sourceDir);
|
||||
sourceDirs.add( sourceDir );
|
||||
}
|
||||
|
||||
|
||||
@ -208,57 +147,41 @@ public class JxrBean
|
||||
*
|
||||
* @param destDir the destination directory for jxr output
|
||||
*/
|
||||
public void setDestDir(String destDir)
|
||||
public void setDestDir( String destDir )
|
||||
{
|
||||
this.destDir = destDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setDestDir(String)
|
||||
*
|
||||
* @see setDestDir(String)
|
||||
*/
|
||||
public String getDestDir()
|
||||
{
|
||||
return destDir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lang attribute of output files.
|
||||
*
|
||||
* @param lang lang attribute of output files.
|
||||
*/
|
||||
public void setLang(String lang)
|
||||
public Locale getLocale()
|
||||
{
|
||||
this.lang = lang;
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setLang(String)
|
||||
*
|
||||
* @see setLang(String)
|
||||
*/
|
||||
public String getLang()
|
||||
public void setLocale( Locale locale )
|
||||
{
|
||||
return lang;
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* InputEncoding is the encoding of source files.
|
||||
*
|
||||
* @param inputEncoding encoding of source files
|
||||
*/
|
||||
public void setInputEncoding(String inputEncoding)
|
||||
public void setInputEncoding( String inputEncoding )
|
||||
{
|
||||
this.inputEncoding = inputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setInputEncoding(String)
|
||||
*
|
||||
* @see setInputEncoding(String)
|
||||
*/
|
||||
public String getInputEncoding()
|
||||
{
|
||||
@ -271,15 +194,13 @@ public class JxrBean
|
||||
*
|
||||
* @param outputEncoding encoding of output files
|
||||
*/
|
||||
public void setOutputEncoding(String outputEncoding)
|
||||
public void setOutputEncoding( String outputEncoding )
|
||||
{
|
||||
this.outputEncoding = outputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setOutputEncoding(String)
|
||||
*
|
||||
* @see setOutputEncoding(String)
|
||||
*/
|
||||
public String getOutputEncoding()
|
||||
{
|
||||
@ -290,20 +211,18 @@ public class JxrBean
|
||||
/**
|
||||
* JavadocDir is used to cross-reference the source code with
|
||||
* the appropriate javadoc pages.
|
||||
*
|
||||
*
|
||||
* If <code>null</code>, no javadoc link will be added.
|
||||
*
|
||||
* @param javadocDir The root directory containing javadocs
|
||||
*/
|
||||
public void setJavadocDir(String javadocDir)
|
||||
public void setJavadocDir( String javadocDir )
|
||||
{
|
||||
this.javadocDir = javadocDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setJavadocDir(String)
|
||||
*
|
||||
* @see setJavadocDir(String)
|
||||
*/
|
||||
public String getJavadocDir()
|
||||
{
|
||||
@ -316,7 +235,7 @@ public class JxrBean
|
||||
* @param windowTitle used by DirectoryIndexer
|
||||
* @see DirectoryIndexer#setWindowTitle(String) setWindowTitle(String)
|
||||
*/
|
||||
public void setWindowTitle(String windowTitle)
|
||||
public void setWindowTitle( String windowTitle )
|
||||
{
|
||||
this.windowTitle = windowTitle;
|
||||
}
|
||||
@ -337,7 +256,7 @@ public class JxrBean
|
||||
* @param docTitle used by DirectoryIndexer
|
||||
* @see DirectoryIndexer#setDocTitle(String) setDocTitle(String)
|
||||
*/
|
||||
public void setDocTitle(String docTitle)
|
||||
public void setDocTitle( String docTitle )
|
||||
{
|
||||
this.docTitle = docTitle;
|
||||
}
|
||||
@ -358,7 +277,7 @@ public class JxrBean
|
||||
* @param bottom used by DirectoryIndexer
|
||||
* @see DirectoryIndexer#setBottom(String) setBottom(String)
|
||||
*/
|
||||
public void setBottom(String bottom)
|
||||
public void setBottom( String bottom )
|
||||
{
|
||||
this.bottom = bottom;
|
||||
}
|
||||
@ -378,15 +297,13 @@ public class JxrBean
|
||||
*
|
||||
* @param templateDir the template directory
|
||||
*/
|
||||
public void setTemplateDir(String templateDir)
|
||||
public void setTemplateDir( String templateDir )
|
||||
{
|
||||
this.templateDir = templateDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setTemplateDir(String)
|
||||
*
|
||||
* @see setTemplateDir(String) setTemplateDir(String)
|
||||
*/
|
||||
public String getTemplateDir()
|
||||
{
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
package org.apache.maven.jxr.ant;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Workaround to ignore package-info.java files.
|
||||
*
|
||||
* @author Carlos Sanchez
|
||||
*/
|
||||
public class DirectoryScanner extends org.apache.tools.ant.DirectoryScanner {
|
||||
|
||||
public void addDefaultExcludes() {
|
||||
super.addDefaultExcludes();
|
||||
int excludesLength = excludes == null ? 0 : excludes.length;
|
||||
String[] newExcludes;
|
||||
newExcludes = new String[excludesLength + 1];
|
||||
if (excludesLength > 0) {
|
||||
System.arraycopy(excludes, 0, newExcludes, 0, excludesLength);
|
||||
}
|
||||
newExcludes[excludesLength] = "**" + File.separatorChar
|
||||
+ "package-info.java";
|
||||
excludes = newExcludes;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* put your documentation comment here
|
||||
*
|
||||
* @author jvanzyl
|
||||
* @created February 23, 2002
|
||||
*/
|
||||
public abstract class BaseType
|
||||
{
|
||||
private String name = null;
|
||||
|
||||
|
||||
/**
|
||||
* Get the name for this type
|
||||
*
|
||||
* @return The name value
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the name for this type
|
||||
*
|
||||
* @param name The new name value
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/** Represents a Java class or interface */
|
||||
public class ClassType extends BaseType
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new ClassType
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public ClassType(String name)
|
||||
{
|
||||
this.setName(name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import 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();
|
||||
private String encoding = null;
|
||||
|
||||
/** 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.getEncoding());
|
||||
this.addFile(real);
|
||||
}
|
||||
|
||||
return real;
|
||||
}
|
||||
|
||||
/** Add a file to this filemanager. */
|
||||
public void addFile(JavaFile file)
|
||||
{
|
||||
this.files.put(file.getFilename(), file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encoding is the encoding of source files.
|
||||
*
|
||||
* @param encoding encoding of source files
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* see setEncoding(String)
|
||||
*
|
||||
* @see setEncoding(String)
|
||||
*/
|
||||
public String getEncoding()
|
||||
{
|
||||
return encoding;
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/** 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
|
||||
*
|
||||
* @param 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,104 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import 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$
|
||||
*/
|
||||
public abstract class JavaFile
|
||||
{
|
||||
|
||||
private Vector imports = new Vector();
|
||||
|
||||
private ClassType classType = null;
|
||||
private PackageType packageType = new PackageType();
|
||||
|
||||
private String filename = null;
|
||||
private String encoding = 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;
|
||||
}
|
||||
|
||||
|
||||
/** Gets the filename attribute of the JavaFile object */
|
||||
public String getFilename()
|
||||
{
|
||||
return this.filename;
|
||||
}
|
||||
|
||||
/** Sets the filename attribute of the JavaFile object */
|
||||
public void setFilename(String filename)
|
||||
{
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
|
||||
/** Gets the encoding attribute of the JavaFile object */
|
||||
public String getEncoding()
|
||||
{
|
||||
return this.encoding;
|
||||
}
|
||||
|
||||
/** Sets the encoding attribute of the JavaFile object */
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
}
|
||||
@ -1,161 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import 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$
|
||||
*/
|
||||
public class JavaFileImpl extends JavaFile
|
||||
{
|
||||
private Reader reader;
|
||||
|
||||
/**
|
||||
* Create a new JavaFileImpl that points to a given file...
|
||||
*
|
||||
* @param filename
|
||||
* @exception IOException
|
||||
*/
|
||||
public JavaFileImpl(String filename, String encoding)
|
||||
throws IOException
|
||||
{
|
||||
this.setFilename(filename);
|
||||
this.setEncoding(encoding);
|
||||
|
||||
//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 = null;
|
||||
try
|
||||
{
|
||||
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.sval.equals("enum"))
|
||||
{
|
||||
stok.nextToken();
|
||||
this.setClassType(new ClassType(stok.sval));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
stok = null;
|
||||
if (this.reader != null) {
|
||||
this.reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 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!");
|
||||
}
|
||||
|
||||
if (this.getEncoding() != null)
|
||||
{
|
||||
this.reader = new InputStreamReader(new FileInputStream(this.getFilename()), this.getEncoding());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.reader = new FileReader(this.getFilename());
|
||||
}
|
||||
|
||||
StreamTokenizer stok = new StreamTokenizer(reader);
|
||||
//int tok;
|
||||
|
||||
stok.commentChar('*');
|
||||
stok.wordChars('_', '_');
|
||||
|
||||
// set tokenizer to skip comments
|
||||
stok.slashStarComments(true);
|
||||
stok.slashSlashComments(true);
|
||||
|
||||
return stok;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,201 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.apache.maven.jxr.util.*;
|
||||
import org.apache.tools.ant.DirectoryScanner;
|
||||
|
||||
|
||||
/**
|
||||
* Given a list of directories, parse them out and store them as rendered
|
||||
* packages, classes, imports, etc.
|
||||
*/
|
||||
public class PackageManager
|
||||
{
|
||||
/** Log */
|
||||
private static final Log LOG = LogFactory.getLog(PackageManager.class);
|
||||
|
||||
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();
|
||||
|
||||
/**
|
||||
* 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 Enumeration getPackageTypes()
|
||||
{
|
||||
return packages.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse out all the directories on which this depends.
|
||||
*/
|
||||
private void parse(String directory)
|
||||
{
|
||||
// Go through each directory and get the java source
|
||||
// files for this dir.
|
||||
LOG.info("Scanning " + directory);
|
||||
DirectoryScanner directoryScanner = new DirectoryScanner();
|
||||
File baseDir = new File(directory);
|
||||
directoryScanner.setBasedir(baseDir);
|
||||
String[] includes = { "**/*.java" };
|
||||
directoryScanner.setIncludes(includes);
|
||||
directoryScanner.scan();
|
||||
String[] files = directoryScanner.getIncludedFiles();
|
||||
|
||||
for (int j = 0; j < files.length; ++j)
|
||||
{
|
||||
LOG.debug("parsing... " + files[j]);
|
||||
|
||||
//now parse out this file to get the packages/classname/etc
|
||||
try
|
||||
{
|
||||
String fileName = new File(baseDir,files[j]).getAbsolutePath();
|
||||
JavaFile jfi = FileManager.getInstance().getFile(fileName);
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*/
|
||||
public void process(String directory)
|
||||
{
|
||||
if (this.directories.get(directory) == null)
|
||||
{
|
||||
this.parse(directory);
|
||||
this.directories.put(directory, directory);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*/
|
||||
public void process(String[] directories)
|
||||
{
|
||||
|
||||
for (int i = 0; i < directories.length; ++i)
|
||||
{
|
||||
this.process(directories[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple logging facility
|
||||
*/
|
||||
public final static void log(String message)
|
||||
{
|
||||
System.out.println(" PackageManager -> " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the package information to STDOUT. FOR DEBUG ONLY
|
||||
*/
|
||||
public void dump()
|
||||
{
|
||||
|
||||
LOG.debug("Dumping out PackageManager structure");
|
||||
|
||||
Enumeration pts = this.getPackageTypes();
|
||||
|
||||
while (pts.hasMoreElements())
|
||||
{
|
||||
|
||||
//get the current package and print it.
|
||||
PackageType current = (PackageType)pts.nextElement();
|
||||
|
||||
LOG.debug(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.debug("\t" + currentClass.getName());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
package org.apache.maven.jxr.pacman;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/** Represents a Java package and its subclasses. */
|
||||
public class PackageType extends BaseType
|
||||
{
|
||||
|
||||
private Hashtable classes = new Hashtable();
|
||||
|
||||
/**
|
||||
* Create a Java package
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
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,220 +0,0 @@
|
||||
package org.apache.maven.jxr.util;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import 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
|
||||
{
|
||||
|
||||
/** Description of the Field */
|
||||
public final static char[] BREAKERS = {'(', ')', '[', ' ', '{', '}'};
|
||||
|
||||
/** Break the given line into multiple StringUtils */
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tokenize the given line but only return StringUtils 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)
|
||||
{
|
||||
|
||||
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,85 +0,0 @@
|
||||
package org.apache.maven.jxr.util;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Constructor for the StringEntry object
|
||||
*
|
||||
* @param value
|
||||
* @param index
|
||||
*/
|
||||
public StringEntry(String value,
|
||||
int index)
|
||||
{
|
||||
|
||||
this.value = value;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/** Gets the index attribute of the StringEntry object */
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
/** Description of the Method */
|
||||
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,43 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">
|
||||
|
||||
<x:doctype name="html" publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" systemId="DTD/xhtml1-transitional.dtd" />
|
||||
<html xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=${outputEncoding}" />
|
||||
<title>All Classes</title>
|
||||
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>All Classes</h3>
|
||||
|
||||
<ul>
|
||||
<j:forEach var="classInfo" items="${info.allClasses.values()}">
|
||||
<li>
|
||||
<a href="${classInfo.dir}/${classInfo.name}.html" target="classFrame">${classInfo.name}</a>
|
||||
</li>
|
||||
</j:forEach>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</j:jelly>
|
||||
@ -1,42 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml">
|
||||
<x:doctype name="html" publicId="-//W3C//DTD XHTML 1.0 Frameset//EN" systemId="DTD/xhtml1-frameset.dtd" />
|
||||
<html xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=${outputEncoding}" />
|
||||
<title>${windowTitle}</title>
|
||||
</head>
|
||||
<frameset cols="20%,80%">
|
||||
<frameset rows="30%,70%">
|
||||
<frame src="overview-frame.html" name="packageListFrame" />
|
||||
<frame src="allclasses-frame.html" name="packageFrame" />
|
||||
</frameset>
|
||||
<frame src="overview-summary.html" name="classFrame" />
|
||||
</frameset>
|
||||
<noframes>
|
||||
<h1>Frame Alert</h1>
|
||||
<p>
|
||||
You don't have frames. Go
|
||||
<a href="overview-summary.html">here</a>
|
||||
</p>
|
||||
</noframes>
|
||||
</html>
|
||||
</j:jelly>
|
||||
@ -1,47 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">
|
||||
|
||||
<x:doctype name="html" publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" systemId="DTD/xhtml1-transitional.dtd" />
|
||||
<html xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=${outputEncoding}" />
|
||||
<title>${windowTitle}</title>
|
||||
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>
|
||||
<a href="allclasses-frame.html" target="packageFrame">All Classes</a>
|
||||
</h3>
|
||||
|
||||
<h3>Packages</h3>
|
||||
|
||||
<ul>
|
||||
<j:forEach var="pkgInfo" items="${info.allPackages.values()}">
|
||||
<li>
|
||||
<a href="${pkgInfo.dir}/package-frame.html" target="packageFrame">${pkgInfo.name}</a>
|
||||
</li>
|
||||
</j:forEach>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</j:jelly>
|
||||
@ -1,95 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">
|
||||
|
||||
<x:parse var="doc">
|
||||
<overview>
|
||||
<navbar />
|
||||
<packages />
|
||||
<navbar />
|
||||
</overview>
|
||||
</x:parse>
|
||||
|
||||
<jsl:stylesheet select="$doc">
|
||||
<jsl:template match="overview">
|
||||
<x:doctype name="html" publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" systemId="DTD/xhtml1-transitional.dtd" />
|
||||
<html xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=${outputEncoding}" />
|
||||
<title>${windowTitle}</title>
|
||||
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<jsl:applyTemplates />
|
||||
<hr />
|
||||
${bottom}
|
||||
</body>
|
||||
</html>
|
||||
</jsl:template>
|
||||
|
||||
<jsl:template match="packages">
|
||||
|
||||
<h2>${docTitle}</h2>
|
||||
|
||||
<table class="summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Packages</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<j:forEach var="pkgInfo" items="${info.allPackages.values()}">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="${pkgInfo.dir}/package-summary.html">${pkgInfo.name}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</j:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</jsl:template>
|
||||
|
||||
<jsl:template match="navbar">
|
||||
<!-- ========== start of navbar ========== -->
|
||||
|
||||
<div class="overview">
|
||||
<ul>
|
||||
<li class="selected">Overview</li>
|
||||
<li>Package</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="framenoframe">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="index.html" target="_top">FRAMES</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="overview-summary.html" target="_top">NO FRAMES</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- =========== end of navbar =========== -->
|
||||
</jsl:template>
|
||||
</jsl:stylesheet>
|
||||
</j:jelly>
|
||||
@ -1,47 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">
|
||||
|
||||
<x:doctype name="html" publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" systemId="DTD/xhtml1-transitional.dtd" />
|
||||
<html xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=${outputEncoding}" />
|
||||
<title>${windowTitle} Package ${pkgInfo.name}</title>
|
||||
<link rel="stylesheet" type="text/css" href="${pkgInfo.rootRef}stylesheet.css" title="style" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>
|
||||
<a href="package-summary.html" target="classFrame">${pkgInfo.name}</a>
|
||||
</h3>
|
||||
|
||||
<h3>Classes</h3>
|
||||
|
||||
<ul>
|
||||
<j:forEach var="classInfo" items="${pkgInfo.classes.values()}">
|
||||
<li>
|
||||
<a href="${classInfo.name}.html" target="classFrame">${classInfo.name}</a>
|
||||
</li>
|
||||
</j:forEach>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</j:jelly>
|
||||
@ -1,100 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">
|
||||
|
||||
<x:parse var="doc">
|
||||
<package-summary>
|
||||
<navbar />
|
||||
<packages />
|
||||
<navbar />
|
||||
</package-summary>
|
||||
</x:parse>
|
||||
|
||||
<jsl:stylesheet select="$doc">
|
||||
<jsl:template match="package-summary">
|
||||
<x:doctype name="html" publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" systemId="DTD/xhtml1-transitional.dtd" />
|
||||
<html xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=${outputEncoding}" />
|
||||
<title>${windowTitle} Package ${name}</title>
|
||||
<link rel="stylesheet" type="text/css" href="${pkgInfo.rootRef}stylesheet.css" title="style" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<jsl:applyTemplates />
|
||||
|
||||
<hr />
|
||||
|
||||
${bottom}
|
||||
</body>
|
||||
</html>
|
||||
</jsl:template>
|
||||
|
||||
<jsl:template match="packages">
|
||||
<h2>Package ${pkgInfo.name}</h2>
|
||||
|
||||
<table class="summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Class Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<j:forEach var="classInfo" items="${pkgInfo.classes.values()}">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="${classInfo.name}.html" target="classFrame">${classInfo.name}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</j:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</jsl:template>
|
||||
|
||||
<jsl:template match="navbar">
|
||||
<!-- ========== start of navbar ========== -->
|
||||
|
||||
<div class="overview">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="${pkgInfo.rootRef}overview-summary.html">Overview</a>
|
||||
</li>
|
||||
<li class="selected">Package</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="framenoframe">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="${pkgInfo.rootRef}index.html" target="_top">FRAMES</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="package-summary.html" target="_top">NO FRAMES</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- =========== end of navbar =========== -->
|
||||
|
||||
</jsl:template>
|
||||
|
||||
</jsl:stylesheet>
|
||||
</j:jelly>
|
||||
@ -1,40 +0,0 @@
|
||||
package org.apache.maven.jxr;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.maven.jxr.pacman.PackageManager;
|
||||
|
||||
public class CodeTransformTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
private CodeTransform codeTransform;
|
||||
|
||||
private PackageManager packageManager;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
packageManager = new PackageManager();
|
||||
codeTransform = new CodeTransform( packageManager );
|
||||
}
|
||||
|
||||
public void testTransform()
|
||||
throws Exception
|
||||
{
|
||||
File sourceFile = new File( System.getProperty( "basedir" )
|
||||
+ "/src/test/org/apache/maven/jxr/CodeTransformTest.java" );
|
||||
assertTrue( sourceFile.exists() );
|
||||
codeTransform.transform( sourceFile.getAbsolutePath(), System.getProperty( "basedir" )
|
||||
+ "/target/CodeTransformTest.html", "en", "ISO-8859-1", "ISO-8859-1", "", "" );
|
||||
// sourceFile = new File("src/test/org/apache/maven/jxr/package-info.java");
|
||||
// assertTrue(sourceFile.exists());
|
||||
// codeTransform.transform(sourceFile.getAbsolutePath(),
|
||||
// "target/pakage-info.html", "en", "ISO-8859-1", "ISO-8859-1",
|
||||
// "", "");
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,7 +17,7 @@ public class JxrBeanTest
|
||||
jxrBean.setDestDir( System.getProperty( "basedir" ) + "/target" );
|
||||
jxrBean.setInputEncoding( "ISO-8859-1" );
|
||||
jxrBean.setOutputEncoding( "ISO-8859-1" );
|
||||
jxrBean.setTemplateDir( System.getProperty( "basedir" ) + "/src/plugin-resources/templates" );
|
||||
jxrBean.setTemplateDir( "templates" );
|
||||
jxrBean.setJavadocDir( "" );
|
||||
jxrBean.setWindowTitle( "title" );
|
||||
jxrBean.setDocTitle( "title" );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user