Search in sources :

Example 1 with BIProperty

use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty 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 BIProperty

use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty 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 BIProperty

use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty in project jaxb-ri by eclipse-ee4j.

the class ColorBinder method createSimpleTypeProperty.

protected final void createSimpleTypeProperty(XSSimpleType type, String propName) {
    BIProperty prop = BIProperty.getCustomization(type);
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);
    // since we are building the simple type here, use buildDef
    CPropertyInfo p = prop.createValueProperty(propName, false, type, stb.buildDef(type), BGMBuilder.getName(type));
    getCurrentBean().addProperty(p);
}
Also used : BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo)

Example 4 with BIProperty

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

Example 5 with BIProperty

use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty in project jaxb-ri by eclipse-ee4j.

the class ParticleBinder method computeLabel.

/**
 * Computes the label of a given particle.
 * Usually, the getLabel method should be used instead.
 */
protected final String computeLabel(XSParticle p) {
    // if the particle carries a customization, use that value.
    // since we are binding content models, it's always non-constant properties.
    BIProperty cust = getLocalPropCustomization(p);
    if (cust != null && cust.getPropertyName(false) != null)
        return cust.getPropertyName(false);
    // no explicit property name is given. Compute one.
    XSTerm t = p.getTerm();
    // if it fails, compute the default name according to the spec.
    if (t.isElementDecl())
        // for element, take the element name.
        return makeJavaName(p, t.asElementDecl().getName());
    if (t.isModelGroupDecl())
        // for named model groups, take that name
        return makeJavaName(p, t.asModelGroupDecl().getName());
    if (t.isWildcard())
        // the spec says it will map to "any" by default.
        return makeJavaName(p, "Any");
    if (t.isModelGroup()) {
        try {
            return getSpecDefaultName(t.asModelGroup(), p.isRepeated());
        } catch (ParseException e) {
            // unable to generate a name.
            getErrorReporter().error(t.getLocator(), Messages.ERR_UNABLE_TO_GENERATE_NAME_FROM_MODELGROUP);
            // recover from error by assuming something
            return "undefined";
        }
    }
    // there are only four types of XSTerm.
    throw new AssertionError();
}
Also used : XSTerm(com.sun.xml.xsom.XSTerm) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) ParseException(java.text.ParseException)

Aggregations

BIProperty (com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty)11 CPropertyInfo (com.sun.tools.xjc.model.CPropertyInfo)9 RawTypeSet (com.sun.tools.xjc.reader.RawTypeSet)5 CClass (com.sun.tools.xjc.model.CClass)3 TypeUse (com.sun.tools.xjc.model.TypeUse)3 XSComplexType (com.sun.xml.xsom.XSComplexType)3 XSContentType (com.sun.xml.xsom.XSContentType)3 XSParticle (com.sun.xml.xsom.XSParticle)3 XSSimpleType (com.sun.xml.xsom.XSSimpleType)2 XSTerm (com.sun.xml.xsom.XSTerm)2 Multiplicity (com.sun.tools.xjc.model.Multiplicity)1 Element (com.sun.tools.xjc.reader.gbind.Element)1 BindInfo (com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo)1 XSContentTypeVisitor (com.sun.xml.xsom.visitor.XSContentTypeVisitor)1 ParseException (java.text.ParseException)1