private static BIProperty getDefault( BGMBuilder builder, XSComponent c ) { while(c!=null) { c = c.apply(defaultCustomizationFinder); if(c!=null) { BIProperty prop = builder.getBindInfo(c).get(BIProperty.class); if(prop!=null) return prop; } } // default to the global one return builder.getGlobalBinding().getDefaultProperty(); }
/** * Gets the BindInfo object associated to a schema component. * * @return * always return a valid {@link BindInfo} object. If none * is specified for the given component, a dummy empty BindInfo * will be returned. */ public BindInfo getBindInfo( XSComponent schemaComponent ) { BindInfo bi = _getBindInfoReadOnly(schemaComponent); if(bi!=null) return bi; else return emptyBindInfo; }
/** * Annotates the obtained schema set. * * @return * null if an error happens. In that case, the error messages * will be properly reported to the controller by this method. */ public Model annotateXMLSchema(XSSchemaSet xs) { if (xs == null) return null; return BGMBuilder.build(xs, codeModel, errorReceiver, opt); }
/** Converts an XML name to the corresponding Java name. */ protected final String makeJavaName( boolean isRepeated, String xmlName ) { String name = builder.getNameConverter().toPropertyName(xmlName); if(builder.getGlobalBinding().isSimpleMode() && isRepeated ) name = JJavaName.getPluralForm(name); return name; }
/** Fill-in the contents of each classes. */ private void buildContents() { ClassSelector cs = getClassSelector(); SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); for( XSSchema s : Ring.get(XSSchemaSet.class).getSchemas() ) { BISchemaBinding sb = getBindInfo(s).get(BISchemaBinding.class); if(sb!=null && !sb.map) { sb.markAsAcknowledged(); continue; // no mapping for this package } getClassSelector().pushClassScope( new CClassInfoParent.Package( getClassSelector().getPackage(s.getTargetNamespace())) ); checkMultipleSchemaBindings(s); processPackageJavadoc(s); populate(s.getAttGroupDecls(),s); populate(s.getAttributeDecls(),s); populate(s.getElementDecls(),s); populate(s.getModelGroupDecls(),s); // fill in typeUses for (XSType t : s.getTypes().values()) { stb.refererStack.push(t); model.typeUses().put( getName(t), cs.bindToType(t,s) ); stb.refererStack.pop(); } getClassSelector().popClassScope(); } }
className = builder.deriveName(className,type); else scope = getClassSelector().getClassScope(); CEnumLeafInfo xducer = new CEnumLeafInfo( model, BGMBuilder.getName(type), scope, className, baseDt, memberList, type, builder.getBindInfo(type).toCustomizationList(), loc ); xducer.javadoc = javadoc; builder.getOrCreateBindInfo(type).addDecl(conv);
BindInfo bindInfo = builder.getBindInfo(complexType); BIClass biClass = bindInfo.get(BIClass.class); BindInfo bindInfo = builder.getBindInfo(component); if(decl == null) { decl = bindInfo.get(BIClass.class); clsName = builder.deriveName( defaultBaseName, component ); } else { if( !JJavaName.isJavaIdentifier(clsName) ) { typeName = getName(t); elementName = getName(e);
private BIGlobalBinding getGlobalBinding() { return builder.getGlobalBinding(); }
private void _build() { // do the binding buildContents(); getClassSelector().executeTasks(); // additional error check // Reports unused customizations to the user as errors. Ring.get(UnusedCustomizationChecker.class).run(); Ring.get(ModelChecker.class).check(); }
/** * Generates <code>package.html</code> if the customization * says so. */ private void processPackageJavadoc( XSSchema s ) { // look for the schema-wide customization BISchemaBinding cust = getBindInfo(s).get(BISchemaBinding.class); if(cust==null) return; // not present cust.markAsAcknowledged(); if( cust.getJavadoc()==null ) return; // no javadoc customization // produce a HTML file JTextFile html = new JTextFile("package.html"); html.setContents(cust.getJavadoc()); getClassSelector().getPackage(s.getTargetNamespace()).addResourceFile(html); }
/** * Entry point. */ public static Model build( XSSchemaSet _schemas, JCodeModel codeModel, ErrorReceiver _errorReceiver, Options opts ) { // set up a ring final Ring old = Ring.begin(); try { ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver); Ring.add(XSSchemaSet.class,_schemas); Ring.add(codeModel); Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas); Ring.add(model); Ring.add(ErrorReceiver.class,ef); Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef)); BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2, opts.isExtensionMode(),opts.getFieldRendererFactory()); builder._build(); if(ef.hadError()) return null; else return model; } finally { Ring.end(old); } }
protected final <T extends BIDeclaration> T getLocalCustomization( XSParticle p, Class<T> type ) { // check the property customization of this component first T cust = builder.getBindInfo(p).get(type); if(cust!=null) return cust; // if not, the term might have one. cust = builder.getBindInfo(p.getTerm()).get(type); if(cust!=null) return cust; return null; }
/** * Derives a name from a schema component. * Use the name of the schema component as the default name. */ private String deriveName( XSDeclaration comp ) { return builder.deriveName( comp.getName(), comp ); }
/** * Calls {@link ClassSelector} for each item in the iterator * to populate class items if there is any. */ private void populate( Map<String,? extends XSComponent> col, XSSchema schema ) { ClassSelector cs = getClassSelector(); for( XSComponent sc : col.values() ) cs.bindToType(sc,schema); }
/** Fill-in the contents of each classes. */ private void buildContents() { ClassSelector cs = getClassSelector(); SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class); for( XSSchema s : Ring.get(XSSchemaSet.class).getSchemas() ) { BISchemaBinding sb = getBindInfo(s).get(BISchemaBinding.class); if(sb!=null && !sb.map) { sb.markAsAcknowledged(); continue; // no mapping for this package } getClassSelector().pushClassScope( new CClassInfoParent.Package( getClassSelector().getPackage(s.getTargetNamespace())) ); checkMultipleSchemaBindings(s); processPackageJavadoc(s); populate(s.getAttGroupDecls(),s); populate(s.getAttributeDecls(),s); populate(s.getElementDecls(),s); populate(s.getModelGroupDecls(),s); // fill in typeUses for (XSType t : s.getTypes().values()) { stb.refererStack.push(t); model.typeUses().put( getName(t), cs.bindToType(t,s) ); stb.refererStack.pop(); } getClassSelector().popClassScope(); } }
className = builder.deriveName(className,type); else scope = getClassSelector().getClassScope(); CEnumLeafInfo xducer = new CEnumLeafInfo( model, BGMBuilder.getName(type), scope, className, baseDt, memberList, type, builder.getBindInfo(type).toCustomizationList(), loc ); xducer.javadoc = javadoc; builder.getOrCreateBindInfo(type).addDecl(conv);
BindInfo bindInfo = builder.getBindInfo(complexType); BIClass biClass = bindInfo.get(BIClass.class); BindInfo bindInfo = builder.getBindInfo(component); if(decl == null) { decl = bindInfo.get(BIClass.class); clsName = builder.deriveName( defaultBaseName, component ); } else { if( !JJavaName.isJavaIdentifier(clsName) ) { typeName = getName(t); elementName = getName(e);
/** Converts an XML name to the corresponding Java name. */ protected final String makeJavaName( boolean isRepeated, String xmlName ) { String name = builder.getNameConverter().toPropertyName(xmlName); if(builder.getGlobalBinding().isSimpleMode() && isRepeated ) name = JJavaName.getPluralForm(name); return name; }
private BIGlobalBinding getGlobalBinding() { return builder.getGlobalBinding(); }
private void _build() { // do the binding buildContents(); getClassSelector().executeTasks(); // additional error check // Reports unused customizations to the user as errors. Ring.get(UnusedCustomizationChecker.class).run(); Ring.get(ModelChecker.class).check(); for( Plugin ma : activePlugins ) ma.postProcessModel(model, Ring.get(ErrorReceiver.class)); }