1 19 20 28 29 package org.netbeans.modules.xml.wsdl.ui.wizard; 30 31 import javax.xml.namespace.QName ; 32 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement; 33 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 34 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 35 import org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType; 36 import org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionElementType; 37 import org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType; 38 import org.netbeans.modules.xml.wsdl.ui.view.wizard.localized.LocalizedTemplate; 39 40 44 public class WsdlGenerationUtil { 45 46 private WSDLModel mModel; 47 48 49 public WsdlGenerationUtil(WSDLModel model) { 50 this.mModel = model; 51 } 52 53 54 public ExtensibilityElement createAndAddExtensionElementAndAttribute(String wsdlElementNameInTemplate, LocalizedTemplate bindingSubType, WSDLComponent parentWSDLComponent) { 55 ExtensibilityElement e = null; 56 String namespace = bindingSubType.getTemplateGroup().getNamespace(); 57 String prefix = bindingSubType.getTemplateGroup().getPrefix(); 58 59 WsdlElementType wsdlElement = bindingSubType.getWSDLElementType(wsdlElementNameInTemplate); 60 61 if(wsdlElement != null) { 62 ExtensionElementType[] ees = wsdlElement.getExtensionElement(); 63 if(ees != null) { 64 for(int i=0; i < ees.length; i++) { 65 ExtensionElementType ee = ees[i]; 66 String name = ee.getName(); 67 if(name != null) { 68 e = createExtensibilityElement(name, prefix, namespace, parentWSDLComponent); 69 if(e != null) { 70 parentWSDLComponent.addExtensibilityElement(e); 71 createAndAddExtensibilityElementAttributes(e, ee.getExtensionAttr()); 72 } 73 } 74 } 75 } 76 } 77 78 return e; 79 } 80 81 public void createAndAddExtensibilityElementAttributes(ExtensibilityElement ee, ExtensionAttrType[] attrs) { 82 if(attrs != null) { 83 for(int i =0; i< attrs.length; i++) { 84 ExtensionAttrType attr = attrs[i]; 85 String name = attr.getName(); 86 String defaultValue = attr.getDefaultValue(); 87 if(name != null) { 88 ee.setAttribute(name, defaultValue); 89 } 90 } 91 } 92 } 93 94 public ExtensibilityElement createExtensibilityElement(String elementName, 95 String prefix, 96 String targetNamespace, 97 WSDLComponent parent) { 98 QName qName = null; 99 100 if(prefix != null) { 101 qName = new QName (targetNamespace, elementName, prefix); 102 } else { 103 qName = new QName (targetNamespace, elementName); 104 } 105 106 ExtensibilityElement exElement = (ExtensibilityElement) this.mModel.getFactory().create(parent, qName); 109 110 return exElement; 111 112 } 113 } 114 | Popular Tags |