KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > model > impl > DefinitionsImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.wsdl.model.impl;
21
22 import java.util.Collection JavaDoc;
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 JavaDoc;
33
34 /**
35  *
36  * @author rico
37  */

38 public class DefinitionsImpl extends NamedImpl implements Definitions {
39             
40     /** Creates a new instance of DefinitionsImpl */
41     public DefinitionsImpl(WSDLModel model, Element JavaDoc 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 JavaDoc TNS = "tns"; //NOI18N
82

83     public void setTargetNamespace(String JavaDoc uri) {
84         String JavaDoc 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 JavaDoc<Service> getServices() {
102         return getChildren(Service.class);
103     }
104
105     public Collection JavaDoc<PortType> getPortTypes() {
106         return getChildren(PortType.class);
107     }
108
109     public Collection JavaDoc<Message> getMessages() {
110         return getChildren(Message.class);
111     }
112
113     public Collection JavaDoc<Import> getImports() {
114         return getChildren(Import.class);
115     }
116
117     public Collection JavaDoc<Binding> getBindings() {
118         return getChildren(Binding.class);
119     }
120
121     public String JavaDoc 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