Back to overview of XmlDoclet

Provides a lot of information of classes, interfaces, methods and so on. This document generator covers most use cases, especially since it has a few configuration options.

This is how you would send parameter values to the document generator from a Maven POM file:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-javadoc-plugin</artifactId>
  ...
  <configuration>
    ...
    <doclet>info.mikaelsvensson.devtools.doclet.xml.XmlDoclet</doclet>
    ...
    <additionalparams>
      -format.name standard
      -format.property.showAnnotations parameter_value
      -format.property.showTypeParameters parameter_value
      -format.property.showInheritedInterfaces parameter_value
      -format.property.showFields parameter_value
      -format.property.textOnlyComments parameter_value
      -format.property.showAllTags parameter_value
    </additionalparams>
...

Document Creator Format Options

showAnnotations
showTypeParameters
showInheritedInterfaces
showFields
textOnlyComments
showAllTags

Samples

There are 7 samples for this document creator:

AnnotatedClass

Source:

package info.mikaelsvensson.devtools;

import info.mikaelsvensson.devtools.doclet.xml.FormatProperty;

public class AnnotatedClass {
    @FormatProperty
    public static final String TEST = "testing";
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<packages>
    <package name="info.mikaelsvensson.devtools">
        <class abstract="false" access="public" extends="java.lang.Object" interface="false" name="AnnotatedClass" qualified-name="info.mikaelsvensson.devtools.AnnotatedClass" serializable="false">
            <methods/>
            <interfaces/>
        </class>
    </package>
</packages>

ClassA

Source:

package info.mikaelsvensson.devtools;

import java.util.List;
import java.util.Map;

/**
 * Class comment
 */
public class ClassA {

    public static final String A_CONSTANT = "value";

    /**
     * this is a private integer constant used for... nothing.
     */
    private static final int PRIVATE_INTEGER = 1;

    private String field1;
    public String field2;

    public void voidMethod(String... variableArgs) {

    }

    private int intMethod(int[][] table) {
        return 0;
    }

    /**
     * This method handles numbers. Unfortunately this comment contains a {@unrecognized weird} inline <code>tag</code>.
     *
     * @param numberParameter
     *         parameter comment
     * @param <T>
     *         a comment
     * @return something
     * @customtag
     */
    protected <T extends Number> T numberMethod(T numberParameter) {
        return null;
    }

    /**
     * This is a comment with both <code>HTML</code> style and {@code Javadoc} style tags.
     *
     * @return a grouped list
     * @throws Exception
     *         when something does wrong.
     */
    Map<String, List<String>> getGroupedStrings() throws Exception {
        return null;
    }
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<packages>
    <package name="info.mikaelsvensson.devtools">
        <class abstract="false" access="public" extends="java.lang.Object" interface="false" name="ClassA" qualified-name="info.mikaelsvensson.devtools.ClassA" serializable="false">
            <methods>
                <method abstract="false" access="public" constructor="false" final="false" name="voidMethod" partofproperty="false" static="false" synchronized="false">
                    <parameters>
                        <parameter type="java.lang.String"/>
                    </parameters>
                    <returns type="void"/>
                    <exceptions/>
                </method>
                <method abstract="false" access="private" constructor="false" final="false" name="intMethod" partofproperty="false" static="false" synchronized="false">
                    <parameters>
                        <parameter type="int"/>
                    </parameters>
                    <returns type="int"/>
                    <exceptions/>
                </method>
                <method abstract="false" access="package" constructor="false" final="false" name="numberMethod" partofproperty="false" static="false" synchronized="false">
                    <parameters>
                        <parameter type="T"/>
                    </parameters>
                    <returns type="T"/>
                    <comment format="html">
                        <p>This method handles numbers. Unfortunately this comment contains a <span class="tag-unrecognized">weird</span> inline <code>tag</code>.</p>
                    </comment>
                    <exceptions/>
                </method>
                <method abstract="false" access="default" constructor="false" final="false" name="getGroupedStrings" partofproperty="false" static="false" synchronized="false">
                    <parameters/>
                    <returns type="java.util.Map">
                        <typeparameter type="java.lang.String"/>
                        <typeparameter type="java.util.List"/>
                    </returns>
                    <comment format="html">
                        <p>This is a comment with both <code>HTML</code> style and <code>Javadoc</code> style tags.</p>
                    </comment>
                    <exceptions>
                        <exception qualified-name="java.lang.Exception">
                            <comment format="html">
                                <p>when something does wrong.</p>
                            </comment>
                        </exception>
                    </exceptions>
                </method>
            </methods>
            <comment format="html">
                <p>Class comment</p>
            </comment>
            <interfaces/>
        </class>
    </package>
</packages>

Contact

Source:

package info.mikaelsvensson.devtools;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Pojo(name = "ca")
public class Contact {
    @Required
    private String emailAddress;

    @Required
    private String name;

    @NumericRange(min = 1900)
    private int birthYear;

    @Text(condition = "^[0-9\\s]+$", conditionType = TextConditionType.REGEXP)
    @Required
    private String zipCode;

    @Texts({@Text(condition = "sv_SE", conditionType = TextConditionType.EQUALS), @Text(condition = "en", conditionType = TextConditionType.STARTS_WITH)})
    private String preferredLocale;
}

@Target(ElementType.TYPE)
@interface Pojo {
    String name();
}

@Target(ElementType.FIELD)
@interface Text {
    String condition();

    TextConditionType conditionType() default TextConditionType.EQUALS;
}

@Target(ElementType.FIELD)
@interface Texts {
    Text[] value();
}

@Target(ElementType.FIELD)
@interface NumericRange {
    long min() default Long.MIN_VALUE;

    long max() default Long.MAX_VALUE;
}

@interface Required {

}

enum TextConditionType {
    EQUALS,
    STARTS_WITH,
    REGEXP
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<packages>
    <package name="info.mikaelsvensson.devtools">
        <class abstract="false" access="public" extends="java.lang.Object" interface="false" name="Contact" qualified-name="info.mikaelsvensson.devtools.Contact" serializable="false">
            <methods/>
            <interfaces/>
        </class>
        <class abstract="true" access="default" interface="false" name="Pojo" qualified-name="info.mikaelsvensson.devtools.Pojo" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="java.lang.annotation.Annotation"/>
            </interfaces>
        </class>
        <class abstract="true" access="default" interface="false" name="Text" qualified-name="info.mikaelsvensson.devtools.Text" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="java.lang.annotation.Annotation"/>
            </interfaces>
        </class>
        <class abstract="true" access="default" interface="false" name="Texts" qualified-name="info.mikaelsvensson.devtools.Texts" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="java.lang.annotation.Annotation"/>
            </interfaces>
        </class>
        <class abstract="true" access="default" interface="false" name="NumericRange" qualified-name="info.mikaelsvensson.devtools.NumericRange" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="java.lang.annotation.Annotation"/>
            </interfaces>
        </class>
        <class abstract="true" access="default" interface="false" name="Required" qualified-name="info.mikaelsvensson.devtools.Required" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="java.lang.annotation.Annotation"/>
            </interfaces>
        </class>
        <enum access="default" extends="java.lang.Enum" name="TextConditionType" qualified-name="info.mikaelsvensson.devtools.TextConditionType" serializable="true">
            <value name="EQUALS"/>
            <value name="STARTS_WITH"/>
            <value name="REGEXP"/>
            <interfaces/>
        </enum>
    </package>
</packages>

Fruit

Source:

package enumeration;

import java.awt.*;

public enum Fruit {

    APPLE(Color.RED),
    ORANGE(Color.ORANGE),
    BANANA(Color.YELLOW),
    PEAR(Color.GREEN);

    private Fruit(final Color color) {
        this.color = color;
    }

    private Color color;

    public Color color() {
        return color;
    }
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<packages>
    <package name="enumeration">
        <enum access="public" extends="java.lang.Enum" name="Fruit" qualified-name="enumeration.Fruit" serializable="true">
            <value name="APPLE"/>
            <value name="ORANGE"/>
            <value name="BANANA"/>
            <value name="PEAR"/>
            <interfaces/>
        </enum>
    </package>
</packages>

GenericInterface

Source:

import java.util.Map;

public interface GenericInterface<N extends Number> {
    N getNumber();

    void setNumber(N number);

    Map<N, String> getMap();

    void setMap(Map<N, String> map);
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<packages>
    <package name="">
        <class abstract="true" access="public" interface="true" name="GenericInterface" qualified-name="GenericInterface" serializable="false">
            <methods>
                <method abstract="false" access="public" constructor="false" final="false" name="getNumber" partofproperty="true" static="false" synchronized="false">
                    <parameters/>
                    <returns type="N"/>
                    <exceptions/>
                </method>
                <method abstract="false" access="public" constructor="false" final="false" name="setNumber" partofproperty="true" static="false" synchronized="false">
                    <parameters>
                        <parameter type="N"/>
                    </parameters>
                    <returns type="void"/>
                    <exceptions/>
                </method>
                <method abstract="false" access="public" constructor="false" final="false" name="getMap" partofproperty="true" static="false" synchronized="false">
                    <parameters/>
                    <returns type="java.util.Map">
                        <typeparameter type="N"/>
                        <typeparameter type="java.lang.String"/>
                    </returns>
                    <exceptions/>
                </method>
                <method abstract="false" access="public" constructor="false" final="false" name="setMap" partofproperty="true" static="false" synchronized="false">
                    <parameters>
                        <parameter type="java.util.Map">
                            <typeparameter type="N"/>
                            <typeparameter type="java.lang.String"/>
                        </parameter>
                    </parameters>
                    <returns type="void"/>
                    <exceptions/>
                </method>
            </methods>
            <interfaces/>
            <implementations/>
        </class>
    </package>
</packages>

NoPackage

Source:

public class NoPackage {
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<packages>
    <package name="">
        <class abstract="false" access="public" extends="java.lang.Object" interface="false" name="NoPackage" qualified-name="NoPackage" serializable="false">
            <methods/>
            <interfaces/>
        </class>
    </package>
</packages>

Vehicle

Source:

package info.mikaelsvensson.devtools;

public class Vehicle {
}

interface Motorized {
}

class Car extends Vehicle {
}

class Truck extends Vehicle implements Motorized, HasItems<Trailer> {
}

class Trailer extends Pullable {
}

class TrainCar extends Pullable {
}

interface HasItems<Pullable> {
}

class Pullable extends Vehicle {
}

class Bicycle extends Vehicle implements Motorized {
}

class Train extends Vehicle implements Motorized, HasItems<TrainCar> {
}

class Metro extends Train {
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<packages>
    <package name="info.mikaelsvensson.devtools">
        <class abstract="false" access="public" extends="java.lang.Object" interface="false" name="Vehicle" qualified-name="info.mikaelsvensson.devtools.Vehicle" serializable="false">
            <methods/>
            <interfaces/>
        </class>
        <class abstract="true" access="default" interface="true" name="Motorized" qualified-name="info.mikaelsvensson.devtools.Motorized" serializable="false">
            <methods/>
            <interfaces/>
            <implementations>
                <implementation qualified-name="info.mikaelsvensson.devtools.Truck"/>
                <implementation qualified-name="info.mikaelsvensson.devtools.Bicycle"/>
                <implementation qualified-name="info.mikaelsvensson.devtools.Train"/>
            </implementations>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Vehicle" interface="false" name="Car" qualified-name="info.mikaelsvensson.devtools.Car" serializable="false">
            <methods/>
            <interfaces/>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Vehicle" interface="false" name="Truck" qualified-name="info.mikaelsvensson.devtools.Truck" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="info.mikaelsvensson.devtools.Motorized"/>
                <interface qualified-name="info.mikaelsvensson.devtools.HasItems"/>
            </interfaces>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Pullable" interface="false" name="Trailer" qualified-name="info.mikaelsvensson.devtools.Trailer" serializable="false">
            <methods/>
            <interfaces/>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Pullable" interface="false" name="TrainCar" qualified-name="info.mikaelsvensson.devtools.TrainCar" serializable="false">
            <methods/>
            <interfaces/>
        </class>
        <class abstract="true" access="default" interface="true" name="HasItems" qualified-name="info.mikaelsvensson.devtools.HasItems" serializable="false">
            <methods/>
            <interfaces/>
            <implementations>
                <implementation qualified-name="info.mikaelsvensson.devtools.Truck"/>
                <implementation qualified-name="info.mikaelsvensson.devtools.Train"/>
            </implementations>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Vehicle" interface="false" name="Pullable" qualified-name="info.mikaelsvensson.devtools.Pullable" serializable="false">
            <methods/>
            <interfaces/>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Vehicle" interface="false" name="Bicycle" qualified-name="info.mikaelsvensson.devtools.Bicycle" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="info.mikaelsvensson.devtools.Motorized"/>
            </interfaces>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Vehicle" interface="false" name="Train" qualified-name="info.mikaelsvensson.devtools.Train" serializable="false">
            <methods/>
            <interfaces>
                <interface qualified-name="info.mikaelsvensson.devtools.Motorized"/>
                <interface qualified-name="info.mikaelsvensson.devtools.HasItems"/>
            </interfaces>
        </class>
        <class abstract="false" access="default" extends="info.mikaelsvensson.devtools.Train" interface="false" name="Metro" qualified-name="info.mikaelsvensson.devtools.Metro" serializable="false">
            <methods/>
            <interfaces/>
        </class>
    </package>
</packages>

Back to top

Reflow Maven skin by Andrius Velykis.