private FieldRenderer calcFr(Model m) { FieldRendererFactory frf = m.options.getFieldRendererFactory(); if (collectionType==null) return frf.getDefault(); if (collectionType.equals("indexed")) return frf.getArray(); return frf.getList(m.codeModel.ref(collectionType)); } }
public static FieldOutline createAttributeField( ClassOutlineImpl classOutline, String name, final QName attName, final CTypeInfo typeInfo, final boolean required // , // final XSDatatype datatype, // final JType type ) { final CPropertyInfo propertyInfo = new CAttributePropertyInfo(name, null, new CCustomizations(), null, attName, typeInfo, required); propertyInfo.realization = new FieldRendererFactory().getDefault(); final FieldOutline fieldOutline = propertyInfo.realization.generate(classOutline, propertyInfo); return fieldOutline; } //
/** * 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)); // the correctness of the attribute value must be // checked by the validator. throw new InternalError("unexpected collection value: "+v); }
CReferencePropertyInfo p = (CReferencePropertyInfo)prop; if (p.isDummy()) { return frf.getDummyList(outline.parent().getCodeModel().ref(ArrayList.class)); return frf.getContentList(outline.parent().getCodeModel().ref(ArrayList.class).narrow(Serializable.class)); return frf.getRequiredUnboxed(); else return frf.getSingle(); return frf.getList(outline.parent().getCodeModel().ref(ArrayList.class));
r = frf.getRequiredUnboxed(); break; case WRAPPER: r = prop.isOptionalPrimitive() ? frf.getSingle() : frf.getDefault(); break; case ISSET: r = prop.isOptionalPrimitive() ? frf.getSinglePrimitiveAccess() : frf.getDefault(); break; default:
/** * Determines the FieldRenderer used for the given FieldUse, * then generates the field declaration and accessor methods. * * The <code>fields</code> map will be updated with the newly * created FieldRenderer. */ private FieldOutline generateFieldDecl( ClassOutlineImpl cc, CPropertyInfo prop ) { FieldRenderer fr = prop.realization; if(fr==null) // none is specified. use the default factory fr = model.options.getFieldRendererFactory().getDefault(); FieldOutline field = fr.generate(cc, prop); fields.put(prop,field); return field; }
/** * 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); }
CReferencePropertyInfo p = (CReferencePropertyInfo)prop; if (p.isDummy()) { return frf.getDummyList(outline.parent().getCodeModel().ref(ArrayList.class)); return frf.getContentList(outline.parent().getCodeModel().ref(ArrayList.class).narrow(Serializable.class)); return frf.getRequiredUnboxed(); else return frf.getSingle(); return frf.getList(outline.parent().getCodeModel().ref(ArrayList.class));
r = frf.getRequiredUnboxed(); break; case WRAPPER: r = prop.isOptionalPrimitive() ? frf.getSingle() : frf.getDefault(); break; case ISSET: r = prop.isOptionalPrimitive() ? frf.getSinglePrimitiveAccess() : frf.getDefault(); break; default:
/** * 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)); // the correctness of the attribute value must be // checked by the validator. throw new InternalError("unexpected collection value: "+v); }
/** * Determines the FieldRenderer used for the given FieldUse, * then generates the field declaration and accessor methods. * * The <code>fields</code> map will be updated with the newly * created FieldRenderer. */ private FieldOutline generateFieldDecl( ClassOutlineImpl cc, CPropertyInfo prop ) { FieldRenderer fr = prop.realization; if(fr==null) // none is specified. use the default factory fr = model.options.getFieldRendererFactory().getDefault(); FieldOutline field = fr.generate(cc, prop); fields.put(prop,field); return field; }
/** * 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); }
CReferencePropertyInfo p = (CReferencePropertyInfo)prop; if (p.isDummy()) { return frf.getDummyList(outline.parent().getCodeModel().ref(ArrayList.class)); return frf.getContentList(outline.parent().getCodeModel().ref(ArrayList.class).narrow(Serializable.class)); return frf.getRequiredUnboxed(); else return frf.getSingle(); return frf.getList(outline.parent().getCodeModel().ref(ArrayList.class));
r = frf.getRequiredUnboxed(); break; case WRAPPER: r = prop.isOptionalPrimitive() ? frf.getSingle() : frf.getDefault(); break; case ISSET: r = prop.isOptionalPrimitive() ? frf.getSinglePrimitiveAccess() : frf.getDefault(); break; default:
private FieldRenderer calcFr(Model m) { FieldRendererFactory frf = m.options.getFieldRendererFactory(); if (collectionType==null) return frf.getDefault(); if (collectionType.equals("indexed")) return frf.getArray(); return frf.getList(m.codeModel.ref(collectionType)); } }
/** * 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)); // the correctness of the attribute value must be // checked by the validator. throw new InternalError("unexpected collection value: "+v); }
public static FieldOutline createAttributeField( ClassOutlineImpl classOutline, String name, final QName attName, final CNonElement typeInfo, final boolean required // , // final XSDatatype datatype, // final JType type ) { final CPropertyInfo propertyInfo = new CAttributePropertyInfo( // name name, // source null, new CCustomizations(), // locator null, // attName attName, // typeUse typeInfo, // typeName typeInfo.getTypeName(), // required required); propertyInfo.realization = new FieldRendererFactory().getDefault(); final FieldOutline fieldOutline = propertyInfo.realization.generate(classOutline, propertyInfo); return fieldOutline; }
/** * Determines the FieldRenderer used for the given FieldUse, * then generates the field declaration and accessor methods. * * The <code>fields</code> map will be updated with the newly * created FieldRenderer. */ private FieldOutline generateFieldDecl(ClassOutlineImpl cc, CPropertyInfo prop) { FieldRenderer fr = prop.realization; if (fr == null) // none is specified. use the default factory { fr = model.options.getFieldRendererFactory().getDefault(); } FieldOutline field = fr.generate(cc, prop); fields.put(prop, field); return field; }
prop.realization = builder.fieldRendererFactory.getConst(prop.realization); } else if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
CReferencePropertyInfo p = (CReferencePropertyInfo)prop; if (p.isDummy()) { return frf.getDummyList(outline.parent().getCodeModel().ref(ArrayList.class)); return frf.getContentList(outline.parent().getCodeModel().ref(ArrayList.class).narrow(Serializable.class)); return frf.getRequiredUnboxed(); else return frf.getSingle(); return frf.getList(outline.parent().getCodeModel().ref(ArrayList.class));