use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty in project jaxb-ri by eclipse-ee4j.
the class BindPurple method attributeUse.
/**
* Attribute use always becomes a property.
*/
@Override
public void attributeUse(XSAttributeUse use) {
boolean hasFixedValue = use.getFixedValue() != null;
BIProperty pc = BIProperty.getCustomization(use);
// map to a constant property ?
boolean toConstant = pc.isConstantProperty() && hasFixedValue;
TypeUse attType = bindAttDecl(use.getDecl());
CPropertyInfo prop = pc.createAttributeProperty(use, attType);
if (toConstant) {
prop.defaultValue = CDefaultValue.create(attType, use.getFixedValue());
prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
} else if (!attType.isCollection() && (prop.baseType == null || !prop.baseType.isPrimitive())) {
if (use.getDefaultValue() != null) {
// this attribute use has a default value.
// the item type is guaranteed to be a leaf type... or TODO: is it really so?
// don't support default values if it's a list
prop.defaultValue = CDefaultValue.create(attType, use.getDefaultValue());
} else if (use.getFixedValue() != null) {
prop.defaultValue = CDefaultValue.create(attType, use.getFixedValue());
}
} else if (prop.baseType != null && prop.baseType.isPrimitive()) {
ErrorReporter errorReporter = Ring.get(ErrorReporter.class);
errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
}
getCurrentBean().addProperty(prop);
}
use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty in project jaxb-ri by eclipse-ee4j.
the class SimpleTypeBuilder method getRefererCustomization.
/**
* Returns a javaType customization specified to the referer, if present.
* @return can be null.
*/
private BIConversion getRefererCustomization() {
BindInfo info = builder.getBindInfo(getReferer());
BIProperty prop = info.get(BIProperty.class);
if (prop == null)
return null;
return prop.getConv();
}
use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty in project jaxb-ri by eclipse-ee4j.
the class MultiWildcardComplexTypeBuilder method build.
@Override
public void build(XSComplexType ct) {
XSContentType contentType = ct.getContentType();
builder.recordBindingMode(ct, FALLBACK_CONTENT);
BIProperty prop = BIProperty.getCustomization(ct);
CPropertyInfo p;
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);
}
use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty in project jaxb-ri by eclipse-ee4j.
the class RestrictedComplexTypeBuilder method build.
@Override
public void build(XSComplexType ct) {
if (bgmBuilder.getGlobalBinding().isRestrictionFreshType()) {
// handle derivation-by-restriction like a whole new type
new FreshComplexTypeBuilder().build(ct);
return;
}
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;
selector.getCurrentBean().setBaseClass(baseClass);
if (bgmBuilder.isGenerateMixedExtensions()) {
boolean forceFallbackInExtension = baseType.isMixed() && ct.isMixed() && (ct.getExplicitContent() != null) && bgmBuilder.inExtensionMode;
if (forceFallbackInExtension) {
builder.recordBindingMode(ct, ComplexTypeBindingMode.NORMAL);
BIProperty prop = BIProperty.getCustomization(ct);
CPropertyInfo p;
XSParticle particle = ct.getContentType().asParticle();
if (particle != null) {
RawTypeSet ts = RawTypeSetBuilder.build(particle, false);
p = prop.createDummyExtendedMixedReferenceProperty("Content", ct, ts);
selector.getCurrentBean().addProperty(p);
}
} else {
// determine the binding of this complex type.
builder.recordBindingMode(ct, builder.getBindingMode(baseType));
}
} else {
builder.recordBindingMode(ct, builder.getBindingMode(baseType));
}
}
use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty in project jaxb-ri by eclipse-ee4j.
the class STDerivedComplexTypeBuilder method build.
@Override
public void build(XSComplexType ct) {
assert ct.getDerivationMethod() == XSType.EXTENSION;
// base type is a simple type
XSSimpleType baseType = ct.getBaseType().asSimpleType();
// determine the binding of this complex type.
builder.recordBindingMode(ct, ComplexTypeBindingMode.NORMAL);
simpleTypeBuilder.refererStack.push(ct);
TypeUse use = simpleTypeBuilder.build(baseType);
simpleTypeBuilder.refererStack.pop();
BIProperty prop = BIProperty.getCustomization(ct);
CPropertyInfo p = prop.createValueProperty("Value", false, baseType, use, BGMBuilder.getName(baseType));
selector.getCurrentBean().addProperty(p);
// adds attributes and we are through.
green.attContainer(ct);
}
Aggregations