use of com.sun.tools.xjc.generator.annotation.spec.XmlSeeAlsoWriter in project jaxb-ri by eclipse-ee4j.
the class BeanGenerator method generateClassBody.
/**
* Generates the body of a class.
*/
private void generateClassBody(ClassOutlineImpl cc) {
CClassInfo target = cc.target;
// used to simplify the generated annotations
String mostUsedNamespaceURI = cc._package().getMostUsedNamespaceURI();
// [RESULT]
// @XmlType(name="foo", targetNamespace="bar://baz")
XmlTypeWriter xtw = cc.implClass.annotate2(XmlTypeWriter.class);
writeTypeName(cc.target.getTypeName(), xtw, mostUsedNamespaceURI);
// @XmlSeeAlso
Iterator<CClassInfo> subclasses = cc.target.listSubclasses();
if (subclasses.hasNext()) {
XmlSeeAlsoWriter saw = cc.implClass.annotate2(XmlSeeAlsoWriter.class);
while (subclasses.hasNext()) {
CClassInfo s = subclasses.next();
saw.value(getClazz(s).implRef);
}
}
if (target.isElement()) {
String namespaceURI = target.getElementName().getNamespaceURI();
String localPart = target.getElementName().getLocalPart();
// [RESULT]
// @XmlRootElement(name="foo", targetNamespace="bar://baz")
XmlRootElementWriter xrew = cc.implClass.annotate2(XmlRootElementWriter.class);
xrew.name(localPart);
if (// only generate if necessary
!namespaceURI.equals(mostUsedNamespaceURI)) {
xrew.namespace(namespaceURI);
}
}
if (target.isOrdered()) {
for (CPropertyInfo p : target.getProperties()) {
if (!(p instanceof CAttributePropertyInfo)) {
if (!((p instanceof CReferencePropertyInfo) && ((CReferencePropertyInfo) p).isDummy())) {
xtw.propOrder(p.getName(false));
}
}
}
} else {
// produce empty array
xtw.getAnnotationUse().paramArray("propOrder");
}
for (CPropertyInfo prop : target.getProperties()) {
generateFieldDecl(cc, prop);
}
if (target.declaresAttributeWildcard()) {
generateAttributeWildcard(cc);
}
// generate some class level javadoc
cc.ref.javadoc().append(target.javadoc);
cc._package().objectFactoryGenerator().populate(cc);
}
Aggregations