Hi
I am writing a code generator using jaxb xjc plugin.
I intend to use this plugin to
1)set annotations for class variable
<xs:element name="a" type="xs:integer">
<xs:annotation>
<xs:appinfo>
<Mytags:annotation>Attribute</Mytags:annotation>
</xs:appinfo>
</xs:annotation>
</xs:element>
2)implement many interfaces
3)etc etc
I have tried to implement 1) with the following code
for (final ClassOutline co : outline.getClasses())
{
//Get handle to JModel representing the field
final Map<String, JFieldVar> fields =
co.implClass.fields();
// check all Fields in Class
for (final FieldOutline f : co.getDeclaredFields())
{
final CPropertyInfo fieldInfo = f.getPropertyInfo();
final CPluginCustomization c1 =
fieldInfo.getCustomizations().find(ConstNS, "annotation");
if (c1 == null)
{
continue; // no customization --- nothing to do
here
}
//mark this as ack to avoid below error
/**
* [ERROR] compiler was unable to honor this
dcs:annotation
* customization.
* It is attached to a wrong place, or its inconsistent
with
* other bindings.
*/
c1.markAsAcknowledged();
final JFieldVar var =
fields.get(fieldInfo.getName(false));
System.out.println("======= " +
fieldInfo.getName(false));
System.out.println("-------" +
c1.element.getTagName());
//add the Annotation
var.annotate(MyAttributeAnnotation.class);
}
I wish to access the value Attribute in the tags
<Mytags:annotation>Attribute</Mytags:annotation>
can some obe pls help me with this.
Thanks
Su