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; }
/** * Gets or creates the BindInfo object associated to a schema component. * * @return * Always return a non-null valid BindInfo object. * Even if no declaration was specified, this method creates * a new BindInfo so that new decls can be added. */ public BindInfo getOrCreateBindInfo( XSComponent schemaComponent ) { BindInfo bi = _getBindInfoReadOnly(schemaComponent); if(bi!=null) return bi; // XSOM is read-only, so we cannot add new annotations. // for components that didn't have annotations, // we maintain an external map. bi = new BindInfo(); bi.setOwner(this,schemaComponent); externalBindInfos.put(schemaComponent,bi); return bi; }
public BindInfo getResult( Object existing ) { if(handler==null) // interface contract violation. // the getContentHandler method must have been called. throw new AssertionError(); try { BindInfo result = (BindInfo)handler.getResult(); if(existing!=null) { BindInfo bie = (BindInfo)existing; bie.absorb(result); return bie; } else { if(!result.isPointless()) return result; // just annotation. no meaningful customization else return null; } } catch (JAXBException e) { throw new AssertionError(e); } } };
/** * Gets the BindInfo object associated to a schema component. * * @return * null if no bind info is associated to this schema component. */ private BindInfo _getBindInfoReadOnly( XSComponent schemaComponent ) { BindInfo bi = externalBindInfos.get(schemaComponent); if(bi!=null) return bi; XSAnnotation annon = schemaComponent.getAnnotation(); if(annon!=null) { bi = (BindInfo)annon.getAnnotation(); if(bi!=null) { if(bi.getOwner()==null) bi.setOwner(this,schemaComponent); return bi; } } return null; }
model.getCustomizations().addAll(bi.toCustomizationList()); BIGlobalBinding gb = bi.get(BIGlobalBinding.class); if(gb==null) continue; BindInfo big = new BindInfo(); big.addDecl(globalBinding); big.setOwner(this,null);
String mdoc=builder.getBindInfo(facet).getDocumentation(); if( mem==null ) mem = builder.getBindInfo(facet).get(BIEnumMember.class); memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator()));
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);
String mdoc=builder.getBindInfo(facet).getDocumentation(); if( mem==null ) mem = builder.getBindInfo(facet).get(BIEnumMember.class);
public void addTo(BindInfo bi) { if(contents==null) return; for (Object o : contents) { if(o instanceof BIDeclaration) bi.addDecl((BIDeclaration)o); // this is really PITA! I can't get the source location if(o instanceof DomHandlerEx.DomAndLocation) { DomHandlerEx.DomAndLocation e = (DomHandlerEx.DomAndLocation)o; String nsUri = e.element.getNamespaceURI(); if(nsUri==null || nsUri.equals("") || nsUri.equals(WellKnownNamespace.XML_SCHEMA)) continue; // this is definitely not a customization bi.addDecl(new BIXPluginCustomization(e.element,e.loc)); } } } }
String doc = builder.getBindInfo(sc).getDocumentation(); if(doc!=null) append(bean, doc);
private static BIDeclaration hasAnnotation(XSAnnotation annotation, QName qname) { if (annotation == null) { return null; } Object object = annotation.getAnnotation(); if (!(object instanceof BindInfo)) { return null; } BindInfo info = (BindInfo) object; BIDeclaration[] declarations = info.getDecls(); if (declarations == null) { return null; } for (BIDeclaration declaration : declarations) { if (qname.equals(declaration.getName())) { return declaration; } } return null; }
protected final BGMBuilder getBuilder() { return parent.getBuilder(); } protected final JCodeModel getCodeModel() {
protected final XSComponent getOwner() { return parent.getOwner(); } protected final BGMBuilder getBuilder() {
model.getCustomizations().addAll(bi.toCustomizationList()); BIGlobalBinding gb = bi.get(BIGlobalBinding.class); if(gb==null) continue; BindInfo big = new BindInfo(); big.addDecl(globalBinding); big.setOwner(this,null);
String mdoc=builder.getBindInfo(facet).getDocumentation(); if( mem==null ) mem = builder.getBindInfo(facet).get(BIEnumMember.class); memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator()));
/** * Gets the BindInfo object associated to a schema component. * * @return * null if no bind info is associated to this schema component. */ private BindInfo _getBindInfoReadOnly( XSComponent schemaComponent ) { BindInfo bi = externalBindInfos.get(schemaComponent); if(bi!=null) return bi; XSAnnotation annon = schemaComponent.getAnnotation(); if(annon!=null) { bi = (BindInfo)annon.getAnnotation(); if(bi!=null) { if(bi.getOwner()==null) bi.setOwner(this,schemaComponent); return bi; } } return null; }
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);
public void addTo(BindInfo bi) { if(contents==null) return; for (Object o : contents) { if(o instanceof BIDeclaration) bi.addDecl((BIDeclaration)o); // this is really PITA! I can't get the source location if(o instanceof DomHandlerEx.DomAndLocation) { DomHandlerEx.DomAndLocation e = (DomHandlerEx.DomAndLocation)o; String nsUri = e.element.getNamespaceURI(); if(nsUri==null || nsUri.equals("") || nsUri.equals(WellKnownNamespace.XML_SCHEMA)) continue; // this is definitely not a customization bi.addDecl(new BIXPluginCustomization(e.element,e.loc)); } } } }