public CValuePropertyInfo createValueProperty(String defaultName,boolean forConstant, XSComponent source,TypeUse tu, QName typeName) { markAsAcknowledged(); constantPropertyErrorCheck(); String name = getPropertyName(forConstant); if(name==null) { name = defaultName; if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } CValuePropertyInfo prop = wrapUp(new CValuePropertyInfo(name, source, getCustomizations(source), source.getLocator(), tu, typeName), source); BIInlineBinaryData.handle(source, prop); return prop; }
/** * Gets the inherited value of the "fixedAttrToConstantProperty" customization. * * <p> * Note that returning true from this method doesn't necessarily mean * that a property needs to be mapped to a constant property. * It just means that it's mapped to a constant property * <b>if an attribute use carries a fixed value.</b> * * <p> * I don't like this semantics but that's what the spec implies. */ public boolean isConstantProperty() { if(isConstantProperty!=null) return isConstantProperty; BIProperty next = getDefault(); if(next!=null) return next.isConstantProperty(); // globalBinding always has true or false in this property, // so this can't happen throw new AssertionError(); }
public void setParent(BindInfo parent) { super.setParent(parent); // fill in the remaining default values if(enumBaseTypes==null) enumBaseTypes = Collections.singleton(new QName(WellKnownNamespace.XML_SCHEMA,"string")); this.defaultProperty = new BIProperty(getLocation(),null,null,null, collectionType, fixedAttributeAsConstantProperty, optionalProperty, generateElementProperty ); defaultProperty.setParent(parent); // don't forget to initialize the defaultProperty }
public CPropertyInfo createElementOrReferenceProperty( String defaultName, boolean forConstant, XSParticle source, RawTypeSet types) { boolean generateRef; switch(types.canBeTypeRefs) { case CAN_BE_TYPEREF: case SHOULD_BE_TYPEREF: // it's up to the use Boolean b = generateElementProperty(); if(b==null) // follow XJC recommendation generateRef = types.canBeTypeRefs== RawTypeSet.Mode.CAN_BE_TYPEREF; else // use the value user gave us generateRef = b; break; case MUST_BE_REFERENCE: generateRef = true; break; default: throw new AssertionError(); } if(generateRef) { return createReferenceProperty(defaultName,forConstant,source,types, false, false, false, false); } else { return createElementProperty(defaultName,forConstant,source,types); } }
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
prop.javadoc = concat(javadoc, getBuilder().getBindInfo(source).getDocumentation()); if(prop.javadoc==null) prop.javadoc=""; OptionalPropertyMode opm = getOptionalPropertyMode(); if(prop.isCollection()) { CollectionTypeAttribute ct = getCollectionType(); r = ct.get(getBuilder().model); } else { FieldRendererFactory frf = getBuilder().fieldRendererFactory; JType bt = getBaseType(); if(bt!=null) prop.baseType = bt;
BIProperty prop = BIProperty.getCustomization(ct); p = prop.createContentExtendedMixedReferenceProperty("Content", ct, null); } else { p = prop.createValueProperty("Content",false,ct,CBuiltinLeafInfo.STRING,null); p = prop.createContentExtendedMixedReferenceProperty("Content", ct, null); } else { RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(), false); p = prop.createContentExtendedMixedReferenceProperty("Content", ct, ts); 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);
/** * Attribute use always becomes a property. */ 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()) { // don't support a collection default value. That's difficult to do. 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()); } } getCurrentBean().addProperty(prop); }
BIGlobalBinding gb = getBuilder().getGlobalBinding(); NameConverter nc = getBuilder().model.getNameConverter(); return name; // ... or don't change the value BIProperty next = getDefault(); if(next!=null) return next.getPropertyName(forConstant); else return null;
public void particle( XSParticle p ) { XSTerm t = p.getTerm(); if(marked(p)) { BIProperty cust = BIProperty.getCustomization(p); CPropertyInfo prop = cust.createElementOrReferenceProperty( getLabel(p), false, p, RawTypeSetBuilder.build(p,insideOptionalParticle)); getCurrentBean().addProperty(prop); } else { // repeated model groups should have been marked already assert !p.isRepeated(); boolean oldIOP = insideOptionalParticle; insideOptionalParticle |= BigInteger.ZERO.equals(p.getMinOccurs()); // this is an unmarked particle t.visit(this); insideOptionalParticle = oldIOP; } }
public void build(XSComplexType ct) { XSComplexType baseType = ct.getBaseType().asComplexType(); // build the base class CClass baseClass = selector.bindToType(baseType, ct, true); assert baseClass != null; // global complex type must map to a class if (!checkIfExtensionSafe(baseType, ct)) { // error. We can't handle any further extension errorReceiver.error(ct.getLocator(), Messages.ERR_NO_FURTHER_EXTENSION.format( baseType.getName(), ct.getName() ) ); return; } selector.getCurrentBean().setBaseClass(baseClass); builder.recordBindingMode(ct, ComplexTypeBindingMode.FALLBACK_EXTENSION); BIProperty prop = BIProperty.getCustomization(ct); CPropertyInfo p; RawTypeSet ts = RawTypeSetBuilder.build(ct.getContentType().asParticle(), false); p = prop.createDummyExtendedMixedReferenceProperty("contentOverrideFor" + ct.getName(), ct, ts); selector.getCurrentBean().addProperty(p); // adds attributes and we are through. green.attContainer(ct); }
private String getCustomPropertyName(final XSComponent component) { if (component.getAnnotation() != null && (component.getAnnotation().getAnnotation() instanceof BindInfo)) { final BindInfo bindInfo = (BindInfo) component.getAnnotation().getAnnotation(); final BIProperty biProperty = bindInfo.get(BIProperty.class); if (biProperty != null) { final String customPropertyName = biProperty.getPropertyName(false); return customPropertyName != null ? customPropertyName : null; } } return null; } };
@Override public void postProcessModel(final Model model, final ErrorHandler errorHandler) { this.fixedAttributeAsConstantProperty = Ring.get(BGMBuilder.class).getGlobalBinding().getDefaultProperty().isConstantProperty(); }
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
prop.javadoc = concat(javadoc, getBuilder().getBindInfo(source).getDocumentation()); if(prop.javadoc==null) prop.javadoc=""; OptionalPropertyMode opm = getOptionalPropertyMode(); if(prop.isCollection()) { CollectionTypeAttribute ct = getCollectionType(); r = ct.get(getBuilder().model); } else { FieldRendererFactory frf = getBuilder().fieldRendererFactory; JType bt = getBaseType(); if(bt!=null) prop.baseType = bt;
BIProperty prop = BIProperty.getCustomization(ct); p = prop.createContentExtendedMixedReferenceProperty("Content", ct, null); } else { p = prop.createValueProperty("Content",false,ct,CBuiltinLeafInfo.STRING,null); p = prop.createContentExtendedMixedReferenceProperty("Content", ct, null); } else { RawTypeSet ts = RawTypeSetBuilder.build(contentType.asParticle(), false); p = prop.createContentExtendedMixedReferenceProperty("Content", ct, ts); 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);
/** * Attribute use always becomes a property. */ 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()) { // don't support a collection default value. That's difficult to do. 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()); } } getCurrentBean().addProperty(prop); }
BIGlobalBinding gb = getBuilder().getGlobalBinding(); NameConverter nc = getBuilder().model.getNameConverter(); return name; // ... or don't change the value BIProperty next = getDefault(); if(next!=null) return next.getPropertyName(forConstant); else return null;
public CPropertyInfo createElementOrReferenceProperty( String defaultName, boolean forConstant, XSParticle source, RawTypeSet types) { boolean generateRef; switch(types.canBeTypeRefs) { case CAN_BE_TYPEREF: case SHOULD_BE_TYPEREF: // it's up to the use Boolean b = generateElementProperty(); if(b==null) // follow XJC recommendation generateRef = types.canBeTypeRefs== RawTypeSet.Mode.CAN_BE_TYPEREF; else // use the value user gave us generateRef = b; break; case MUST_BE_REFERENCE: generateRef = true; break; default: throw new AssertionError(); } if(generateRef) { return createReferenceProperty(defaultName,forConstant,source,types, false, false, false, false); } else { return createElementProperty(defaultName,forConstant,source,types); } }
public void particle( XSParticle p ) { XSTerm t = p.getTerm(); if(marked(p)) { BIProperty cust = BIProperty.getCustomization(p); CPropertyInfo prop = cust.createElementOrReferenceProperty( getLabel(p), false, p, RawTypeSetBuilder.build(p,insideOptionalParticle)); getCurrentBean().addProperty(prop); } else { // repeated model groups should have been marked already assert !p.isRepeated(); boolean oldIOP = insideOptionalParticle; insideOptionalParticle |= BigInteger.ZERO.equals(p.getMinOccurs()); // this is an unmarked particle t.visit(this); insideOptionalParticle = oldIOP; } }