Class JavaDocExtractor
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.JavaDocExtractor
-
public class JavaDocExtractor extends java.lang.ObjectThe 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classJavaDocExtractor.ReadOnlySearchableDocumentationStandard read-only SearchableDocumentation implementation.
-
Field Summary
Fields Modifier and Type Field Description private com.thoughtworks.qdox.JavaProjectBuilderbuilderprivate static java.lang.StringDEFAULT_VALUEThe default value given as the return value from some annotation classes whenever the attribute has not been supplied within the codebase.private org.apache.maven.plugin.logging.Loglog
-
Constructor Summary
Constructors Constructor Description JavaDocExtractor(org.apache.maven.plugin.logging.Log log)Creates a JavaDocExtractor wrapping the supplied Maven Log.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddEntry(java.util.SortedMap<SortableLocation,JavaDocData> map, SortableLocation key, com.thoughtworks.qdox.model.JavaAnnotatedElement value)JavaDocExtractoraddSourceFiles(java.util.List<java.io.File> sourceCodeFiles)Adds the supplied sourceCodeFiles for processing by this JavaDocExtractor.JavaDocExtractoraddSourceURLs(java.util.List<java.net.URL> sourceCodeURLs)Adds the supplied sourceCodeFiles for processing by this JavaDocExtractor.private static java.lang.StringgetAnnotationAttributeValueFrom(java.lang.Class<?> annotationType, java.lang.String attributeName, java.util.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.private static booleanhasAnnotation(java.lang.Class<?> annotationType, java.util.List<com.thoughtworks.qdox.model.JavaAnnotation> annotations)SearchableDocumentationprocess()Processes all supplied Java source Files and URLs to extract JavaDocData for all ClassLocations from which JavaDoc has been collected.voidsetEncoding(java.lang.String encoding)Assigns the encoding of the underlyingJavaProjectBuilder.
-
-
-
Field Detail
-
DEFAULT_VALUE
private static final java.lang.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:
- Constant Field Values
-
builder
private com.thoughtworks.qdox.JavaProjectBuilder builder
-
log
private org.apache.maven.plugin.logging.Log log
-
-
Method Detail
-
setEncoding
public void setEncoding(java.lang.String encoding)
Assigns the encoding of the underlyingJavaProjectBuilder.- Parameters:
encoding- The non-empty encoding to be set into the underlyingJavaProjectBuilder.
-
addSourceFiles
public JavaDocExtractor addSourceFiles(java.util.List<java.io.File> sourceCodeFiles) throws java.lang.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:
java.lang.IllegalArgumentException- If any of the given sourceCodeFiles could not be read properly.
-
addSourceURLs
public JavaDocExtractor addSourceURLs(java.util.List<java.net.URL> sourceCodeURLs) throws java.lang.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:
java.lang.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 java.lang.String getAnnotationAttributeValueFrom(java.lang.Class<?> annotationType, java.lang.String attributeName, java.util.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 asXmlElement,XmlAttributeorXmlEnumValue.- Parameters:
annotations- The list of JavaAnnotations to filter from.annotationType- The type of annotation to read attribute values from.attributeName- The name of the attribute the value of which should be returned.- Returns:
- The first matching JavaAnnotation of type annotationType within the given annotations
List, or
nullif none was found. - Since:
- 2.2
-
hasAnnotation
private static boolean hasAnnotation(java.lang.Class<?> annotationType, java.util.List<com.thoughtworks.qdox.model.JavaAnnotation> annotations)
-
addEntry
private void addEntry(java.util.SortedMap<SortableLocation,JavaDocData> map, SortableLocation key, com.thoughtworks.qdox.model.JavaAnnotatedElement value)
-
-