use of com.sun.tools.xjc.generator.bean.field.FieldRendererFactory in project jaxb-ri by eclipse-ee4j.
the class BIAttribute method getRealization.
/**
* Gets the realization of this particle, if any.
*
* @return
* null if the "collection" attribute was not specified.
*/
public final FieldRenderer getRealization() {
Attr a = element.getAttributeNode("collection");
if (a == null)
return null;
String v = element.getAttribute("collection").trim();
FieldRendererFactory frf = parent.parent.model.options.getFieldRendererFactory();
if (v.equals("array"))
return frf.getArray();
if (v.equals("list"))
return frf.getList(parent.parent.codeModel.ref(ArrayList.class));
// checked by the validator.
throw new InternalError("unexpected collection value: " + v);
}
use of com.sun.tools.xjc.generator.bean.field.FieldRendererFactory in project jaxb-ri by eclipse-ee4j.
the class BIProperty method wrapUp.
/**
* Common finalization of {@link CPropertyInfo} for the create***Property methods.
*/
private <T extends CPropertyInfo> T wrapUp(T prop, XSComponent source) {
prop.javadoc = concat(javadoc, getBuilder().getBindInfo(source).getDocumentation());
if (prop.javadoc == null)
prop.javadoc = "";
// decide the realization.
FieldRenderer r;
OptionalPropertyMode opm = getOptionalPropertyMode();
if (prop.isCollection()) {
CollectionTypeAttribute ct = getCollectionType();
r = ct.get(getBuilder().model);
} else {
FieldRendererFactory frf = getBuilder().fieldRendererFactory;
// according to the spec we should bahave as in jaxb1. So we ignore possiblity that property could be nullable
switch(opm) {
// the property type can be primitive type if we are to ignore absence
case PRIMITIVE:
r = frf.getRequiredUnboxed();
break;
case WRAPPER:
// force the wrapper type
r = prop.isOptionalPrimitive() ? frf.getSingle() : frf.getDefault();
break;
case ISSET:
r = prop.isOptionalPrimitive() ? frf.getSinglePrimitiveAccess() : frf.getDefault();
break;
default:
throw new Error();
}
}
if (opm == OptionalPropertyMode.ISSET) {
// only isSet is allowed on a collection. these 3 modes aren't really symmetric.
// if the property is a primitive type, we need an explicit unset because
// we can't overload the meaning of set(null).
// if it's a collection, we need to be able to unset it so that we can distinguish
// null list and empty list.
r = new IsSetFieldRenderer(r, prop.isOptionalPrimitive() || prop.isCollection(), true);
}
prop.realization = r;
JType bt = getBaseType();
if (bt != null)
prop.baseType = bt;
return prop;
}
Aggregations