src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/Operation.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.internal.ws.processor.model;
27
28 import com.sun.tools.internal.ws.processor.model.java.JavaMethod;
29 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
30 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
31 import com.sun.tools.internal.ws.wsdl.framework.Entity;
32 import com.sun.xml.internal.ws.spi.db.BindingHelper;
33
34 import javax.xml.namespace.QName;
35 import java.util.HashSet;
36 import java.util.Iterator;
37 import java.util.Set;
38
39 /**
40 *
41 * @author WS Development Team
42 */
43 public class Operation extends ModelObject {
44
45 public Operation(Entity entity) {
46 super(entity);
47 }
48
49 public Operation(Operation operation, Entity entity){
50 this(operation._name, entity);
51 this._style = operation._style;
52 this._use = operation._use;
53 this.customizedName = operation.customizedName;
54 }
55 public Operation(QName name, Entity entity) {
56 super(entity);
57 _name = name;
58 _uniqueName = name.getLocalPart();
59 _faultNames = new HashSet<String>();
60 _faults = new HashSet<Fault>();
61 }
62
63 public QName getName() {
64 return _name;
65 }
66
67 public void setName(QName n) {
68 _name = n;
69 }
70
71 public String getUniqueName() {
72 return _uniqueName;
73 }
74
75 public void setUniqueName(String s) {
76 _uniqueName = s;
77 }
78
79 public Request getRequest() {
80 return _request;
81 }
82
83 public void setRequest(Request r) {
84 _request = r;
85 }
86
87 public Response getResponse() {
88 return _response;
89 }
90
91 public void setResponse(Response r) {
92 _response = r;
93 }
94
95 public boolean isOverloaded() {
96 return !_name.getLocalPart().equals(_uniqueName);
97 }
98
99 public void addFault(Fault f) {
100 if (_faultNames.contains(f.getName())) {
101 throw new ModelException("model.uniqueness");
102 }
103 _faultNames.add(f.getName());
104 _faults.add(f);
105 }
106
107 public Iterator<Fault> getFaults() {
108 return _faults.iterator();
109 }
110
111 public Set<Fault> getFaultsSet() {
112 return _faults;
113 }
114
115 /* serialization */
116 public void setFaultsSet(Set<Fault> s) {
117 _faults = s;
118 initializeFaultNames();
119 }
120
121 private void initializeFaultNames() {
122 _faultNames = new HashSet<String>();
123 if (_faults != null) {
124 for (Iterator iter = _faults.iterator(); iter.hasNext();) {
125 Fault f = (Fault) iter.next();
126 if (f.getName() != null && _faultNames.contains(f.getName())) {
127 throw new ModelException("model.uniqueness");
128 }
129 _faultNames.add(f.getName());
130 }
131 }
132 }
133
134 public Iterator<Fault> getAllFaults() {
135 Set<Fault> allFaults = getAllFaultsSet();
136 return allFaults.iterator();
137 }
138
139 public Set<Fault> getAllFaultsSet() {
140 Set transSet = new HashSet();
141 transSet.addAll(_faults);
142 Iterator iter = _faults.iterator();
143 Fault fault;
144 Set tmpSet;
145 while (iter.hasNext()) {
146 tmpSet = ((Fault)iter.next()).getAllFaultsSet();
147 transSet.addAll(tmpSet);
148 }
149 return transSet;
150 }
151
152 public int getFaultCount() {
153 return _faults.size();
154 }
155
156 public Set<Block> getAllFaultBlocks(){
157 Set<Block> blocks = new HashSet<Block>();
158 Iterator faults = _faults.iterator();
159 while(faults.hasNext()){
160 Fault f = (Fault)faults.next();
161 blocks.add(f.getBlock());
162 }
163 return blocks;
164 }
165
166 public JavaMethod getJavaMethod() {
167 return _javaMethod;
168 }
169
170 public void setJavaMethod(JavaMethod i) {
171 _javaMethod = i;
172 }
173
174 public String getSOAPAction() {
175 return _soapAction;
176 }
177
178 public void setSOAPAction(String s) {
179 _soapAction = s;
180 }
181
182 public SOAPStyle getStyle() {
183 return _style;
184 }
185
186 public void setStyle(SOAPStyle s) {
187 _style = s;
188 }
189
190 public SOAPUse getUse() {
191 return _use;
192 }
193
194 public void setUse(SOAPUse u) {
195 _use = u;
196 }
197
198 public boolean isWrapped() {
199 return _isWrapped;
200 }
201
202 public void setWrapped(boolean isWrapped) {
203 _isWrapped = isWrapped;
204 }
205
206
207 public void accept(ModelVisitor visitor) throws Exception {
208 visitor.visit(this);
209 }
210
211 public void setCustomizedName(String name){
212 this.customizedName = name;
213 }
214
215 public String getCustomizedName(){
216 return customizedName;
217 }
218
219 public String getJavaMethodName(){
220 //if JavaMethod is created return the name
221 if(_javaMethod != null){
222 return _javaMethod.getName();
223 }
224
225 //return the customized operation name if any without mangling
226 if(customizedName != null){
227 return customizedName;
228 }
229
230 return BindingHelper.mangleNameToVariableName(_name.getLocalPart());
231 }
232
233 public com.sun.tools.internal.ws.wsdl.document.Operation getWSDLPortTypeOperation(){
234 return wsdlOperation;
235 }
236
237 public void setWSDLPortTypeOperation(com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation){
238 this.wsdlOperation = wsdlOperation;
239 }
240
241
242
243 private String customizedName;
244 private boolean _isWrapped = true;
245 private QName _name;
246 private String _uniqueName;
247 private Request _request;
248 private Response _response;
249 private JavaMethod _javaMethod;
250 private String _soapAction;
251 private SOAPStyle _style = SOAPStyle.DOCUMENT;
252 private SOAPUse _use = SOAPUse.LITERAL;
253 private Set<String> _faultNames;
254 private Set<Fault> _faults;
255 private com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation;
256
257 }

mercurial