Class XsdEnumerationAnnotationProcessor
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.XsdEnumerationAnnotationProcessor
-
- All Implemented Interfaces:
NodeProcessor
public class XsdEnumerationAnnotationProcessor extends Object implements NodeProcessor
Node processor that injects XSD documentation annotations consisting of JavaDoc harvested Java source code into SimpleTypes, Elements and Attributes typically produced by SchemaGen when generate XSDs for Java Enumerations. The documentation is injected as follows:
- SimpleType: Class-level JavaDoc from the corresponding type is injected as an annotation directly inside the SimpleType.
- 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:simpleType name="foodPreference"> <xs:restriction base="xs:string"> <xs:enumeration value="NONE"/> <xs:enumeration value="VEGAN"/> <xs:enumeration value="LACTO_VEGETARIAN"/> </xs:restriction> </xs:simpleType>
... will be converted in a manner similar to the one below:
<xs:simpleType name="foodPreference"> <xs:annotation> <xs:documentation><![CDATA[Simple enumeration example defining some Food preferences.]]></xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="LACTO_VEGETARIAN"> <xs:annotation> <xs:documentation><![CDATA[Vegetarian who will not eat meats, but drinks milk.]]></xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="NONE"> <xs:annotation> <xs:documentation><![CDATA[No special food preferences; eats everything.]]></xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="VEGAN"> <xs:annotation> <xs:documentation><![CDATA[Vegan who will neither eat meats nor drink milk.]]></xs:documentation> </xs:annotation> </xs:enumeration> </xs:restriction> </xs:simpleType>
... given that the Java class
FoodPreference
has JavaDoc on its class and fields corresponding to the injected XSD annotation/documentation elements.- Author:
- Lennart Jörelid, jGuru Europe AB
-
-
Constructor Summary
Constructors Constructor Description XsdEnumerationAnnotationProcessor(SearchableDocumentation docs, JavaDocRenderer renderer)
Creates an XsdEnumerationAnnotationProcessor 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)
Only accept simpleTypes which are restrictions to eitherxs:string
orxs:integer
.void
process(Node aNode)
Processes the provided DOM Node.
-
-
-
Constructor Detail
-
XsdEnumerationAnnotationProcessor
public XsdEnumerationAnnotationProcessor(SearchableDocumentation docs, JavaDocRenderer renderer)
Creates an XsdEnumerationAnnotationProcessor 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)
Only accept simpleTypes which are restrictions to either
Defines if this visitor should process the provided node.xs:string
orxs:integer
. The former is generated by JAXB when the Java Enum uses String values, and the latter is used for ordinal values.- 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.
-
-