Search in sources :

Example 1 with XmlElementRefWriter

use of com.sun.tools.xjc.generator.annotation.spec.XmlElementRefWriter in project jaxb-ri by eclipse-ee4j.

the class AbstractField method annotateReference.

private void annotateReference(JAnnotatable field) {
    CReferencePropertyInfo rp = (CReferencePropertyInfo) prop;
    TODO.prototype();
    // this is just a quick hack to get the basic test working
    Collection<CElement> elements = rp.getElements();
    XmlElementRefWriter refw;
    if (elements.size() == 1) {
        refw = field.annotate2(XmlElementRefWriter.class);
        CElement e = elements.iterator().next();
        refw.name(e.getElementName().getLocalPart()).namespace(e.getElementName().getNamespaceURI()).type(e.getType().toType(outline.parent(), IMPLEMENTATION));
        refw.required(rp.isRequired());
    } else if (elements.size() > 1) {
        XmlElementRefsWriter refsw = field.annotate2(XmlElementRefsWriter.class);
        for (CElement e : elements) {
            refw = refsw.value();
            refw.name(e.getElementName().getLocalPart()).namespace(e.getElementName().getNamespaceURI()).type(e.getType().toType(outline.parent(), IMPLEMENTATION));
            refw.required(rp.isRequired());
        }
    }
    if (rp.isMixed())
        field.annotate(XmlMixed.class);
    NClass dh = rp.getDOMHandler();
    if (dh != null) {
        XmlAnyElementWriter xaew = field.annotate2(XmlAnyElementWriter.class);
        xaew.lax(rp.getWildcard().allowTypedObject);
        final JClass value = dh.toType(outline.parent(), IMPLEMENTATION);
        if (!value.equals(codeModel.ref(W3CDomHandler.class))) {
            xaew.value(value);
        }
    }
}
Also used : XmlElementRefsWriter(com.sun.tools.xjc.generator.annotation.spec.XmlElementRefsWriter) CElement(com.sun.tools.xjc.model.CElement) XmlElementRefWriter(com.sun.tools.xjc.generator.annotation.spec.XmlElementRefWriter) NClass(com.sun.tools.xjc.model.nav.NClass) JClass(com.sun.codemodel.JClass) XmlAnyElementWriter(com.sun.tools.xjc.generator.annotation.spec.XmlAnyElementWriter) CReferencePropertyInfo(com.sun.tools.xjc.model.CReferencePropertyInfo) XmlMixed(jakarta.xml.bind.annotation.XmlMixed)

Aggregations

JClass (com.sun.codemodel.JClass)1 XmlAnyElementWriter (com.sun.tools.xjc.generator.annotation.spec.XmlAnyElementWriter)1 XmlElementRefWriter (com.sun.tools.xjc.generator.annotation.spec.XmlElementRefWriter)1 XmlElementRefsWriter (com.sun.tools.xjc.generator.annotation.spec.XmlElementRefsWriter)1 CElement (com.sun.tools.xjc.model.CElement)1 CReferencePropertyInfo (com.sun.tools.xjc.model.CReferencePropertyInfo)1 NClass (com.sun.tools.xjc.model.nav.NClass)1 XmlMixed (jakarta.xml.bind.annotation.XmlMixed)1