diff --git a/jxr/src/main/org/apache/maven/jxr/CodeTransform.java b/jxr/src/main/org/apache/maven/jxr/CodeTransform.java index cd871993..1923d6c8 100644 --- a/jxr/src/main/org/apache/maven/jxr/CodeTransform.java +++ b/jxr/src/main/org/apache/maven/jxr/CodeTransform.java @@ -30,19 +30,25 @@ package org.apache.maven.jxr; * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.PrintWriter; +import java.io.Serializable; import java.util.Hashtable; import java.util.Vector; import org.apache.commons.lang.StringUtils; - import org.apache.maven.jxr.pacman.ClassType; -import org.apache.maven.jxr.pacman.PackageManager; -import org.apache.maven.jxr.pacman.JavaFile; -import org.apache.maven.jxr.pacman.ImportType; import org.apache.maven.jxr.pacman.FileManager; +import org.apache.maven.jxr.pacman.ImportType; +import org.apache.maven.jxr.pacman.JavaFile; +import org.apache.maven.jxr.pacman.PackageManager; import org.apache.maven.jxr.pacman.PackageType; - import org.apache.maven.jxr.util.SimpleWordTokenizer; import org.apache.maven.jxr.util.StringEntry; @@ -59,84 +65,97 @@ import org.apache.maven.jxr.util.StringEntry; * |__ * multiLineCommentFilter -> uriFilter * |___ - * inlineCommentFilter - * |___ - * stringFilter - * |__ - * keywordFilter - * |__ - * uriFilter - * |__ - * jxrFilter - * |__ - * importFilter + * inlineCommentFilter + * |___ + * stringFilter + * |___ + * keywordFilter + * |___ + * uriFilter + * |___ + * jxrFilter + * |___ + * importFilter * */ public class CodeTransform implements Serializable { + /** - * Description of the Field + * show line numbers */ - public final static boolean LINE_NUMBERS = true; + 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 final static String BACKGROUND_COLOR = "#ffffff"; - - /** - * Description of the Field - */ - public final static String COMMENT_START = ""; - - /** - * Description of the Field - */ - public final static String COMMENT_END = ""; - - /** - * Description of the Field - */ - public final static String JAVADOC_COMMENT_START = ""; - - /** - * Description of the Field - */ - public final static String JAVADOC_COMMENT_END = ""; - - /** - * Description of the Field - */ - public final static String STRING_START = ""; - - /** - * Description of the Field - */ - public final static String STRING_END = ""; - - /** - * Description of the Field - */ - public final static String RESERVED_WORD_START = ""; - - /** - * Description of the Field - */ - public final static String RESERVED_WORD_END = ""; - - /** - * Description of the Field - */ - public final static String[] VALID_URI_SCHEMES = {"http://", "mailto:"}; + 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 final static char[] VALID_URI_CHARS = {'?', '+', '%', '&', ':', '/', '.', '@', '_', ';', '=', '$', ',', '-', '!', '~', '*', '\'', '(', ')'}; - + 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; /** @@ -168,16 +187,14 @@ public class CodeTransform implements Serializable * 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) @@ -186,10 +203,11 @@ public class CodeTransform implements Serializable 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) { @@ -198,6 +216,8 @@ public class CodeTransform implements Serializable /** * Filter html tags into more benign text. + * @param line String + * @return html encoded line */ private final String htmlFilter(String line) { @@ -205,18 +225,18 @@ public class CodeTransform implements Serializable { return ""; } + line = replace(line, "&", "&"); 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. + * Filter out multiLine comments. State is kept with a private boolean variable. + * @param line String + * @return String */ private final String multiLineCommentFilter(String line) { @@ -228,8 +248,7 @@ public class CodeTransform implements Serializable int index; //First, check for the end of a java comment. - if (inJavadocComment && - (index = line.indexOf("*/")) > -1 && !isInsideString(line, index)) + if (inJavadocComment && (index = line.indexOf("*/")) > -1 && !isInsideString(line, index)) { inJavadocComment = false; buf.append(JAVADOC_COMMENT_START); @@ -323,6 +342,8 @@ public class CodeTransform implements Serializable * 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) { @@ -348,6 +369,8 @@ public class CodeTransform implements Serializable /** * Filters strings from a line of text and formats them properly. + * @param line String + * @return String */ private final String stringFilter(String line) { @@ -394,6 +417,8 @@ public class CodeTransform implements Serializable /** * Filters keywords from a line of text and formats them properly. + * @param line String + * @return String */ private final String keywordFilter(String line) { @@ -402,19 +427,15 @@ public class CodeTransform implements Serializable return ""; } StringBuffer buf = new StringBuffer(); - //HashMap usedReservedWords = new HashMap(); Hashtable usedReservedWords = new Hashtable(); int i = 0; - int startAt = 0; char ch; StringBuffer temp = new StringBuffer(); while (i < line.length()) { temp.setLength(0); ch = line.charAt(i); - startAt = i; - while (i < line.length() && ((ch >= 65 && ch <= 90) - || (ch >= 97 && ch <= 122))) + while (i < line.length() && ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122))) { temp.append(ch); i++; @@ -441,13 +462,22 @@ public class CodeTransform implements Serializable /** * 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(); + line = + (new StringBuffer() + .append(line.substring(0, i)) + .append(newString) + .append(line.substring(i + oldString.length()))) + .toString(); i += newString.length(); } return line; @@ -456,6 +486,9 @@ public class CodeTransform implements Serializable /** * 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) { @@ -478,14 +511,7 @@ public class CodeTransform implements Serializable rightCount++; right = right.substring(index + 1); } - if (rightCount % 2 != 0 && leftCount % 2 != 0) - { - return true; - } - else - { - return false; - } + return (rightCount % 2 != 0 && leftCount % 2 != 0); } /** @@ -550,52 +576,89 @@ public class CodeTransform implements Serializable /** * Description of the Method + * @param oos ObjectOutputStream + * @throws IOException */ - final void writeObject(ObjectOutputStream oos) - 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 + final void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); } /** * Gets the header attribute of the CodeTransform object + * @todo make language and encoding headers customizable + * @return String */ public String getHeader() { - return "\n" + - "
\n" + - "\n" + this.getFileOverview();
+ StringBuffer buffer = new StringBuffer();
+
+ // header
+ buffer
+ .append("\n")
+ .append("\n")
+ .append("\n")
+ .append("");
+
+ // title ("classname xref")
+ try
+ {
+ buffer
+ .append("")
+ .append(FileManager.getInstance().getFile(this.getCurrentFilename()).getClassType().getName())
+ .append(" xref \n");
+
+ }
+ catch (IOException e)
+ {
+ buffer.append("xref \n");
+ e.printStackTrace();
+ }
+
+ // stylesheet link
+ buffer
+ .append("\n");
+
+ buffer.append("\n").append("\n").append(this.getFileOverview());
+
+ // start code section
+ buffer.append("\n");
+
+ return buffer.toString();
}
-
+
/**
* Gets the footer attribute of the CodeTransform object
+ * @return String
*/
public final String getFooter()
{
- return "\n" +
- "
" +
- "" + JXR.NOTICE + " " +
- "\n" +
- "\n";
+ return "\n" + "- * - * Given the name of a package... get the number of - * subdirectories/subpackages there would be.
- * - * EX: org.apache.maven == 3
+ *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) { @@ -966,6 +1044,8 @@ public class CodeTransform implements Serializable /** * 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) { @@ -981,9 +1061,7 @@ public class CodeTransform implements Serializable */ boolean isPackage = line.indexOf("package") != -1; - // - if (line.indexOf("import") != -1 || - isPackage) + if (line.indexOf("import") != -1 || isPackage) { start = line.trim().indexOf(" "); @@ -1005,13 +1083,13 @@ public class CodeTransform implements Serializable pkg = StringUtils.replace(pkg, ".*", ""); } - else if (isPackage == false) + 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(). @@ -1019,10 +1097,10 @@ public class CodeTransform implements Serializable // // 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); @@ -1043,33 +1121,27 @@ public class CodeTransform implements Serializable 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) + if (packageManager.getPackageType(pkg) != null || isPackage) { //Create an HREF for explicit classname imports if (classname != null) { - line = StringUtils.replace(line, classname, "" + - classname + - ""); + line = + StringUtils.replace( + line, + classname, + "" + classname + ""); } //now replace the given package with a href - line = StringUtils.replace(line, pkg, "" + - pkg + - ""); + line = + StringUtils.replace( + line, + pkg, + "" + pkg + ""); } } @@ -1077,10 +1149,10 @@ public class CodeTransform implements Serializable return line; } - /** * From the current file, determine the package root based on the current * path. + * @return String */ public final String getPackageRoot() { @@ -1113,6 +1185,8 @@ public class CodeTransform implements Serializable /** * 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) { @@ -1136,8 +1210,7 @@ public class CodeTransform implements Serializable char current = line.charAt(j); - if (Character.isLetterOrDigit(current) == false && - isInvalidURICharacter(current)) + if (!Character.isLetterOrDigit(current) && isInvalidURICharacter(current)) { end = j; break; @@ -1155,21 +1228,17 @@ public class CodeTransform implements Serializable String uri = line.substring(start, end); - line = StringUtils.replace(line, uri, "" + - uri + - ""); - + line = + StringUtils.replace( + line, + uri, + "" + uri + ""); } - } - } //if we are in a multiline comment we should not call JXR here. - if (inMultiLineComment == false && - inJavadocComment == false) + if (!inMultiLineComment && !inJavadocComment) { return jxrFilter(line); } @@ -1180,22 +1249,21 @@ public class CodeTransform implements Serializable } - /** * 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;
@@ -1203,6 +1271,7 @@ public class CodeTransform implements Serializable
/**
* The current revision of the CVS module
+ * @return String
*/
public final String getRevision()
{
@@ -1211,6 +1280,7 @@ public class CodeTransform implements Serializable
/**
* The current source file being read
+ * @return source file name
*/
public final String getSourcefile()
{
@@ -1219,6 +1289,7 @@ public class CodeTransform implements Serializable
/**
* The current dest file being written
+ * @return destination file name
*/
public final String getDestfile()
{
@@ -1227,19 +1298,21 @@ public class CodeTransform implements Serializable
/**
* 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)
+ public final String xrLine(String line, String packageName, ClassType classType)
{
StringBuffer buff = new StringBuffer(line);
@@ -1251,7 +1324,6 @@ public class CodeTransform implements Serializable
if (classType != null)
{
href = this.getHREF(packageName, classType);
- //find = packageName + "." + classType.getName();
find = classType.getName();
}
else
@@ -1259,19 +1331,16 @@ public class CodeTransform implements Serializable
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
- //StringEntry se = SimpleWordTokenizer.tokenize( buff.toString(),
-
//now replace the word in the buffer with the link
-
String replace = link;
-
StringEntry[] tokens = SimpleWordTokenizer.tokenize(buff.toString(), find);
for (int l = 0; l < tokens.length; ++l)
@@ -1289,9 +1358,11 @@ public class CodeTransform implements Serializable
/**
* 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)
+ public final String xrLine(String line, String packageName)
{
String href = this.getHREF(packageName);
@@ -1301,10 +1372,7 @@ public class CodeTransform implements Serializable
//build out what the link would be.
String link = "" + find + "";
- //System.out.println( "find" );
-
return StringUtils.replace(line, find, link);
}
}
-
diff --git a/jxr/src/plugin-resources/stylesheet.css b/jxr/src/plugin-resources/stylesheet.css
index 44c5a087..d8945b24 100644
--- a/jxr/src/plugin-resources/stylesheet.css
+++ b/jxr/src/plugin-resources/stylesheet.css
@@ -1,45 +1,96 @@
/* Javadoc style sheet */
-
/* Define colors, fonts and other style attributes here to override the defaults */
+body {
+ background-color: #fff;
+ font-family: Arial, Helvetica, sans-serif;
+}
-/* Page background color */
-body { background-color: #FFFFFF }
+a:link {
+ color: #00f;
+}
+a:visited {
+ color: #00a;
+}
-a:link, a:visited {
- color: blue;
- }
-
-a:active, a:hover, #leftcol a:active, #leftcol a:hover {
+a:active, a:hover {
color: #f30 !important;
- }
+}
-a:link.selfref, a:visited.selfref {
- color: #555 !important;
- }
+ul, li {
+ list-style-type:none ;
+ margin:0;
+ padding:0;
+}
-.a td {
- background: #ddd;
- color: #000;
- }
+table td{
+ padding: 3px;
+ border: 1px solid #000;
+}
+table{
+ width:100%;
+ border: 1px solid #000;
+ border-collapse: collapse;
+}
-/* Table colors */
-.TableHeadingColor { background: #036; color:#FFFFFF } /* Dark blue */
-.TableSubHeadingColor { background: #bbb; color:#fff } /* Dark grey */
-.TableRowColor { background: #efefef } /* White */
+div.overview {
+ background-color:#ddd;
+ padding: 4px 4px 4px 0;
+}
+div.overview li, div.framenoframe li {
+ display: inline;
+}
+div.framenoframe {
+ text-align: center;
+ font-size: x-small;
+}
+div.framenoframe li {
+ margin: 0 3px 0 3px;
+}
+div.overview li {
+ margin:3px 3px 0 3px;
+ padding: 4px;
+}
+li.selected {
+ background-color:#888;
+ color: #fff;
+ font-weight: bold;
+}
-/* Font used in left-hand frame lists */
-.FrameTitleFont { font-size: normal; font-family: normal; color:#000000 }
-.FrameHeadingFont { font-size: normal; font-family: normal; color:#000000 }
-.FrameItemFont { font-size: normal; font-family: normal; color:#000000 }
+table.summary {
+ margin-bottom: 20px;
+}
+table.summary td, table.summary th {
+ font-weight: bold;
+ text-align: left;
+ padding: 3px;
+}
+table.summary th{
+ background-color:#036;
+ color: #fff;
+}
+table.summary td{
+ background-color:#eee;
+ border: 1px solid black;
+}
-/* Example of smaller, sans-serif font in frames */
-/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
-
-/* Navigation bar fonts and colors */
-.NavBarCell1 { background-color:#ddd;}/* Light mauve */
-.NavBarCell1Rev { background-color:#888;}/* Dark Blue */
-.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
-.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
-
-.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
-.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
+em {
+ color: #A00;
+}
+em.comment {
+ color: #390;
+}
+.string {
+ color: #009;
+}
+div#footer {
+ text-align:center;
+}
+#overview {
+ padding:2px;
+}
+
+
+hr {
+ height: 1px;
+ color: #000;
+}
\ No newline at end of file
diff --git a/jxr/src/plugin-resources/templates/allclasses-frame.jelly b/jxr/src/plugin-resources/templates/allclasses-frame.jelly
index 55bc45e2..ef1c5e7c 100644
--- a/jxr/src/plugin-resources/templates/allclasses-frame.jelly
+++ b/jxr/src/plugin-resources/templates/allclasses-frame.jelly
@@ -1,33 +1,25 @@
|
- - |
-
-
You don't have frames. Go here
++ You don't have frames. Go + here +
|
-
- All Classes
-
-
- Packages
- + + All Classes +-- Packages- |
-
| - - Packages - - | -|||||||||||||||||||||
| - - ${pkgInfo.name} - - | +|||||||||||||||||||||
| Packages |
|---|
| + ${pkgInfo.name} + | +
-
-
|
- - - - | -|||
| - - FRAMES - - NO FRAMES - - | -||||
|
- Classes
- + - - Classes+ +
|
-
| - Class Summary - | -|||||||||
| - ${classInfo.name} - | + +|||||||||
| Class Summary |
|---|
| + ${classInfo.name} + | +
-
-
|
- - - - | -|||
| - - FRAMES - - NO FRAMES - - | -||||