Back to overview of XmlDoclet

Highly specialized document creator which only outputs information about enum classes. On the other hand, it attempts to load each enum constant (using class loader) in order to access their run-time values.

This allows this document creator to access the names, types and values for the enumeration constants.

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 enum
      -format.property.classfolder parameter_value
    </additionalparams>
...

Document Creator Format Options

classfolder

Specified where the compiled classes (*.class files) can be found. The class file folder is used to instantiate enum classes in order to invoke their getters and retrieve their return values.

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"?>
<enumerations/>

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"?>
<enumerations/>

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"?>
<enumerations>
    <enum name="TextConditionType" qualified-name="info.mikaelsvensson.devtools.TextConditionType">
        <interfaces/>
        <constant name="EQUALS"/>
        <constant name="STARTS_WITH"/>
        <constant name="REGEXP"/>
    </enum>
</enumerations>

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"?>
<enumerations>
    <enum name="Fruit" qualified-name="enumeration.Fruit">
        <interfaces/>
        <constant name="APPLE"/>
        <constant name="ORANGE"/>
        <constant name="BANANA"/>
        <constant name="PEAR"/>
    </enum>
</enumerations>

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"?>
<enumerations/>

NoPackage

Source:

public class NoPackage {
}

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<enumerations/>

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"?>
<enumerations/>

Back to top

Reflow Maven skin by Andrius Velykis.