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;
}
Aggregations