Search in sources :

Example 1 with CClass

use of com.sun.tools.xjc.model.CClass 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);
}
Also used : CClass(com.sun.tools.xjc.model.CClass) XSComplexType(com.sun.xml.xsom.XSComplexType) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo) RawTypeSet(com.sun.tools.xjc.reader.RawTypeSet)

Example 2 with CClass

use of com.sun.tools.xjc.model.CClass 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);
}
Also used : XSContentType(com.sun.xml.xsom.XSContentType) CClass(com.sun.tools.xjc.model.CClass) XSComplexType(com.sun.xml.xsom.XSComplexType) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo) RawTypeSet(com.sun.tools.xjc.reader.RawTypeSet)

Example 3 with CClass

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

the class RestrictedComplexTypeBuilder method build.

@Override
public void build(XSComplexType ct) {
    if (bgmBuilder.getGlobalBinding().isRestrictionFreshType()) {
        // handle derivation-by-restriction like a whole new type
        new FreshComplexTypeBuilder().build(ct);
        return;
    }
    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;
    selector.getCurrentBean().setBaseClass(baseClass);
    if (bgmBuilder.isGenerateMixedExtensions()) {
        boolean forceFallbackInExtension = baseType.isMixed() && ct.isMixed() && (ct.getExplicitContent() != null) && bgmBuilder.inExtensionMode;
        if (forceFallbackInExtension) {
            builder.recordBindingMode(ct, ComplexTypeBindingMode.NORMAL);
            BIProperty prop = BIProperty.getCustomization(ct);
            CPropertyInfo p;
            XSParticle particle = ct.getContentType().asParticle();
            if (particle != null) {
                RawTypeSet ts = RawTypeSetBuilder.build(particle, false);
                p = prop.createDummyExtendedMixedReferenceProperty("Content", ct, ts);
                selector.getCurrentBean().addProperty(p);
            }
        } else {
            // determine the binding of this complex type.
            builder.recordBindingMode(ct, builder.getBindingMode(baseType));
        }
    } else {
        builder.recordBindingMode(ct, builder.getBindingMode(baseType));
    }
}
Also used : CClass(com.sun.tools.xjc.model.CClass) XSParticle(com.sun.xml.xsom.XSParticle) XSComplexType(com.sun.xml.xsom.XSComplexType) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo) RawTypeSet(com.sun.tools.xjc.reader.RawTypeSet)

Example 4 with CClass

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

the class ExtendedComplexTypeBuilder 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;
    selector.getCurrentBean().setBaseClass(baseClass);
    // derivation by extension.
    ComplexTypeBindingMode baseTypeFlag = builder.getBindingMode(baseType);
    XSContentType explicitContent = ct.getExplicitContent();
    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;
    }
    // explicit content is always either empty or a particle.
    if (explicitContent != null && explicitContent.asParticle() != null) {
        if (baseTypeFlag == ComplexTypeBindingMode.NORMAL) {
            // if we have additional explicit content, process them.
            builder.recordBindingMode(ct, bgmBuilder.getParticleBinder().checkFallback(explicitContent.asParticle()) ? ComplexTypeBindingMode.FALLBACK_REST : ComplexTypeBindingMode.NORMAL);
            bgmBuilder.getParticleBinder().build(explicitContent.asParticle());
        } else {
            // the base class has already done the fallback.
            // don't add anything new
            builder.recordBindingMode(ct, baseTypeFlag);
        }
    } else {
        // if it's empty, no additional processing is necessary
        builder.recordBindingMode(ct, baseTypeFlag);
    }
    // adds attributes and we are through.
    green.attContainer(ct);
}
Also used : CClass(com.sun.tools.xjc.model.CClass) XSContentType(com.sun.xml.xsom.XSContentType) XSComplexType(com.sun.xml.xsom.XSComplexType)

Aggregations

CClass (com.sun.tools.xjc.model.CClass)4 XSComplexType (com.sun.xml.xsom.XSComplexType)4 CPropertyInfo (com.sun.tools.xjc.model.CPropertyInfo)3 RawTypeSet (com.sun.tools.xjc.reader.RawTypeSet)3 BIProperty (com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty)3 XSContentType (com.sun.xml.xsom.XSContentType)2 XSParticle (com.sun.xml.xsom.XSParticle)1