Class XsdAnnotationProcessor
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.XsdAnnotationProcessor
-
- All Implemented Interfaces:
NodeProcessor
public class XsdAnnotationProcessor extends Object implements 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
- Author:
- Lennart Jörelid, jGuru Europe AB
- See Also:
JavaDocRenderer
-
-
Constructor Summary
Constructors Constructor Description XsdAnnotationProcessor(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(Node aNode)
Defines if this visitor should process the provided node.void
process(Node aNode)
Processes the provided DOM Node.
-
-
-
Constructor Detail
-
XsdAnnotationProcessor
public XsdAnnotationProcessor(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.- 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 Detail
-
accept
public boolean accept(Node aNode)
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
public void process(Node aNode)
Processes the provided DOM Node.- Specified by:
process
in interfaceNodeProcessor
- Parameters:
aNode
- The DOM Node to process.
-
-