Class AddJavaDoc

java.lang.Object
   |
   +----AddJavaDoc

public class AddJavaDoc
extends Object
Adds javadoc comment templates to source by using output of iDoc by Reto Kramer. Currently adds class/interface/variable/method descriptor templates, method parameter templates and method return value templates. Additionally generates javadoc comments indicating obsolete and nonjavadoc tags. See the variable unjavadocumentedvariablefortesting and the method testAddJavaDoc below for an example.

Typical usage is:

    java iDoc.Tools -s -n -t %classname%.java >%classname%.idoc
    java AddJavaDoc %classname%.idoc %classname%.java [%header_file%]
 

The output (source with javadoc templates) PROVIDED NOTHING BAD HAPPENS is put into %classname%.jdoc. I strongly recommend verification (a compile and run of javadoc should be sufficient) before toasting the original.

If you run it on this class, it should look something like:

 C:\myJava>java iDoc.Tool -s -n -t AddJavaDoc.java >AddJavaDoc.idoc
 C:\myJava>java AddJavaDoc AddJavaDoc.idoc AddJavaDoc.java
 0  306 iDoc.Variable Title
 1  311  NONJAVADOC
 2  311  OBSOLETE iDoc.Method params obsoleteparm
 3  311 iDoc.Method Title
 4  311 iDoc.Method params missingparm returns
 
optionally
 C:\myJava>copy AddJavaDoc.jdoc t.java
 C:\myJava>javadoc -private -author -version -notree t.java
 
will generate AddJavaDoc.html which will look very much like what you are reading now.

VERIFY THE .JDOC BEFORE COPYING BACK TO THE .JAVA -- I think this code is correct for now, but iDoc could change or an exception could happen and if you didn't verify it with at least a compile and a run of javadoc then you will lose your original source when copying the .jdoc to .java. Backups are always good too.

It should System.exit(1) if it encounters a problem, and you can test this in the shell (eg. IF ERRORLEVEL 1 in DOS) to see if it completed successfully. Again, there are no guarantees -- keep backups of your source.

Just as an example, here is the .BAT file I use.

 java iDoc.Tool -s -n -t %1.java >%1.idoc
 if errorlevel 1 goto :errorexit
 java AddJavaDoc %1.idoc %1.java c:\myjava\freeheader.txt
 if errorlevel 1 goto :errorexit
 copy %1.java %1.jbak
 if errorlevel 1 goto :errorexit
 copy %1.jdoc %1.java
 echo Completed...
 goto :exit
 :errorexit
 echo ERROR!!!
 :exit
 echo exiting.
 
Obviously, I make backups of the source before running it (in addition to the one it makes) JUST IN CASE.

Ideally, the source is available with this page by clicking on "the source".

Be sure to check AddJavaDoc's "home page" at http://parasol.cs.tamu.edu/people/jack/fromCS/java/AddJavaDoc/AddJavaDoc.html for updates.

Revisions:

Version:
0.0004 13 Jul 1998
Author:
Jack Perdue j-perdue@tamu.edu si_slick@cy-net.net

Variable Index

 o authortag
customized javadoc author tag (hard-coded for now -- needs servicing)
 o BADCOMMENT
Disallowed comment starter (change if desired)
 o CLASSTITLE
code for iDoc unlabeled class error
 o dobadcommentcheck
Disable bad comment check.
 o errorcode
code for iDoc error
 o FILL
indicates user needs to provide info for javadoc
 o FILLNONJAVADOC
indicates user needs to service some unrecognized javadoc comments
 o FILLOBSOLETETAG
indicates user needs to service a parameter tag
 o IDOCCLASSTAG
iDoc class tag
 o IDOCCOMMENTTAG
iDoc comment tag
 o IDOCERRORTAG
iDoc error tag
 o IDOCINTERFACETAG
iDoc interface tag
 o IDOCMETHODTAG
iDoc method tag
 o IDOCMISSINGTAG
iDoc missing tag
 o IDOCNONJAVADOCTAG
iDoc non-javadoc comment tag
 o IDOCOBSOLETETAG
iDoc obsolete tag
 o IDOCPARAMTAG
iDoc param tag
 o IDOCRETURNTAG
iDoc return tag
 o IDOCSCANNEREXCEPTIONTAG
iDoc Scanner exception tag
 o IDOCVARIABLETAG
iDoc variable tag
 o INTERFACETITLE
code for iDoc unlabeled interface error
 o JAVADOCAUTHOR
javadoc author tag
 o JAVADOCENDCOMMENT
javadoc endcomment
 o JAVADOCMIDDLECOMMENT
javadoc middle comment
 o JAVADOCPARAM
javadoc parameter tag
 o JAVADOCRETURN
javadoc return tag
 o JAVADOCSTARTCOMMENT
javadoc start comment
 o JAVADOCVERSION
javadoc version tag
 o lineno
line number the errorcode occurred
 o MAXPARAMS
maximum number of parameters a method can have
 o MAXREADFORMARK
Error file size limit
 o METHODPARAMRETURN
code for iDoc method parameters and return error
 o METHODPARAMVOID
code for iDoc method parameters error
 o METHODTITLE
code for iDoc unlabeled method error
 o NONJAVADOC
code for iDoc non-javadoc comment error
 o OBSOLETETAG
code for iDoc obsolete parameter tag error
 o params
parameters for method
 o unjavadocumentedvariablefortesting
+XX+
 o VARIABLETITLE
code for iDoc unlabeled variable error
 o versiontag
customized javadoc version tag (hard-coded for now -- needs servicing)

Constructor Index

 o AddJavaDoc(int, int, String[])
Constructs an iDoc errorcode entry (a future javadoc comment)

Method Index

 o addJavaDocs(String, AddJavaDoc[], String[])
adds javadoc comments to source code
 o iDocErrors(String)
reads iDoc errorcode file
 o main(String[])
Adds javadoc comments to code.
 o parseError(String)
parses iDoc error
 o readHeaders(String)
reads header (copyright) file into buffer
 o sortErrors(AddJavaDoc[])
sorts errors by line number and type
 o swap(AddJavaDoc[], int, int)
swaps two iDoc errors
 o testAddJavaDoc(int)
NONJAVADOC OBSOLETETAG obsoleteparm +XX+ +XX+
 o toString()
converts an iDoc errorcode (future javadoc addition) to a string

Variables

 o MAXREADFORMARK
 static int MAXREADFORMARK
Error file size limit

 o MAXPARAMS
 static int MAXPARAMS
maximum number of parameters a method can have

 o CLASSTITLE
 static final int CLASSTITLE
code for iDoc unlabeled class error

 o INTERFACETITLE
 static final int INTERFACETITLE
code for iDoc unlabeled interface error

 o VARIABLETITLE
 static final int VARIABLETITLE
code for iDoc unlabeled variable error

 o METHODTITLE
 static final int METHODTITLE
code for iDoc unlabeled method error

 o METHODPARAMVOID
 static final int METHODPARAMVOID
code for iDoc method parameters error

 o METHODPARAMRETURN
 static final int METHODPARAMRETURN
code for iDoc method parameters and return error

 o NONJAVADOC
 static final int NONJAVADOC
code for iDoc non-javadoc comment error

 o OBSOLETETAG
 static final int OBSOLETETAG
code for iDoc obsolete parameter tag error

 o FILL
 static String FILL
indicates user needs to provide info for javadoc

 o FILLOBSOLETETAG
 static String FILLOBSOLETETAG
indicates user needs to service a parameter tag

 o FILLNONJAVADOC
 static String FILLNONJAVADOC
indicates user needs to service some unrecognized javadoc comments

 o IDOCSCANNEREXCEPTIONTAG
 static String IDOCSCANNEREXCEPTIONTAG
iDoc Scanner exception tag

 o IDOCCLASSTAG
 static String IDOCCLASSTAG
iDoc class tag

 o IDOCINTERFACETAG
 static String IDOCINTERFACETAG
iDoc interface tag

 o IDOCVARIABLETAG
 static String IDOCVARIABLETAG
iDoc variable tag

 o IDOCMETHODTAG
 static String IDOCMETHODTAG
iDoc method tag

 o IDOCERRORTAG
 static String IDOCERRORTAG
iDoc error tag

 o IDOCNONJAVADOCTAG
 static String IDOCNONJAVADOCTAG
iDoc non-javadoc comment tag

 o IDOCCOMMENTTAG
 static String IDOCCOMMENTTAG
iDoc comment tag

 o IDOCMISSINGTAG
 static String IDOCMISSINGTAG
iDoc missing tag

 o IDOCOBSOLETETAG
 static String IDOCOBSOLETETAG
iDoc obsolete tag

 o IDOCPARAMTAG
 static String IDOCPARAMTAG
iDoc param tag

 o IDOCRETURNTAG
 static String IDOCRETURNTAG
iDoc return tag

 o dobadcommentcheck
 static final boolean dobadcommentcheck
Disable bad comment check. Change if desired. However, enabling will cause errors when processing this class.

 o BADCOMMENT
 static final String BADCOMMENT
Disallowed comment starter (change if desired)

 o JAVADOCSTARTCOMMENT
 static final String JAVADOCSTARTCOMMENT
javadoc start comment

 o JAVADOCMIDDLECOMMENT
 static final String JAVADOCMIDDLECOMMENT
javadoc middle comment

 o JAVADOCENDCOMMENT
 static final String JAVADOCENDCOMMENT
javadoc endcomment

 o JAVADOCPARAM
 static final String JAVADOCPARAM
javadoc parameter tag

 o JAVADOCRETURN
 static final String JAVADOCRETURN
javadoc return tag

 o JAVADOCAUTHOR
 static final String JAVADOCAUTHOR
javadoc author tag

 o JAVADOCVERSION
 static final String JAVADOCVERSION
javadoc version tag

 o authortag
 static String authortag
customized javadoc author tag (hard-coded for now -- needs servicing)

 o versiontag
 static String versiontag
customized javadoc version tag (hard-coded for now -- needs servicing)

 o lineno
 int lineno
line number the errorcode occurred

 o errorcode
 int errorcode
code for iDoc error

 o params
 String params[]
parameters for method

 o unjavadocumentedvariablefortesting
 static final int unjavadocumentedvariablefortesting
+XX+

Constructors

 o AddJavaDoc
 public AddJavaDoc(int lineno,
                   int errorcode,
                   String params[])
Constructs an iDoc errorcode entry (a future javadoc comment)

Parameters:
lineno - line number in source where javadoc comments are needed
errorcode - type of iDoc error
params - method parameters (to generate lines like this one)

Methods

 o main
 public static void main(String args[])
Adds javadoc comments to code.

Parameters:
args - iDoc filename, source filename, header filename
 o testAddJavaDoc
 final int testAddJavaDoc(int missingparm)
NONJAVADOC OBSOLETETAG obsoleteparm +XX+ +XX+

Parameters:
missingparm - +XX+
Returns:
+XX+
 o readHeaders
 static String[] readHeaders(String headername)
reads header (copyright) file into buffer

Parameters:
headername - name of header file
Returns:
buffer containing text of header file
 o parseError
 public static AddJavaDoc parseError(String line)
parses iDoc error

Parameters:
line - line of text from iDoc errorcode listing
Returns:
a iDoc errorcode (future javadoc addition)
 o iDocErrors
 static AddJavaDoc[] iDocErrors(String idocname)
reads iDoc errorcode file

Parameters:
idocname - name of iDoc errorcode listing
Returns:
list of iDoc errors (future javadoc additions)
 o addJavaDocs
 static void addJavaDocs(String srcname,
                         AddJavaDoc errors[],
                         String headers[])
adds javadoc comments to source code

Parameters:
srcname - name of source code (.java) file
errors - list of iDoc errors (future javadoc additions)
headers - new header for source file
 o swap
 static void swap(AddJavaDoc errors[],
                  int i,
                  int j)
swaps two iDoc errors

Parameters:
errors - list of iDoc errors
i - errorcode to swap
j - errorcode to swap
 o sortErrors
 static void sortErrors(AddJavaDoc errors[])
sorts errors by line number and type

Parameters:
errors - list of iDoc errors (future javadoc addition)
 o toString
 public String toString()
converts an iDoc errorcode (future javadoc addition) to a string

Returns:
string describing iDoc errorcode (future javadoc addition)
Overrides:
toString in class Object