Search in sources :

Example 1 with ReferencePropertyInfo

use of org.glassfish.jaxb.core.v2.model.core.ReferencePropertyInfo 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

Property (com.sun.tools.xjc.api.Property)1 CClassInfo (com.sun.tools.xjc.model.CClassInfo)1 CElement (com.sun.tools.xjc.model.CElement)1 CElementInfo (com.sun.tools.xjc.model.CElementInfo)1 CElementPropertyInfo (com.sun.tools.xjc.model.CElementPropertyInfo)1 CPropertyInfo (com.sun.tools.xjc.model.CPropertyInfo)1 CReferencePropertyInfo (com.sun.tools.xjc.model.CReferencePropertyInfo)1 Collection (java.util.Collection)1 ClassInfo (org.glassfish.jaxb.core.v2.model.core.ClassInfo)1 ReferencePropertyInfo (org.glassfish.jaxb.core.v2.model.core.ReferencePropertyInfo)1