- * htmlFilter - * |__ - * multiLineCommentFilter -> uriFilter - * |___ - * inlineCommentFilter - * |___ - * stringFilter - * |___ - * keywordFilter - * |___ - * uriFilter - * |___ - * jxrFilter - * |___ - * importFilter - *- */ -public class CodeTransform implements Serializable -{ - - /** - * show line numbers - */ - public static final boolean LINE_NUMBERS = true; - - /** - * start comment delimeter - */ - public static final String COMMENT_START = ""; - - /** - * end comment delimeter - */ - public static final String COMMENT_END = ""; - - /** - * start javadoc comment delimeter - */ - public static final String JAVADOC_COMMENT_START = ""; - - /** - * end javadoc comment delimeter - */ - public static final String JAVADOC_COMMENT_END = ""; - - /** - * start String delimeter - */ - public static final String STRING_START = ""; - - /** - * end String delimeter - */ - public static final String STRING_END = ""; - - /** - * start reserved word delimeter - */ - public static final String RESERVED_WORD_START = ""; - - /** - * end reserved word delimeter - */ - public static final String RESERVED_WORD_END = ""; - - /** - * stylesheet file name - */ - public static final String STYLESHEET_FILENAME = "stylesheet.css"; - - /** - * Description of the Field - */ - public static final String[] VALID_URI_SCHEMES = {"http://", "mailto:"}; - - /** - * Specify the only characters that are allowed in a URI besides alpha and - * numeric characters. Refer RFC2396 - http://www.ietf.org/rfc/rfc2396.txt - */ - public static final char[] VALID_URI_CHARS = - { '?', '+', '%', '&', ':', '/', '.', '@', '_', ';', '=', '$', ',', '-', '!', '~', '*', '\'', '(', ')' }; - - /** - * HashTable containing java reserved words - */ - private Hashtable reservedWords = new Hashtable(); - - /** - * flag set to true when a multi line comment is started - */ - private boolean inMultiLineComment = false; - - /** - * flag set to true when a javadoc comment is started - */ - private boolean inJavadocComment = false; - - /** - * Set the filename that is currently being processed. - */ - private String currentFilename = null; - - /** - * The current CVS revision of the currently transformed documnt - */ - private String revision = null; - - /** - * The currently being transformed source file - */ - private String sourcefile = null; - - /** - * The currently being written destfile - */ - private String destfile = null; - - /** - * The virtual source directory that is being read from: src/java - */ - private String sourcedir = null; - - private String inputEncoding = null; - private String outputEncoding = null; - private String lang = null; - - /** - * Relative path to javadocs, suitable for hyperlinking - */ - private String javadocLinkDir; - - /** - * Package Manager for this project. - */ - private PackageManager packageManager; - - /** - * Constructor for the CodeTransform object - * @param packageManager PackageManager for this project - */ - public CodeTransform(PackageManager packageManager) - { - this.packageManager = packageManager; - loadHash(); - } - - /** - * Now different method of seeing if at end of input stream, closes inputs - * stream at end. - * @param line String - * @return filtered line of code - */ - public final String syntaxHighlight(String line) - { - return htmlFilter(line); - } - - /** - * Filter html tags into more benign text. - * @param line String - * @return html encoded line - */ - private final String htmlFilter(String line) - { - if (line == null || line.equals("")) - { - return ""; - } - line = replace(line, "&", "&"); - line = replace(line, "<", "<"); - line = replace(line, "\\\\", "//"); - line = replace(line, "\\\"", "\\""); - line = replace(line, "'\"'", "'"'"); - return multiLineCommentFilter(line); - } - - /** - * Filter out multiLine comments. State is kept with a private boolean variable. - * @param line String - * @return String - */ - private final String multiLineCommentFilter(String line) - { - if (line == null || line.equals("")) - { - return ""; - } - StringBuffer buf = new StringBuffer(); - int index; - - //First, check for the end of a java comment. - if (inJavadocComment && (index = line.indexOf("*/")) > -1 && !isInsideString(line, index)) - { - inJavadocComment = false; - buf.append(JAVADOC_COMMENT_START); - buf.append(line.substring(0, index)); - buf.append("*/").append(JAVADOC_COMMENT_END); - if (line.length() > index + 2) - { - buf.append(inlineCommentFilter(line.substring(index + 2))); - } - - return uriFilter(buf.toString()); - } - - //Second, check for the end of a multi-line comment. - if (inMultiLineComment && (index = line.indexOf("*/")) > -1 && !isInsideString(line, index)) - { - inMultiLineComment = false; - buf.append(COMMENT_START); - buf.append(line.substring(0, index)); - buf.append("*/").append(COMMENT_END); - if (line.length() > index + 2) - { - buf.append(inlineCommentFilter(line.substring(index + 2))); - } - return uriFilter(buf.toString()); - } - - //If there was no end detected and we're currently in a multi-line - //comment, we don't want to do anymore work, so return line. - else if (inMultiLineComment) - { - - StringBuffer buffer = new StringBuffer(line); - buffer.insert(0, COMMENT_START); - buffer.append(COMMENT_END); - return uriFilter(buffer.toString()); - } - else if (inJavadocComment) - { - - StringBuffer buffer = new StringBuffer(line); - buffer.insert(0, JAVADOC_COMMENT_START); - buffer.append(JAVADOC_COMMENT_END); - return uriFilter(buffer.toString()); - } - - //We're not currently in a Javadoc comment, so check to see if the start - //of a multi-line Javadoc comment is in this line. - else if ((index = line.indexOf("/**")) > -1 && !isInsideString(line, index)) - { - inJavadocComment = true; - //Return result of other filters + everything after the start - //of the multiline comment. We need to pass the through the - //to the multiLineComment filter again in case the comment ends - //on the same line. - buf.append(inlineCommentFilter(line.substring(0, index))); - buf.append(JAVADOC_COMMENT_START).append("/**"); - buf.append(multiLineCommentFilter(line.substring(index + 2))); - buf.append(JAVADOC_COMMENT_END); - return uriFilter(buf.toString()); - } - - //We're not currently in a comment, so check to see if the start - //of a multi-line comment is in this line. - else if ((index = line.indexOf("/*")) > -1 && !isInsideString(line, index)) - { - inMultiLineComment = true; - //Return result of other filters + everything after the start - //of the multiline comment. We need to pass the through the - //to the multiLineComment filter again in case the comment ends - //on the same line. - buf.append(inlineCommentFilter(line.substring(0, index))); - buf.append(COMMENT_START).append("/*"); - buf.append(multiLineCommentFilter(line.substring(index + 2))); - buf.append(COMMENT_END); - return uriFilter(buf.toString()); - } - - //Otherwise, no useful multi-line comment information was found so - //pass the line down to the next filter for processesing. - else - { - return inlineCommentFilter(line); - } - } - - /** - * Filter inline comments from a line and formats them properly. One problem - * we'll have to solve here: comments contained in a string should be - * ignored... this is also true of the multiline comments. So, we could - * either ignore the problem, or implement a function called something like - * isInsideString(line, index) where index points to some point in the line - * that we need to check... started doing this function below. - * @param line String - * @return String - */ - private final String inlineCommentFilter(String line) - { - if (line == null || line.equals("")) - { - return ""; - } - StringBuffer buf = new StringBuffer(); - int index; - if ((index = line.indexOf("//")) > -1 && !isInsideString(line, index)) - { - buf.append(stringFilter(line.substring(0, index))); - buf.append(COMMENT_START); - buf.append(line.substring(index)); - buf.append(COMMENT_END); - } - else - { - buf.append(stringFilter(line)); - } - return buf.toString(); - } - - /** - * Filters strings from a line of text and formats them properly. - * @param line String - * @return String - */ - private final String stringFilter(String line) - { - - if (line == null || line.equals("")) - { - return ""; - } - StringBuffer buf = new StringBuffer(); - if (line.indexOf("\"") <= -1) - { - return keywordFilter(line); - } - int start = 0; - int startStringIndex = -1; - int endStringIndex = -1; - int tempIndex; - //Keep moving through String characters until we want to stop... - while ((tempIndex = line.indexOf("\"")) > -1) - { - //We found the beginning of a string - if (startStringIndex == -1) - { - startStringIndex = 0; - buf.append(stringFilter(line.substring(start, tempIndex))); - buf.append(STRING_START).append("\""); - line = line.substring(tempIndex + 1); - } - //Must be at the end - else - { - startStringIndex = -1; - endStringIndex = tempIndex; - buf.append(line.substring(0, endStringIndex + 1)); - buf.append(STRING_END); - line = line.substring(endStringIndex + 1); - } - } - - buf.append(keywordFilter(line)); - - return buf.toString(); - } - - /** - * Filters keywords from a line of text and formats them properly. - * @param line String - * @return String - */ - private final String keywordFilter(String line) - { - if (line == null || line.equals("")) - { - return ""; - } - StringBuffer buf = new StringBuffer(); - Hashtable usedReservedWords = new Hashtable(); - int i = 0; - char ch; - StringBuffer temp = new StringBuffer(); - while (i < line.length()) - { - temp.setLength(0); - ch = line.charAt(i); - while (i < line.length() && ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122))) - { - temp.append(ch); - i++; - if (i < line.length()) - { - ch = line.charAt(i); - } - } - String tempString = temp.toString(); - if (reservedWords.containsKey(tempString) && !usedReservedWords.containsKey(tempString)) - { - usedReservedWords.put(tempString, tempString); - line = replace(line, tempString, (RESERVED_WORD_START + tempString + RESERVED_WORD_END)); - i += (RESERVED_WORD_START.length() + RESERVED_WORD_END.length()); - } - else - { - i++; - } - } - buf.append(line); - return uriFilter(buf.toString()); - } - - /** - * Replace... I made it use a stringBuffer... hope it still works :) - * @param line String - * @param oldString String - * @param newString String - * @return String - */ - private final String replace(String line, String oldString, String newString) - { - int i = 0; - while ((i = line.indexOf(oldString, i)) >= 0) - { - line = - (new StringBuffer() - .append(line.substring(0, i)) - .append(newString) - .append(line.substring(i + oldString.length()))) - .toString(); - i += newString.length(); - } - return line; - } - - /** - * Checks to see if some position in a line is between String start and - * ending characters. Not yet used in code or fully working :) - * @param line String - * @param position int - * @return boolean - */ - private final boolean isInsideString(String line, int position) - { - if (line.indexOf("\"") < 0) - { - return false; - } - int index; - String left = line.substring(0, position); - String right = line.substring(position); - int leftCount = 0; - int rightCount = 0; - while ((index = left.indexOf("\"")) > -1) - { - leftCount++; - left = left.substring(index + 1); - } - while ((index = right.indexOf("\"")) > -1) - { - rightCount++; - right = right.substring(index + 1); - } - return (rightCount % 2 != 0 && leftCount % 2 != 0); - } - - /** - * Description of the Method - */ - private final void loadHash() - { - reservedWords.put("abstract", "abstract"); - reservedWords.put("do", "do"); - reservedWords.put("inner", "inner"); - reservedWords.put("public", "public"); - reservedWords.put("var", "var"); - reservedWords.put("boolean", "boolean"); - reservedWords.put("continue", "continue"); - reservedWords.put("int", "int"); - reservedWords.put("return", "return"); - reservedWords.put("void", "void"); - reservedWords.put("break", "break"); - reservedWords.put("else", "else"); - reservedWords.put("interface", "interface"); - reservedWords.put("short", "short"); - reservedWords.put("volatile", "volatile"); - reservedWords.put("byvalue", "byvalue"); - reservedWords.put("extends", "extends"); - reservedWords.put("long", "long"); - reservedWords.put("static", "static"); - reservedWords.put("while", "while"); - reservedWords.put("case", "case"); - reservedWords.put("final", "final"); - reservedWords.put("native", "native"); - reservedWords.put("super", "super"); - reservedWords.put("transient", "transient"); - reservedWords.put("cast", "cast"); - reservedWords.put("float", "float"); - reservedWords.put("new", "new"); - reservedWords.put("rest", "rest"); - reservedWords.put("catch", "catch"); - reservedWords.put("for", "for"); - reservedWords.put("null", "null"); - reservedWords.put("synchronized", "synchronized"); - reservedWords.put("char", "char"); - reservedWords.put("finally", "finally"); - reservedWords.put("operator", "operator"); - reservedWords.put("this", "this"); - reservedWords.put("class", "class"); - reservedWords.put("generic", "generic"); - reservedWords.put("outer", "outer"); - reservedWords.put("switch", "switch"); - reservedWords.put("const", "const"); - reservedWords.put("goto", "goto"); - reservedWords.put("package", "package"); - reservedWords.put("throw", "throw"); - reservedWords.put("double", "double"); - reservedWords.put("if", "if"); - reservedWords.put("private", "private"); - reservedWords.put("true", "true"); - reservedWords.put("default", "default"); - reservedWords.put("import", "import"); - reservedWords.put("protected", "protected"); - reservedWords.put("try", "try"); - } - - /** - * Description of the Method - * @param oos ObjectOutputStream - * @throws IOException - */ - final void writeObject(ObjectOutputStream oos) throws IOException - { - oos.defaultWriteObject(); - } - - /** - * Description of the Method - * @param ois ObjectInputStream - * @throws ClassNotFoundException - * @throws IOException - */ - final void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException - { - ois.defaultReadObject(); - } - - /** - * Gets the header attribute of the CodeTransform object - * @return String - */ - public String getHeader() - { - StringBuffer buffer = new StringBuffer(); - - String lang = this.lang; - if (lang == null) { - lang = "en"; - } - String outputEncoding = this.outputEncoding; - if (outputEncoding == null) { - outputEncoding = "ISO-8859-1"; - } - - // header - buffer - .append("\n") - .append("\n") - .append("\n") - .append(""); - - // title ("classname xref") - try - { - buffer - .append("
\n");
-
- return buffer.toString();
- }
-
- /**
- * Gets the footer attribute of the CodeTransform object
- * @return String
- */
- public final String getFooter()
- {
- return "\n" + "Given the name of a package... get the number of - * subdirectories/subpackages there would be.
- *EX: org.apache.maven == 3
- * @param packageName String - * @return int - */ - private final int getPackageCount(String packageName) - { - - if (packageName == null) - { - return 0; - } - - int count = 0; - - int index = 0; - - while (true) - { - - index = packageName.indexOf(".", index); - - if (index == -1) - { - break; - } - ++index; - ++count; - } - - //need to increment this by one - count = ++count; - - return count; - } - - /** - * Parse out the current link and look for package/import statements and - * then create HREFs for them - * @param line String - * @return String - */ - private final String importFilter(String line) - { - - int start = -1; - - /* - Used for determining if this is a package declaration. If it is - then we can make some additional assumptions: - - that this isn't a Class import so the full String is valid - - that it WILL be on the disk since this is based on the current - - file. - */ - boolean isPackage = line.trim().startsWith("package "); - boolean isImport = line.trim().startsWith("import "); - - if (isImport || isPackage) - { - - start = line.trim().indexOf(" "); - } - - if (start != -1) - { - - //filter out this packagename... - - String pkg = line.substring(start, line.length()).trim(); - - //specify the classname of this import if any. - String classname = null; - - if (pkg.indexOf(".*") != -1) - { - - pkg = StringUtils.replace(pkg, ".*", ""); - - } - else if (!isPackage) - { - - //this is an explicit Class import - - String packageLine = pkg.toString(); - - // This catches a boundary problem where you have something like: - // - // Foo foo = FooMaster.getFooInstance(). - // danceLittleFoo(); - // - // This breaks Jxr and won't be a problem when we hook - // in the real parser. - - int a = packageLine.lastIndexOf(".") + 1; - int b = packageLine.length() - 1; - - if (a > b + 1) - { - classname = packageLine.substring(packageLine.lastIndexOf(".") + 1, packageLine.length() - 1); - - int end = pkg.lastIndexOf("."); - - if (end == -1) - { - end = pkg.length() - 1; - } - - pkg = pkg.substring(0, end); - } - - } - - pkg = StringUtils.replace(pkg, ";", ""); - String pkgHREF = getHREF(pkg); - //if this package is within the PackageManager then you can create an HREF for it. - - if (packageManager.getPackageType(pkg) != null || isPackage) - { - - //Create an HREF for explicit classname imports - if (classname != null) - { - - line = - StringUtils.replace( - line, - classname, - "" + classname + ""); - - } - - //now replace the given package with a href - line = - StringUtils.replace( - line, - pkg, - "" + pkg + ""); - } - - } - - return line; - } - - /** - * From the current file, determine the package root based on the current - * path. - * @return String - */ - public final String getPackageRoot() - { - - StringBuffer buff = new StringBuffer(); - - JavaFile jf = null; - - try - { - jf = FileManager.getInstance().getFile(this.getCurrentFilename()); - } - catch (IOException e) - { - e.printStackTrace(); - return null; - } - - String current = jf.getPackageType().getName(); - - int count = this.getPackageCount(current); - - for (int i = 0; i < count; ++i) - { - buff.append("../"); - } - - return buff.toString(); - } - - /** - * Given a line of text, search for URIs and make href's out of them - * @param line String - * @return String - */ - public final String uriFilter(String line) - { - - for (int i = 0; i < VALID_URI_SCHEMES.length; ++i) - { - - String scheme = VALID_URI_SCHEMES[i]; - - int index = line.indexOf(scheme); - - if (index != -1) - { - - int start = index; - - int end = -1; - - for (int j = start; j < line.length(); ++j) - { - - char current = line.charAt(j); - - if (!Character.isLetterOrDigit(current) && isInvalidURICharacter(current)) - { - end = j; - break; - } - - end = j; - - } - - //now you should have the full URI so you can replace this - //in the current buffer - - if (end != -1) - { - - String uri = line.substring(start, end); - - line = - StringUtils.replace( - line, - uri, - "" + uri + ""); - } - } - } - - //if we are in a multiline comment we should not call JXR here. - if (!inMultiLineComment && !inJavadocComment) - { - return jxrFilter(line); - } - else - { - return line; - } - - } - - /** - * if the given char is not one of the following in VALID_URI_CHARS then - * return true - * @param c char to check against VALID_URI_CHARS list - * @returntrue if c is a valid URI char
- */
- private final boolean isInvalidURICharacter(char c)
- {
-
- for (int i = 0; i < VALID_URI_CHARS.length; ++i)
- {
- if (VALID_URI_CHARS[i] == c)
- {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * The current revision of the CVS module
- * @return String
- */
- public final String getRevision()
- {
- return this.revision;
- }
-
- /**
- * The current source file being read
- * @return source file name
- */
- public final String getSourcefile()
- {
- return this.sourcefile;
- }
-
- /**
- * The current dest file being written
- * @return destination file name
- */
- public final String getDestfile()
- {
- return this.destfile;
- }
-
- /**
- * The current source directory being read from.
- * @return source directory
- */
- public final String getSourceDirectory()
- {
- return this.sourcedir;
- }
-
- /**
- * Cross Reference the given line with JXR returning the new content.
- * @param line String
- * @param packageName String
- * @param classType ClassType
- * @return String
- */
- public final String xrLine(String line, String packageName, ClassType classType)
- {
-
- StringBuffer buff = new StringBuffer(line);
-
- String link = null;
- String find = null;
- String href = null;
-
- if (classType != null)
- {
- href = this.getHREF(packageName, classType);
- find = classType.getName();
- }
- else
- {
- href = this.getHREF(packageName);
- find = packageName;
- }
-
- //build out what the link would be.
- link = "" + find + "";
-
- //use the SimpleWordTokenizer to find all entries
- //that match word. Then replace these with the link
-
- //now replace the word in the buffer with the link
-
- String replace = link;
- StringEntry[] tokens = SimpleWordTokenizer.tokenize(buff.toString(), find);
-
- for (int l = 0; l < tokens.length; ++l)
- {
-
- int start = tokens[l].getIndex();
- int end = tokens[l].getIndex() + find.length();
-
- buff.replace(start, end, replace);
-
- }
-
- return buff.toString();
- }
-
- /**
- * Highlight the package in this line.
- * @param line input line
- * @param packageName package name
- * @return input line with linked package
- */
- public final String xrLine(String line, String packageName)
- {
-
- String href = this.getHREF(packageName);
-
- String find = packageName;
-
- //build out what the link would be.
- String link = "" + find + "";
-
- return StringUtils.replace(line, find, link);
- }
-
-}
diff --git a/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java b/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java
deleted file mode 100644
index 95102d6a..00000000
--- a/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java
+++ /dev/null
@@ -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:
- * 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 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);
-
- }
-
- /**
- *
- *
- * Given a java source file determine if this needs updating. This is
- * determined by:
- *
- * - The class doesn't exist in the destination directory
- * - The file does exist in the destination directory but is older
- *
- *
- *
- */
- 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;
- }
-
-}
-
diff --git a/jxr/src/main/org/apache/maven/jxr/JxrBean.java b/jxr/src/main/org/apache/maven/jxr/JxrBean.java
index e3df87f8..259ef469 100644
--- a/jxr/src/main/org/apache/maven/jxr/JxrBean.java
+++ b/jxr/src/main/org/apache/maven/jxr/JxrBean.java
@@ -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 null, 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()
{
diff --git a/jxr/src/main/org/apache/maven/jxr/ant/DirectoryScanner.java b/jxr/src/main/org/apache/maven/jxr/ant/DirectoryScanner.java
deleted file mode 100644
index 08e371a6..00000000
--- a/jxr/src/main/org/apache/maven/jxr/ant/DirectoryScanner.java
+++ /dev/null
@@ -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;
- }
-
-}
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/BaseType.java b/jxr/src/main/org/apache/maven/jxr/pacman/BaseType.java
deleted file mode 100644
index 03a503dd..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/BaseType.java
+++ /dev/null
@@ -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;
- }
-}
-
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/ClassType.java b/jxr/src/main/org/apache/maven/jxr/pacman/ClassType.java
deleted file mode 100644
index 3868f24b..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/ClassType.java
+++ /dev/null
@@ -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);
- }
-
-}
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/FileManager.java b/jxr/src/main/org/apache/maven/jxr/pacman/FileManager.java
deleted file mode 100644
index fbaa6450..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/FileManager.java
+++ /dev/null
@@ -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;
-
-/**
- *
- *
- * 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.
- *
- *
- * Note. This assumes that the file will not be modified on disk while
- * Alexandria is running.
- */
-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;
- }
-}
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/ImportType.java b/jxr/src/main/org/apache/maven/jxr/pacman/ImportType.java
deleted file mode 100644
index daf94f3a..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/ImportType.java
+++ /dev/null
@@ -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;
- }
-
-}
-
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/JavaFile.java b/jxr/src/main/org/apache/maven/jxr/pacman/JavaFile.java
deleted file mode 100644
index 8e8c6335..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/JavaFile.java
+++ /dev/null
@@ -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 Kevin A. Burton
- * @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;
- }
-}
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/JavaFileImpl.java b/jxr/src/main/org/apache/maven/jxr/pacman/JavaFileImpl.java
deleted file mode 100644
index 09d9b036..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/JavaFileImpl.java
+++ /dev/null
@@ -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 Kevin A. Burton
- * @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;
- }
-
-}
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/PackageManager.java b/jxr/src/main/org/apache/maven/jxr/pacman/PackageManager.java
deleted file mode 100644
index d64d0b6c..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/PackageManager.java
+++ /dev/null
@@ -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());
-
- }
- }
- }
-}
-
diff --git a/jxr/src/main/org/apache/maven/jxr/pacman/PackageType.java b/jxr/src/main/org/apache/maven/jxr/pacman/PackageType.java
deleted file mode 100644
index 6c01994b..00000000
--- a/jxr/src/main/org/apache/maven/jxr/pacman/PackageType.java
+++ /dev/null
@@ -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);
- }
-
-}
diff --git a/jxr/src/main/org/apache/maven/jxr/util/SimpleWordTokenizer.java b/jxr/src/main/org/apache/maven/jxr/util/SimpleWordTokenizer.java
deleted file mode 100644
index 6ada6b5a..00000000
--- a/jxr/src/main/org/apache/maven/jxr/util/SimpleWordTokenizer.java
+++ /dev/null
@@ -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;
- }
-
-}
-
diff --git a/jxr/src/main/org/apache/maven/jxr/util/StringEntry.java b/jxr/src/main/org/apache/maven/jxr/util/StringEntry.java
deleted file mode 100644
index eaeb30db..00000000
--- a/jxr/src/main/org/apache/maven/jxr/util/StringEntry.java
+++ /dev/null
@@ -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;
- }
-
- }
-
-}
-
diff --git a/jxr/src/plugin-resources/templates/allclasses-frame.jelly b/jxr/src/plugin-resources/templates/allclasses-frame.jelly
deleted file mode 100644
index 4c5c03ae..00000000
--- a/jxr/src/plugin-resources/templates/allclasses-frame.jelly
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
- All Classes
-
-
-
-
- All Classes
-
-
-
- -
- ${classInfo.name}
-
-
-
-
-
-
-
diff --git a/jxr/src/plugin-resources/templates/index.jelly b/jxr/src/plugin-resources/templates/index.jelly
deleted file mode 100644
index 23ae56fc..00000000
--- a/jxr/src/plugin-resources/templates/index.jelly
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
- ${windowTitle}
-
-
-
- Frame Alert
-
- You don't have frames. Go
- here
-
-
-
-
diff --git a/jxr/src/plugin-resources/templates/overview-frame.jelly b/jxr/src/plugin-resources/templates/overview-frame.jelly
deleted file mode 100644
index 7e2d11c2..00000000
--- a/jxr/src/plugin-resources/templates/overview-frame.jelly
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
- ${windowTitle}
-
-
-
-
-
- All Classes
-
-
- Packages
-
-
-
- -
- ${pkgInfo.name}
-
-
-
-
-
-
-
diff --git a/jxr/src/plugin-resources/templates/overview-summary.jelly b/jxr/src/plugin-resources/templates/overview-summary.jelly
deleted file mode 100644
index 0d4b0fc7..00000000
--- a/jxr/src/plugin-resources/templates/overview-summary.jelly
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${windowTitle}
-
-
-
-
-
-
- ${bottom}
-
-
-
-
-
-
- ${docTitle}
-
-
-
-
- Packages
-
-
-
-
-
-
-
- ${pkgInfo.name}
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Overview
- - Package
-
-
-
-
-
-
-
-
diff --git a/jxr/src/plugin-resources/templates/package-frame.jelly b/jxr/src/plugin-resources/templates/package-frame.jelly
deleted file mode 100644
index d2b9d2e5..00000000
--- a/jxr/src/plugin-resources/templates/package-frame.jelly
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
- ${windowTitle} Package ${pkgInfo.name}
-
-
-
-
-
- ${pkgInfo.name}
-
-
- Classes
-
-
-
- -
- ${classInfo.name}
-
-
-
-
-
-
-
diff --git a/jxr/src/plugin-resources/templates/package-summary.jelly b/jxr/src/plugin-resources/templates/package-summary.jelly
deleted file mode 100644
index d20f867f..00000000
--- a/jxr/src/plugin-resources/templates/package-summary.jelly
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${windowTitle} Package ${name}
-
-
-
-
-
-
-
-
- ${bottom}
-
-
-
-
-
- Package ${pkgInfo.name}
-
-
-
-
- Class Summary
-
-
-
-
-
-
-
- ${classInfo.name}
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- Overview
-
- - Package
-
-
-
-
-
-
-
-
-
-
diff --git a/jxr/src/test/org/apache/maven/jxr/CodeTransformTest.java b/jxr/src/test/org/apache/maven/jxr/CodeTransformTest.java
deleted file mode 100644
index 197cf3e5..00000000
--- a/jxr/src/test/org/apache/maven/jxr/CodeTransformTest.java
+++ /dev/null
@@ -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",
- // "", "");
- }
-
-}
diff --git a/jxr/src/test/org/apache/maven/jxr/JxrBeanTest.java b/jxr/src/test/org/apache/maven/jxr/JxrBeanTest.java
index 4ff6db28..06e8eb3c 100644
--- a/jxr/src/test/org/apache/maven/jxr/JxrBeanTest.java
+++ b/jxr/src/test/org/apache/maven/jxr/JxrBeanTest.java
@@ -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" );