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);
}
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));
}
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;
}
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);
}
Aggregations