001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.internal.ws.processor.model;
027:
028: import com.sun.tools.internal.ws.processor.model.java.JavaMethod;
029: import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
030: import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
031: import com.sun.xml.internal.bind.api.JAXBRIContext;
032:
033: import javax.xml.namespace.QName;
034: import java.util.HashSet;
035: import java.util.Iterator;
036: import java.util.Set;
037:
038: /**
039: *
040: * @author WS Development Team
041: */
042: public class Operation extends ModelObject {
043:
044: public Operation() {
045: }
046:
047: public Operation(Operation operation) {
048: this (operation._name);
049: this ._style = operation._style;
050: this ._use = operation._use;
051: this .customizedName = operation.customizedName;
052: }
053:
054: public Operation(QName name) {
055: _name = name;
056: _uniqueName = name.getLocalPart();
057: _faultNames = new HashSet<String>();
058: _faults = new HashSet<Fault>();
059: }
060:
061: public QName getName() {
062: return _name;
063: }
064:
065: public void setName(QName n) {
066: _name = n;
067: }
068:
069: public String getUniqueName() {
070: return _uniqueName;
071: }
072:
073: public void setUniqueName(String s) {
074: _uniqueName = s;
075: }
076:
077: public Request getRequest() {
078: return _request;
079: }
080:
081: public void setRequest(Request r) {
082: _request = r;
083: }
084:
085: public Response getResponse() {
086: return _response;
087: }
088:
089: public void setResponse(Response r) {
090: _response = r;
091: }
092:
093: public boolean isOverloaded() {
094: return !_name.getLocalPart().equals(_uniqueName);
095: }
096:
097: public void addFault(Fault f) {
098: if (_faultNames.contains(f.getName())) {
099: throw new ModelException("model.uniqueness");
100: }
101: _faultNames.add(f.getName());
102: _faults.add(f);
103: }
104:
105: public Iterator<Fault> getFaults() {
106: return _faults.iterator();
107: }
108:
109: public Set<Fault> getFaultsSet() {
110: return _faults;
111: }
112:
113: /* serialization */
114: public void setFaultsSet(Set<Fault> s) {
115: _faults = s;
116: initializeFaultNames();
117: }
118:
119: private void initializeFaultNames() {
120: _faultNames = new HashSet<String>();
121: if (_faults != null) {
122: for (Iterator iter = _faults.iterator(); iter.hasNext();) {
123: Fault f = (Fault) iter.next();
124: if (f.getName() != null
125: && _faultNames.contains(f.getName())) {
126: throw new ModelException("model.uniqueness");
127: }
128: _faultNames.add(f.getName());
129: }
130: }
131: }
132:
133: public Iterator<Fault> getAllFaults() {
134: Set<Fault> allFaults = getAllFaultsSet();
135: return allFaults.iterator();
136: }
137:
138: public Set<Fault> getAllFaultsSet() {
139: Set transSet = new HashSet();
140: transSet.addAll(_faults);
141: Iterator iter = _faults.iterator();
142: Fault fault;
143: Set tmpSet;
144: while (iter.hasNext()) {
145: tmpSet = ((Fault) iter.next()).getAllFaultsSet();
146: transSet.addAll(tmpSet);
147: }
148: return transSet;
149: }
150:
151: public int getFaultCount() {
152: return _faults.size();
153: }
154:
155: public Set<Block> getAllFaultBlocks() {
156: Set<Block> blocks = new HashSet<Block>();
157: Iterator faults = _faults.iterator();
158: while (faults.hasNext()) {
159: Fault f = (Fault) faults.next();
160: blocks.add(f.getBlock());
161: }
162: return blocks;
163: }
164:
165: public JavaMethod getJavaMethod() {
166: return _javaMethod;
167: }
168:
169: public void setJavaMethod(JavaMethod i) {
170: _javaMethod = i;
171: }
172:
173: public String getSOAPAction() {
174: return _soapAction;
175: }
176:
177: public void setSOAPAction(String s) {
178: _soapAction = s;
179: }
180:
181: public SOAPStyle getStyle() {
182: return _style;
183: }
184:
185: public void setStyle(SOAPStyle s) {
186: _style = s;
187: }
188:
189: public SOAPUse getUse() {
190: return _use;
191: }
192:
193: public void setUse(SOAPUse u) {
194: _use = u;
195: }
196:
197: public boolean isWrapped() {
198: return _isWrapped;
199: }
200:
201: public void setWrapped(boolean isWrapped) {
202: _isWrapped = isWrapped;
203: }
204:
205: public void accept(ModelVisitor visitor) throws Exception {
206: visitor.visit(this );
207: }
208:
209: public void setCustomizedName(String name) {
210: this .customizedName = name;
211: }
212:
213: public String getCustomizedName() {
214: return customizedName;
215: }
216:
217: public String getJavaMethodName() {
218: //if JavaMethod is created return the name
219: if (_javaMethod != null) {
220: return _javaMethod.getName();
221: }
222:
223: //return the customized operation name if any without mangling
224: if (customizedName != null) {
225: return customizedName;
226: }
227:
228: return JAXBRIContext.mangleNameToVariableName(_name
229: .getLocalPart());
230: }
231:
232: private String customizedName;
233: private boolean _isWrapped = true;
234: private QName _name;
235: private String _uniqueName;
236: private Request _request;
237: private Response _response;
238: private JavaMethod _javaMethod;
239: private String _soapAction;
240: private SOAPStyle _style = SOAPStyle.DOCUMENT;
241: private SOAPUse _use = SOAPUse.LITERAL;
242: private Set<String> _faultNames;
243: private Set<Fault> _faults;
244:
245: }
|