Search in sources :

Example 1 with Multiplicity

use of com.sun.tools.xjc.model.Multiplicity 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 2 with Multiplicity

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

the class MultiplicityCounter method particle.

public Multiplicity particle(XSParticle p) {
    Multiplicity m = p.getTerm().apply(this);
    BigInteger max;
    if (m.max == null || (BigInteger.valueOf(XSParticle.UNBOUNDED).equals(p.getMaxOccurs())))
        max = null;
    else
        max = p.getMaxOccurs();
    return Multiplicity.multiply(m, Multiplicity.create(p.getMinOccurs(), max));
}
Also used : Multiplicity(com.sun.tools.xjc.model.Multiplicity) BigInteger(java.math.BigInteger)

Example 3 with Multiplicity

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

the class MultiplicityCounter method modelGroup.

@Override
public Multiplicity modelGroup(XSModelGroup group) {
    boolean isChoice = group.getCompositor() == XSModelGroup.CHOICE;
    Multiplicity r = ZERO;
    for (XSParticle p : group.getChildren()) {
        Multiplicity m = particle(p);
        if (r == null) {
            r = m;
            continue;
        }
        if (isChoice) {
            r = Multiplicity.choice(r, m);
        } else {
            r = Multiplicity.group(r, m);
        }
    }
    return r;
}
Also used : XSParticle(com.sun.xml.xsom.XSParticle) Multiplicity(com.sun.tools.xjc.model.Multiplicity)

Example 4 with Multiplicity

use of com.sun.tools.xjc.model.Multiplicity 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);
}
Also used : Multiplicity(com.sun.tools.xjc.model.Multiplicity) RawTypeSet(com.sun.tools.xjc.reader.RawTypeSet)

Aggregations

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