Back to overview of XmlDoclet

Very simple document creator which only outputs a list of class names.

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 elementsonly
    </additionalparams>
...

Document Creator Format Options

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"?>
<classes>
    <class>
        <name>info.mikaelsvensson.devtools.AnnotatedClass</name>
    </class>
</classes>

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"?>
<classes>
    <class>
        <name>info.mikaelsvensson.devtools.ClassA</name>
    </class>
</classes>

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"?>
<classes>
    <class>
        <name>info.mikaelsvensson.devtools.Contact</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Pojo</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Text</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Texts</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.NumericRange</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Required</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.TextConditionType</name>
    </class>
</classes>

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"?>
<classes>
    <class>
        <name>enumeration.Fruit</name>
    </class>
</classes>

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"?>
<classes>
    <class>
        <name>GenericInterface</name>
    </class>
</classes>

NoPackage

Source:

public class NoPackage {
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<classes>
    <class>
        <name>NoPackage</name>
    </class>
</classes>

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"?>
<classes>
    <class>
        <name>info.mikaelsvensson.devtools.Vehicle</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Motorized</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Car</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Truck</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Trailer</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.TrainCar</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.HasItems</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Pullable</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Bicycle</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Train</name>
    </class>
    <class>
        <name>info.mikaelsvensson.devtools.Metro</name>
    </class>
</classes>

Back to top

Reflow Maven skin by Andrius Velykis.