java.lang.Object
org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.JavaDocExtractor

public class JavaDocExtractor extends Object

The schemagen tool operates on compiled bytecode, where JavaDoc comments are not present. However, the javadoc documentation present in java source files is required within the generated XSD to increase usability and produce an XSD which does not loose out on important usage information.

The JavaDocExtractor is used as a post processor after creating the XSDs within the compilation unit, and injects XSD annotations into the appropriate XSD elements or types.

Since:
2.0
  • Field Details

    • DEFAULT_VALUE

      private static final String DEFAULT_VALUE
      The default value given as the return value from some annotation classes whenever the attribute has not been supplied within the codebase.
      See Also:
    • builder

      private com.thoughtworks.qdox.JavaProjectBuilder builder
    • log

      private org.apache.maven.plugin.logging.Log log
  • Constructor Details

    • JavaDocExtractor

      public JavaDocExtractor(org.apache.maven.plugin.logging.Log log)
      Creates a JavaDocExtractor wrapping the supplied Maven Log.
      Parameters:
      log - A non-null Log.
  • Method Details

    • setEncoding

      public void setEncoding(String encoding)
      Assigns the encoding of the underlying JavaProjectBuilder.
      Parameters:
      encoding - The non-empty encoding to be set into the underlying JavaProjectBuilder.
    • addSourceFiles

      public JavaDocExtractor addSourceFiles(List<File> sourceCodeFiles) throws IllegalArgumentException
      Adds the supplied sourceCodeFiles for processing by this JavaDocExtractor.
      Parameters:
      sourceCodeFiles - The non-null List of source code files to add.
      Returns:
      This JavaDocExtractor, for call chaining.
      Throws:
      IllegalArgumentException - If any of the given sourceCodeFiles could not be read properly.
    • addSourceURLs

      public JavaDocExtractor addSourceURLs(List<URL> sourceCodeURLs) throws IllegalArgumentException
      Adds the supplied sourceCodeFiles for processing by this JavaDocExtractor.
      Parameters:
      sourceCodeURLs - The non-null List of source code URLs to add.
      Returns:
      This JavaDocExtractor, for call chaining.
      Throws:
      IllegalArgumentException - If any of the given sourceCodeURLs could not be read properly.
    • process

      public SearchableDocumentation process()
      Processes all supplied Java source Files and URLs to extract JavaDocData for all ClassLocations from which JavaDoc has been collected.
      Returns:
      A SearchableDocumentation relating SortableLocations and their paths to harvested JavaDocData.
    • getAnnotationAttributeValueFrom

      private static String getAnnotationAttributeValueFrom(Class<?> annotationType, String attributeName, List<com.thoughtworks.qdox.model.JavaAnnotation> annotations)
      Finds the value of the attribute with the supplied name within the first matching JavaAnnotation of the given type encountered in the given annotations List. This is typically used for reading values of annotations such as XmlElement, XmlAttribute or XmlEnumValue.
      Parameters:
      annotationType - The type of annotation to read attribute values from.
      attributeName - The name of the attribute the value of which should be returned.
      annotations - The list of JavaAnnotations to filter from.
      Returns:
      The first matching JavaAnnotation of type annotationType within the given annotations List, or null if none was found.
      Since:
      2.2
    • hasAnnotation

      private static boolean hasAnnotation(Class<?> annotationType, List<com.thoughtworks.qdox.model.JavaAnnotation> annotations)
    • addEntry

      private void addEntry(SortedMap<SortableLocation,JavaDocData> map, SortableLocation key, com.thoughtworks.qdox.model.JavaAnnotatedElement value)