Correction

Lets you control the Javadoc comment checking and auto-correction features.

Figure 2.71. Javadoc Correction settings page

Javadoc Correction settings page

Please note that unlike with the Open Source version, auto-correction may be enabled independently from Javadoc formatting. Still, it is recommended to enable the formatting of comments too, because otherwise you may encounter slight style differences when descriptons or tags are inserted/removed.

Correct HTML

This feature lets you enforce valid HTML. When enabled, Jalopy ensures that the comments only contain valid HTML 4.01 markup. Missing tags like optional end tags will be inserted to ensure well-formed contents.

Example 2.793. Javadoc comment with missing paragraph tags

/**
 * Indicates the kinds of program element to which an annotation type
 * is applicable.  If a Target meta-annotation is not present on an
 * annotation type declaration, the declared type may be used on any
 * program element.  If such a meta-annotation is present, the compiler
 * will enforce the specified usage restriction.
 *
 * For example, this meta-annotation indicates that the declared type is
 * itself a meta-annotation type.  It can only be used on annotation type
 * declarations.
 */

Example 2.794. Javadoc comment with inserted paragraph tags

/**
 * Indicates the kinds of program element to which an annotation type
 * is applicable.  If a Target meta-annotation is not present on an
 * annotation type declaration, the declared type may be used on any
 * program element.  If such a meta-annotation is present, the compiler
 * will enforce the specified usage restriction.
 *
 * <p>For example, this meta-annotation indicates that the declared type
 * is itself a meta-annotation type.  It can only be used on annotation
 * type declarations.</p>
 */

Example 2.795. Javadoc comment with missing </li> tags

/**
 * Returns a short description of this throwable.
 * If this <code>Throwable</code> object was created with a non-null detail
 * message string, then the result is the concatenation of three strings: 
 * <ul>
 * <li> The name of the actual class of this object 
 * <li>": " (a colon and a space)
 * <li>The result of the {@link #getMessage} method for this object 
 * </ul>
 */

Example 2.796. Javadoc comment with inserted </li> tags

/**
 * Returns a short description of this throwable. If this <code>
 * Throwable</code> object was created with a non-null detail message
 * string, then the result is the concatenation of three strings:
 *
 * <ul>
 *   <li>The name of the actual class of this object</li>
 *   <li>": " (a colon and a space)</li>
 *   <li>The result of the {@link #getMessage} method for this object</li>
 * </ul>
 */

Since 1.0

Correct sentence punctuation

When enabled, ensures that the first sentence of the description section ends with punctuation. If no punctuation is present, a dot character will be added at the end of the first sentence. The first sentence is determined by either a blank line between two text chunks or by a HTML block tag. If no obvious sentence break could be found, the dot is added at the end of the description section.

Since 1.6

Example 2.797. Javadoc comment with missing period after first sentence

/**
 * The method used for creating the tree
 * <p>
 * This method adds an anonymous TreeSelectionListener to 
 * the returned JTree.  Upon receiving TreeSelectionEvents, 
 * this listener calls refresh with the selected node as a 
 * parameter. 
 */

Example 2.798. Reformatted Javadoc comment with added period after first sentence

/**
 * The method used for creating the tree.
 
 * <p>This method adds an anonymous TreeSelectionListener to the
 * returned JTree. Upon receiving TreeSelectionEvents, this listener
 * calls refresh with the selected node as a parameter.
 */
Description Section

Provides option to control the behavior of the description section of a Javadoc comments.

The description begins after the starting delimiter /** and continues until the tag section. The tag section starts with the first block tag, which is defined by the first @ character that begins a line (ignoring leading asterisks, white space and comment separator). The main description cannot continue after the tag section begins.

/**
 * This sentence would hold the main description for this doc comment.
 * @see java.lang.Object
 */
Correct description section

When enabled, Jalopy inserts a missing description into existing Javadoc comments. Unlike specified otherwise (see "Use text from @return" below), the description is taken from the template for the code element that contains the Javadoc comment. Refer to the section called "Templates" for information on how to customize the templates.

Since 1.2.1

Only when generation

Only inserts the missing description when Javadoc auto-generation has been enabled for the declaration element that contains the Javadoc comment.

Since 1.2.1

Example 2.799. Insert description when auto-generation enabled

/**
 * @jalopy.group accessor
 */
protected int getFoo () {
    ...
}

will only be formatted to

/**
 * DOCME!
 *
 * @jalopy.group accessor
 */
protected int getFoo () {
    ...
}

when Javadoc comment auto-generation is enabled for method declarations that have an access level of protected.

Only when @param or @return

Only inserts the missing description when a @param or @return block tag can be found in the Javadoc comment.

Since 1.2.1

Example 2.800. Insert description only when @param or @return tag present

With this option enabled, code like

/**
 * @jalopy.group accessor
 */
protected int getFoo () {
    ...
}

will be formatted as

/**
 * @jalopy.group  accessor
 */
protected int getFoo () {
    ...
}

because the Javadoc comment neither contains a @param nor a @return block tag.

But

/**
 * @return        returns the foo property.
 * @jalopy.group  accessor
 */
protected int getFoo () {
    ...
}

will be formatted as

/**
 * DOCME!
 *
 * @return        returns the foo property.
 *
 * @jalopy.group  accessor
 */
protected int getFoo () {
    ...
}

because a @return tag can be found.

Only when no @see

Only inserts the missing description when no @see block tag can be found in the Javadoc comment. The default behavior is to disable the insertion of a missing description if the comment only consists of a single @see block tag or starts with an {@inheritDoc} in-line tag.

In order to avoid adding information that is redundant, one may enable this switch when @see tags are used to point to related documentation.

Since 1.2.1

Example 2.801. Insert description only when no @see tag present

/**
 * @jalopy.group accessor
 */
protected int getFoo () {
    ...
}

would be formatted as

/**
 * DOCME!
 *
 * @jalopy.group  accessor
 */
protected int getFoo () {
    ...
}

because the Javadoc comment contains no @see tag.

But

/**
 * @jalopy.group  accessor
 * @see           #com.foo.OtherClass
 */
protected int getFoo () {
    ...
}

would be formatted as

/**
 * @jalopy.group  accessor
 * @see           #com.foo.OtherClass 
 */
protected int getFoo () {
    ...
}

because a @see tag can be found.

Use text from @return

When enabled, the description text of the @return tag is used (when present) for a missing description. The first letter of the text will upper-cased.

Since 1.5

Example 2.802. Javadoc with missing description section

/**
 * @return  returns the result of the operation.
 */
public Object getResult() {
    ...
}

Example 2.803. Missing description generated from template

/**
 * TODO: DOCME!
 * 
 * @return  returns the result of the operation.
 */
public Object getResult() {
    ...
}

Example 2.804. Missing description generated from @return tag

/**
 * Returns the result of the operation.
 * 
 * @return  returns the result of the operation.
 */
public Object getResult() {
    ...
}
Tag Section

Provides options to control the behavior for the block tags of Javadoc commnets.

The description begins after the starting delimiter /** and continues until the tag section. The tag section starts with the first block tag, which is defined by the first @ character that begins a line (ignoring leading asterisks, white space and comment separator). The main description cannot continue after the tag section begins. There can be any number of tags - some types of tags can be repeated while others cannot. In the following example, the @see tags starts the tag section:

/**
 * This sentence would hold the main description for this doc comment.
 * @see java.lang.Object
 */
Correct tag section

When enabled, missing Javadoc block tags will be inserted, obsolete tags can be removed. Spelling errors of block and in-line tags are corrected.

The description of a tag is taken from the template for the code element that contains the Javadoc comment. Refer to the section called "Templates" for information on how to customize the templates.

Only when generation

Only corrects tags when Javadoc auto-generation has been enabled for the declaration element that contains the Javadoc comment.

Since 1.2.1

Example 2.805. Only correct tags when auto-generation enabled

/**
 * @jalopy.group accessor
 */
protected int getFoo () {
    ...
}

will only be formatted to

/**
 * @return       DOCME!
 *
 * @jalopy.group accessor
 */
protected int getFoo () {
    ...
}

when Javadoc comment auto-generation is enabled for method declarations that have an access level of protected.

Only when @param or @return

Only corrects tags when a @param or @return block tag can be found in the Javadoc comment.

Since 1.2.1

Example 2.806. Only correct tags when @param or @return tag present

With this option enabled, code like

/**
 * @jalopy.group  accessor
 */
protected int getFoo (int param) {
    ...
}

will be formatted as

/**
 * @jalopy.group  accessor
 */
protected int getFoo (int param) {
    ...
}

because the Javadoc comment neither contains a @param nor a @return block tag.

But

/**
 * @param         param  a parameter
 * @jalopy.group  accessor
 */
protected int getFoo (int param) {
    ...
}

will be formatted as

/**
 * @param         param  a parameter
 *
 * @return        returns  the foo property.
 *
 * @jalopy.group  accessor
 */
protected int getFoo (int param) {
    ...
}

because a @param tag can be found.

Only when no @see

Disables the auto-correction when a @see tag is found in the comment. The default behavior is to disable auto-correction if the comment only consists of a single @see block tag or starts with an {@inheritDoc} in-line tag.

In order to avoid adding information that is redundant, one may enable this switch when @see tags are used to point to related documentation.

Since 1.0.1

Misspelled tag names

When enabled, misspelled Javadoc tag names will be corrected when possible.

When Jalopy encounters an invalid tag name, i.e. the name is not part of the list with valid tag names, it determines wether the tag name is vastly similar with one on the list. If so, Jalopy will pick the one from the list otherwise it reports an error.

For information about the build-in list with valid Javadoc tag names refer to the section called "Block tags", the section called "In-line tags" and Appendix B, Build-in XDoclet tags.

Since 1.3

Add @throws tags

When enabled, performs an additional check for exceptions that are actually thrown from within a constructor or method body, but not documented and adds block tags. E.g. if a method only declares to throw an IOException, but actually throws a FileNotFoundException, and this FileNotFoundException has not been documented with a @throws tag, it will be added.

Example 2.807. Undocumented exception

/**
 * Description
 *
 * @param   rFile  input file.
 *
 * @throws  IOException if an I/O problem occured.
 */
public void sample(File rFile) throws IOException {
    if (rFile.exists())
        throw new FileNotFoundException();

    ...
}

Example 2.808. Added exception

/**
 * Description
 *
 * @param   rFile  input file.
 *
 * @throws  IOException            if an I/O problem occured.
 * @throws  FileNotFoundException  DOCUMENT ME!
 */
public void sample(File rFile) {
    if (rFile.exists())
        throw new FileNotFoundException();

    ...
}
Ignore runtime exceptions

When enabled, no tags will be added or removed for runtime exceptions and errors that are thrown from within a method or constructor body.

Please note that enabling this option will cause present @throws tags that document runtime exceptions or errors to be removed! If you want to keep existing tags, please enable the "Keep @throws tags" option as well.

You have to explicitly enable type repository services for the Ant, Console and Maven Plug-ins to activate this feature! Please refer to the documentation of the individual Plug-ins to learn how one can accomplish this (see Part II, "Plug-ins").

Since 1.0

Example 2.809. Generated missing throws clause

/**
 * Description
 *
 * @throws  IllegalArgumentException  DOCME!
 */
public void isNewline(int offset) {
    if (input <= 1) throw new IllegalArgumentException();
    ..
}

Example 2.810. No throws clause generated for runtime exception

/**
 * Description
 */
public void isNewline(int offset) {
    if (input <= 1) throw new IllegalArgumentException();
    ..
}
Keep @throws tags

When enabled, no existing @throws tags are removed from comments. This feature proves useful if you have comments with existing @throws tags for runtime exceptions that are not actually thrown from within a method body.

Since 1.0

Add template tags

When enabled, tags that are defined in the Javadoc template but missing in the Javadoc comment of the corresponding declaration node are inserted.

Missing tags are only inserted when their declaration has its Javadoc generation option enabled for the current scope. This holds true if even when the Javadoc comment generation is disabled globally in order to allow fine grained control when and for what declartions missing tags should be inserted. Please refer to Enable Javadoc generation for for information on how to enable Javadoc generation for specific declarations.

For information on how to customize the Javadoc templates, please refer to the section called "Templates".

Since 1.5

Say you have defined your class template to look like this:

Example 2.811. Javadoc template

/**
 * TODO: DOCME!
 *
 * @author $user.name$
 */

Upon reformatting, Jalopy ensures that all existing class level Javadoc comments contain the @author tag. Thus, the following comment

Example 2.812. Javadoc comment

/**
 * Encapsulate an attribute declaration.
 */
class AttributeDecl {
}

could become

Example 2.813. Javadoc comment after formatting

/**
 * Encapsulate an attribute declaration.
 *
 * @author  John Doo
 */
class AttributeDecl {
}

Note how the $user.name variable expression is interpolated during formatting! Environment variables are discussed in the section called "Environment".

Missing tags are added at the end of the tag section in the order they are defined in the template. We recommend to enable Tag sorting in order to ensure a specific ordering.

Add method type parameter tags

When enabled, Jalopy enforces/corrects @param tags for generic method and constructor declarations.

Example 2.814. Generic method

/**
 * blah.
 *
 * @param  string  blah
 *
 * @return  blah
 */
<T, V extends T> V convert(String string);

will have tags inserted for the type parameters.

Since 1.6

Example 2.815. Generic method

/**
 * blah.
 *
 * @param  <T>  blah
 * @param  <V>  blah
 * @param  string     blah
 *
 * @return  blah
 */
<T, V extends T> V convert(String string);

Please note that existing @param tags documenting type parameters will be removed when this option is disabled!

Remove misused tags

When enabled, the validity of block tags will be checked. Not all tags can be used in all contexts. Tags that are invalid will be removed. If left disabled, Jalopy only prints warnings about misused tags.

Since 1.0

Use description for @return

When enabled, the text for a missing @return tag description is not taken from the template, but the first sentence of description section is taken (when present). The first letter of the description will be lower-cased.

Since 1.5

Example 2.816. Javadoc with missing @return tag description

/**
 * Returns the result of the calculation.
 */
public Object getResult() {
   ...
}

Example 2.817. Javadoc with @return tag description inserted from template

/**
 * Returns the result of the calculation.
 *
 * @return  DOCME!
 */
public Object getResult() {
   ...
}

Example 2.818. Javadoc with @return tag description taken from description section

/**
 * Returns the result of the calculation.
 *
 * @return returns the result of the calculation.
 */
public Object getResult() {
   ...
}
Add missing description

When enabled, missing descriptions of certain Javadoc block tags will be tagged with a marker. The tag marker is inserted for the following tags: @author, @deprecated, @exception, @param, @return, @see, @serialData, @serialField, @since, @throws, @version.

The marker text is taken from the description section of corresponding template.

XDoclet or custom tags will remain untouched.

Since 1.5

Example 2.819. Tags with missing description

/*
 * HTML is the top level element
 *
 * @param lexer
 *
 * @return
 */
public static Node parseDocument(Lexer lexer) {}

When the option is left disabled, the above example would become

Example 2.820. Tags with missing desccription

/**
 * HTML is the top level element
 *
 * @param   lexer
 *
 * @return
 */
public static Node parseDocument(Lexer lexer) {}

But when the option is enabled, the result would be

Example 2.821. Tagged missing descriptions

/**
 * HTML is the top level element
 *
 * @param   lexer  DOCME!
 *
 * @return  DOCME!
 */
public static Node parseDocument(Lexer lexer) {}