use of com.sun.tools.xjc.reader.RawTypeSet in project jaxb-ri by eclipse-ee4j.
the class MixedExtendedComplexTypeBuilder method build.
@Override
public void build(XSComplexType ct) {
XSComplexType baseType = ct.getBaseType().asComplexType();
// build the base class
CClass baseClass = selector.bindToType(baseType, ct, true);
// global complex type must map to a class
assert baseClass != null;
if (!checkIfExtensionSafe(baseType, ct)) {
// error. We can't handle any further extension
errorReceiver.error(ct.getLocator(), Messages.ERR_NO_FURTHER_EXTENSION.format(baseType.getName(), ct.getName()));
return;
}
selector.getCurrentBean().setBaseClass(baseClass);
builder.recordBindingMode(ct, ComplexTypeBindingMode.FALLBACK_EXTENSION);
BIProperty prop = BIProperty.getCustomization(ct);
CPropertyInfo p;
RawTypeSet ts = RawTypeSetBuilder.build(ct.getContentType().asParticle(), false);
p = prop.createDummyExtendedMixedReferenceProperty("contentOverrideFor" + ct.getName(), ct, ts);
selector.getCurrentBean().addProperty(p);
// adds attributes and we are through.
green.attContainer(ct);
}
use of com.sun.tools.xjc.reader.RawTypeSet in project jaxb-ri by eclipse-ee4j.
the class MixedComplexTypeBuilder method build.
@Override
public void build(XSComplexType ct) {
XSContentType contentType = ct.getContentType();
boolean generateMixedExtensions = bgmBuilder.isGenerateMixedExtensions();
if (generateMixedExtensions) {
if (!(ct.getBaseType() == schemas.getAnyType() && ct.isMixed())) {
XSComplexType baseType = ct.getBaseType().asComplexType();
// build the base class
CClass baseClass = selector.bindToType(baseType, ct, true);
selector.getCurrentBean().setBaseClass(baseClass);
}
}
builder.recordBindingMode(ct, FALLBACK_CONTENT);
BIProperty prop = BIProperty.getCustomization(ct);
CPropertyInfo p;
if (generateMixedExtensions) {
List<XSComplexType> cType = ct.getSubtypes();
boolean isSubtyped = (cType != null) && (cType.size() > 0);
if (contentType.asEmpty() != null) {
if (isSubtyped) {
p = prop.createContentExtendedMixedReferenceProperty("Content", ct, null);
} else {
p = prop.createValueProperty("Content", false, ct, CBuiltinLeafInfo.STRING, null);
}
} else if (contentType.asParticle() == null) {
p = prop.createContentExtendedMixedReferenceProperty("Content", ct, null);
} else {
RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(), false);
p = prop.createContentExtendedMixedReferenceProperty("Content", ct, ts);
}
} else {
if (contentType.asEmpty() != null) {
p = prop.createValueProperty("Content", false, ct, CBuiltinLeafInfo.STRING, null);
} else {
RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(), false);
p = prop.createReferenceProperty("Content", false, ct, ts, true, false, true, false);
}
}
selector.getCurrentBean().addProperty(p);
// adds attributes and we are through.
green.attContainer(ct);
}
use of com.sun.tools.xjc.reader.RawTypeSet in project jaxb-ri by eclipse-ee4j.
the class ExpressionParticleBinder method buildProperty.
/**
* Builds a property ouf ot a connected component.
*/
private void buildProperty(ConnectedComponent cc) {
// property name
StringBuilder propName = new StringBuilder();
// combine only up to 3
int nameTokenCount = 0;
RawTypeSetBuilder rtsb = new RawTypeSetBuilder();
for (Element e : cc) {
GElement ge = (GElement) e;
if (nameTokenCount < 3) {
if (nameTokenCount != 0)
propName.append("And");
propName.append(makeJavaName(cc.isCollection(), ge.getPropertyNameSeed()));
nameTokenCount++;
}
if (e instanceof GElementImpl) {
GElementImpl ei = (GElementImpl) e;
rtsb.elementDecl(ei.decl);
continue;
}
if (e instanceof GWildcardElement) {
GWildcardElement w = (GWildcardElement) e;
rtsb.getRefs().add(new RawTypeSetBuilder.WildcardRef(w.isStrict() ? WildcardMode.STRICT : WildcardMode.SKIP));
continue;
}
// no other kind should be here
assert false : e;
}
Multiplicity m = Multiplicity.ONE;
if (cc.isCollection())
m = m.makeRepeated();
if (!cc.isRequired())
m = m.makeOptional();
RawTypeSet rts = new RawTypeSet(rtsb.getRefs(), m);
XSParticle p = findSourceParticle(cc);
BIProperty cust = BIProperty.getCustomization(p);
CPropertyInfo prop = cust.createElementOrReferenceProperty(propName.toString(), false, p, rts);
getCurrentBean().addProperty(prop);
}
use of com.sun.tools.xjc.reader.RawTypeSet in project jaxb-ri by eclipse-ee4j.
the class RawTypeSetBuilder method build.
/**
* @param optional
* if this whole property is optional due to the
* occurrence constraints on ancestors, set this to true.
* this will prevent the primitive types to be generated.
*/
public static RawTypeSet build(XSParticle p, boolean optional) {
RawTypeSetBuilder rtsb = new RawTypeSetBuilder();
rtsb.particle(p);
Multiplicity mul = MultiplicityCounter.theInstance.particle(p);
if (optional)
mul = mul.makeOptional();
return new RawTypeSet(rtsb.refs, mul);
}
use of com.sun.tools.xjc.reader.RawTypeSet in project jaxb-ri by eclipse-ee4j.
the class ContentModelBinder method onRepeated.
private Void onRepeated(DPattern p, boolean optional) {
RawTypeSet rts = RawTypeSetBuilder.build(compiler, p, optional ? Multiplicity.STAR : Multiplicity.PLUS);
if (rts.canBeTypeRefs == RawTypeSet.Mode.SHOULD_BE_TYPEREF) {
CElementPropertyInfo prop = new CElementPropertyInfo(calcName(p), REPEATED_ELEMENT, ID.NONE, null, null, null, p.getLocation(), !optional);
rts.addTo(prop);
clazz.addProperty(prop);
} else {
CReferencePropertyInfo prop = new CReferencePropertyInfo(calcName(p), true, !optional, false, /*TODO*/
null, null, p.getLocation(), false, false, false);
rts.addTo(prop);
clazz.addProperty(prop);
}
return null;
}
Aggregations