Search in sources :

Example 6 with CElement

use of com.sun.tools.xjc.model.CElement in project jaxb-ri by eclipse-ee4j.

the class AbstractMappingImpl method buildDrilldown.

/**
 * Derived classes can use this method to implement {@link #calcDrilldown}.
 */
protected List<Property> buildDrilldown(CClassInfo typeBean) {
    // they must not contain xsd:choice
    if (containingChoice(typeBean)) {
        return null;
    }
    List<Property> result;
    CClassInfo bc = typeBean.getBaseClass();
    if (bc != null) {
        result = buildDrilldown(bc);
        if (result == null) {
            // aborted
            return null;
        }
    } else {
        result = new ArrayList<>();
    }
    for (CPropertyInfo p : typeBean.getProperties()) {
        if (p instanceof CElementPropertyInfo) {
            CElementPropertyInfo ep = (CElementPropertyInfo) p;
            // wrong. A+,B,C is eligible for drill-down.
            // if(ep.isCollection())
            // // content model like A+,B,C is not eligible
            // return null;
            List<? extends CTypeRef> ref = ep.getTypes();
            if (ref.size() != 1) {
                // content model like (A|B),C is not eligible
                return null;
            }
            result.add(createPropertyImpl(ep, ref.get(0).getTagName()));
        } else if (p instanceof ReferencePropertyInfo) {
            CReferencePropertyInfo rp = (CReferencePropertyInfo) p;
            Collection<CElement> elements = rp.getElements();
            if (elements.size() != 1) {
                return null;
            }
            CElement ref = elements.iterator().next();
            if (ref instanceof ClassInfo) {
                result.add(createPropertyImpl(rp, ref.getElementName()));
            } else {
                CElementInfo eref = (CElementInfo) ref;
                if (!eref.getSubstitutionMembers().isEmpty()) {
                    // elements with a substitution group isn't qualified for the wrapper style
                    return null;
                }
                // JAX-WS doesn't want to see JAXBElement, so we have to hide it for them.
                ElementAdapter fr;
                if (rp.isCollection()) {
                    fr = new ElementCollectionAdapter(parent.outline.getField(rp), eref);
                } else {
                    fr = new ElementSingleAdapter(parent.outline.getField(rp), eref);
                }
                result.add(new PropertyImpl(this, fr, eref.getElementName()));
            }
        } else {
            // according to the JAX-RPC spec 2.3.1.2, element refs are disallowed
            return null;
        }
    }
    return result;
}
Also used : CElementInfo(com.sun.tools.xjc.model.CElementInfo) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo) CClassInfo(com.sun.tools.xjc.model.CClassInfo) CElementPropertyInfo(com.sun.tools.xjc.model.CElementPropertyInfo) CElement(com.sun.tools.xjc.model.CElement) CReferencePropertyInfo(com.sun.tools.xjc.model.CReferencePropertyInfo) ReferencePropertyInfo(org.glassfish.jaxb.core.v2.model.core.ReferencePropertyInfo) Collection(java.util.Collection) CReferencePropertyInfo(com.sun.tools.xjc.model.CReferencePropertyInfo) Property(com.sun.tools.xjc.api.Property) CClassInfo(com.sun.tools.xjc.model.CClassInfo) ClassInfo(org.glassfish.jaxb.core.v2.model.core.ClassInfo)

Aggregations

CElement (com.sun.tools.xjc.model.CElement)6 CClassInfo (com.sun.tools.xjc.model.CClassInfo)5 CElementInfo (com.sun.tools.xjc.model.CElementInfo)3 CReferencePropertyInfo (com.sun.tools.xjc.model.CReferencePropertyInfo)3 JPackage (com.sun.codemodel.JPackage)2 CElementPropertyInfo (com.sun.tools.xjc.model.CElementPropertyInfo)2 CPropertyInfo (com.sun.tools.xjc.model.CPropertyInfo)2 BISchemaBinding (com.sun.tools.xjc.reader.xmlschema.bindinfo.BISchemaBinding)2 XSElementDecl (com.sun.xml.xsom.XSElementDecl)2 QName (javax.xml.namespace.QName)2 JClass (com.sun.codemodel.JClass)1 Property (com.sun.tools.xjc.api.Property)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 XmlSchemaWriter (com.sun.tools.xjc.generator.annotation.spec.XmlSchemaWriter)1 CAttributePropertyInfo (com.sun.tools.xjc.model.CAttributePropertyInfo)1 CClassInfoParent (com.sun.tools.xjc.model.CClassInfoParent)1 CCustomizations (com.sun.tools.xjc.model.CCustomizations)1 CPropertyVisitor (com.sun.tools.xjc.model.CPropertyVisitor)1