Search in sources :

Example 1 with Element

use of com.sun.tools.xjc.reader.gbind.Element 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)

Aggregations

CPropertyInfo (com.sun.tools.xjc.model.CPropertyInfo)1 Multiplicity (com.sun.tools.xjc.model.Multiplicity)1 RawTypeSet (com.sun.tools.xjc.reader.RawTypeSet)1 Element (com.sun.tools.xjc.reader.gbind.Element)1 BIProperty (com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty)1 XSParticle (com.sun.xml.xsom.XSParticle)1