1 19 20 package org.netbeans.modules.xml.wsdl.model.impl; 21 22 import java.util.Collection ; 23 import org.netbeans.modules.xml.wsdl.model.Binding; 24 import org.netbeans.modules.xml.wsdl.model.Definitions; 25 import org.netbeans.modules.xml.wsdl.model.Import; 26 import org.netbeans.modules.xml.wsdl.model.Message; 27 import org.netbeans.modules.xml.wsdl.model.PortType; 28 import org.netbeans.modules.xml.wsdl.model.Service; 29 import org.netbeans.modules.xml.wsdl.model.Types; 30 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 31 import org.netbeans.modules.xml.wsdl.model.visitor.WSDLVisitor; 32 import org.w3c.dom.Element ; 33 34 38 public class DefinitionsImpl extends NamedImpl implements Definitions { 39 40 41 public DefinitionsImpl(WSDLModel model, Element e) { 42 super(model, e); 43 } 44 45 public DefinitionsImpl(WSDLModel model){ 46 this(model, createNewElement(WSDLQNames.DEFINITIONS.getQName(), model)); 47 } 48 49 public void addBinding(Binding binding) { 50 addAfter(BINDING_PROPERTY, binding, TypeCollection.FOR_BINDING.types()); 51 } 52 53 public void removeBinding(Binding binding) { 54 removeChild(BINDING_PROPERTY, binding); 55 } 56 57 public void addService(Service service) { 58 addAfter(SERVICE_PROPERTY, service, TypeCollection.FOR_SERVICE.types()); 59 } 60 61 public void removeService(Service service) { 62 removeChild(SERVICE_PROPERTY, service); 63 } 64 65 public void addImport(Import importDefinition) { 66 addAfter(IMPORT_PROPERTY, importDefinition, TypeCollection.FOR_IMPORT.types()); 67 } 68 69 public void removeImport(Import importDefinition) { 70 removeChild(IMPORT_PROPERTY, importDefinition); 71 } 72 73 public void addPortType(PortType portType) { 74 addAfter(PORT_TYPE_PROPERTY, portType, TypeCollection.FOR_PORTTYPE.types()); 75 } 76 77 public void removePortType(PortType portType) { 78 removeChild(PORT_TYPE_PROPERTY, portType); 79 } 80 81 public static final String TNS = "tns"; 83 public void setTargetNamespace(String uri) { 84 String currentTargetNamespace = getTargetNamespace(); 85 setAttribute(TARGET_NAMESPACE_PROPERTY, WSDLAttribute.TARGET_NAMESPACE, uri); 86 ensureValueNamespaceDeclared(uri, currentTargetNamespace, TNS); 87 } 88 89 public void setTypes(Types types) { 90 setChild(Types.class, TYPES_PROPERTY, types, TypeCollection.FOR_TYPES.types()); 91 } 92 93 public void addMessage(Message message) { 94 addAfter(MESSAGE_PROPERTY, message, TypeCollection.FOR_MESSAGE.types()); 95 } 96 97 public void removeMessage(Message message) { 98 removeChild(MESSAGE_PROPERTY, message); 99 } 100 101 public Collection <Service> getServices() { 102 return getChildren(Service.class); 103 } 104 105 public Collection <PortType> getPortTypes() { 106 return getChildren(PortType.class); 107 } 108 109 public Collection <Message> getMessages() { 110 return getChildren(Message.class); 111 } 112 113 public Collection <Import> getImports() { 114 return getChildren(Import.class); 115 } 116 117 public Collection <Binding> getBindings() { 118 return getChildren(Binding.class); 119 } 120 121 public String getTargetNamespace() { 122 return getAttribute(WSDLAttribute.TARGET_NAMESPACE); 123 } 124 125 public Types getTypes() { 126 return getChild(Types.class); 127 } 128 129 public void accept(WSDLVisitor visitor) { 130 visitor.visit(this); 131 } 132 } 133 | Popular Tags |