Search in sources :

Example 6 with BIProperty

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);
}
Also used : TypeUse(com.sun.tools.xjc.model.TypeUse) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo)

Example 7 with BIProperty

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();
}
Also used : BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) BindInfo(com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo)

Example 8 with BIProperty

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);
}
Also used : XSContentType(com.sun.xml.xsom.XSContentType) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo) RawTypeSet(com.sun.tools.xjc.reader.RawTypeSet)

Example 9 with BIProperty

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));
    }
}
Also used : CClass(com.sun.tools.xjc.model.CClass) XSParticle(com.sun.xml.xsom.XSParticle) XSComplexType(com.sun.xml.xsom.XSComplexType) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo) RawTypeSet(com.sun.tools.xjc.reader.RawTypeSet)

Example 10 with BIProperty

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);
}
Also used : TypeUse(com.sun.tools.xjc.model.TypeUse) XSSimpleType(com.sun.xml.xsom.XSSimpleType) BIProperty(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty) CPropertyInfo(com.sun.tools.xjc.model.CPropertyInfo)

Aggregations

BIProperty (com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty)11 CPropertyInfo (com.sun.tools.xjc.model.CPropertyInfo)9 RawTypeSet (com.sun.tools.xjc.reader.RawTypeSet)5 CClass (com.sun.tools.xjc.model.CClass)3 TypeUse (com.sun.tools.xjc.model.TypeUse)3 XSComplexType (com.sun.xml.xsom.XSComplexType)3 XSContentType (com.sun.xml.xsom.XSContentType)3 XSParticle (com.sun.xml.xsom.XSParticle)3 XSSimpleType (com.sun.xml.xsom.XSSimpleType)2 XSTerm (com.sun.xml.xsom.XSTerm)2 Multiplicity (com.sun.tools.xjc.model.Multiplicity)1 Element (com.sun.tools.xjc.reader.gbind.Element)1 BindInfo (com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo)1 XSContentTypeVisitor (com.sun.xml.xsom.visitor.XSContentTypeVisitor)1 ParseException (java.text.ParseException)1