Class XsdAnnotationProcessor
java.lang.Object
org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.XsdAnnotationProcessor
- All Implemented Interfaces:
NodeProcessor
Node processor that injects XSD documentation annotations consisting of JavaDoc harvested Java source code into ComplexTypes, Elements and Attributes. The documentation is injected as follows:
- ComplexType: Class-level JavaDoc from the corresponding type is injected as an annotation directly inside the complexType.
- Element: Field-level JavaDoc (or getter Method-level JavaDoc, in case the Field does not contain a JavaDoc annotation) from the corresponding member is injected as an annotation directly inside the element.
- Attribute: Field-level JavaDoc (or getter Method-level JavaDoc, in case the Field does not contain a JavaDoc annotation) from the corresponding member is injected as an annotation directly inside the element.
Thus, the following 'vanilla'-generated XSD:
<xs:complexType name="somewhatNamedPerson">
<xs:sequence>
<xs:element name="firstName" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="lastName" type="xs:string"/>
</xs:sequence>
<xs:attribute name="age" type="xs:int" use="required"/>
</xs:complexType>
... would be converted to the following annotated XSD, given a DefaultJavaDocRenderer:
<xs:complexType name="somewhatNamedPerson">
<xs:annotation>
<xs:documentation><![CDATA[Definition of a person with lastName and age, and optionally a firstName as well...
(author): <a href="mailto:lj@jguru.se">Lennart Jörelid</a>, jGuru Europe AB
(custom): A custom JavaDoc annotation.]]></xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element minOccurs="0" name="firstName" nillable="true" type="xs:string">
<xs:annotation>
<xs:documentation><![CDATA[The first name of the SomewhatNamedPerson.]]></xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="lastName" type="xs:string">
<xs:annotation>
<xs:documentation><![CDATA[The last name of the SomewhatNamedPerson.]]></xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="age" type="xs:int" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The age of the SomewhatNamedPerson. Must be positive.]]></xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
... given that the Java class SomewhatNamedPerson
has JavaDoc on its class and fields
corresponding to the injected XSD annotation/documentation elements.
- Since:
- 2.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SortedMap
<ClassLocation, JavaDocData> private SortedMap
<FieldLocation, JavaDocData> private SortedMap
<MethodLocation, JavaDocData> private JavaDocRenderer
-
Constructor Summary
ConstructorsConstructorDescriptionXsdAnnotationProcessor
(SearchableDocumentation docs, JavaDocRenderer renderer) Creates an XsdAnnotationProcessor that uses the supplied/generated SearchableDocumentation to read all JavaDoc structures and the supplied JavaDocRenderer to render JavaDocs into XSD documentation annotations. -
Method Summary
-
Field Details
-
classJavaDocs
-
fieldJavaDocs
-
methodJavaDocs
-
renderer
-
-
Constructor Details
-
XsdAnnotationProcessor
Creates an XsdAnnotationProcessor that uses the supplied/generated SearchableDocumentation to read all JavaDoc structures and the supplied JavaDocRenderer to render JavaDocs into XSD documentation annotations.- Parameters:
docs
- A non-null SearchableDocumentation, produced from the source code of the JAXB compilation unit.renderer
- A non-null JavaDocRenderer, used to render the JavaDocData within the SearchableDocumentation.
-
-
Method Details
-
accept
Defines if this visitor should process the provided node.- Specified by:
accept
in interfaceNodeProcessor
- Parameters:
aNode
- The DOM node to process.- Returns:
true
if the provided Node should be processed by this NodeProcessor.
-
process
Processes the provided DOM Node.- Specified by:
process
in interfaceNodeProcessor
- Parameters:
aNode
- The DOM Node to process.
-