325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.tools.internal.ws.processor.model;
325N/A
325N/Aimport com.sun.tools.internal.ws.processor.model.java.JavaMethod;
325N/Aimport com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
325N/Aimport com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
325N/Aimport com.sun.tools.internal.ws.wsdl.framework.Entity;
325N/Aimport com.sun.xml.internal.bind.api.JAXBRIContext;
325N/A
325N/Aimport javax.xml.namespace.QName;
325N/Aimport java.util.HashSet;
325N/Aimport java.util.Iterator;
325N/Aimport java.util.Set;
325N/A
325N/A/**
325N/A *
325N/A * @author WS Development Team
325N/A */
325N/Apublic class Operation extends ModelObject {
325N/A
325N/A public Operation(Entity entity) {
325N/A super(entity);
325N/A }
325N/A
325N/A public Operation(Operation operation, Entity entity){
325N/A this(operation._name, entity);
325N/A this._style = operation._style;
325N/A this._use = operation._use;
325N/A this.customizedName = operation.customizedName;
325N/A }
325N/A public Operation(QName name, Entity entity) {
325N/A super(entity);
325N/A _name = name;
325N/A _uniqueName = name.getLocalPart();
325N/A _faultNames = new HashSet<String>();
325N/A _faults = new HashSet<Fault>();
325N/A }
325N/A
325N/A public QName getName() {
325N/A return _name;
325N/A }
325N/A
325N/A public void setName(QName n) {
325N/A _name = n;
325N/A }
325N/A
325N/A public String getUniqueName() {
325N/A return _uniqueName;
325N/A }
325N/A
325N/A public void setUniqueName(String s) {
325N/A _uniqueName = s;
325N/A }
325N/A
325N/A public Request getRequest() {
325N/A return _request;
325N/A }
325N/A
325N/A public void setRequest(Request r) {
325N/A _request = r;
325N/A }
325N/A
325N/A public Response getResponse() {
325N/A return _response;
325N/A }
325N/A
325N/A public void setResponse(Response r) {
325N/A _response = r;
325N/A }
325N/A
325N/A public boolean isOverloaded() {
325N/A return !_name.getLocalPart().equals(_uniqueName);
325N/A }
325N/A
325N/A public void addFault(Fault f) {
325N/A if (_faultNames.contains(f.getName())) {
325N/A throw new ModelException("model.uniqueness");
325N/A }
325N/A _faultNames.add(f.getName());
325N/A _faults.add(f);
325N/A }
325N/A
325N/A public Iterator<Fault> getFaults() {
325N/A return _faults.iterator();
325N/A }
325N/A
325N/A public Set<Fault> getFaultsSet() {
325N/A return _faults;
325N/A }
325N/A
325N/A /* serialization */
325N/A public void setFaultsSet(Set<Fault> s) {
325N/A _faults = s;
325N/A initializeFaultNames();
325N/A }
325N/A
325N/A private void initializeFaultNames() {
325N/A _faultNames = new HashSet<String>();
325N/A if (_faults != null) {
325N/A for (Iterator iter = _faults.iterator(); iter.hasNext();) {
325N/A Fault f = (Fault) iter.next();
325N/A if (f.getName() != null && _faultNames.contains(f.getName())) {
325N/A throw new ModelException("model.uniqueness");
325N/A }
325N/A _faultNames.add(f.getName());
325N/A }
325N/A }
325N/A }
325N/A
325N/A public Iterator<Fault> getAllFaults() {
325N/A Set<Fault> allFaults = getAllFaultsSet();
325N/A return allFaults.iterator();
325N/A }
325N/A
325N/A public Set<Fault> getAllFaultsSet() {
325N/A Set transSet = new HashSet();
325N/A transSet.addAll(_faults);
325N/A Iterator iter = _faults.iterator();
325N/A Fault fault;
325N/A Set tmpSet;
325N/A while (iter.hasNext()) {
325N/A tmpSet = ((Fault)iter.next()).getAllFaultsSet();
325N/A transSet.addAll(tmpSet);
325N/A }
325N/A return transSet;
325N/A }
325N/A
325N/A public int getFaultCount() {
325N/A return _faults.size();
325N/A }
325N/A
325N/A public Set<Block> getAllFaultBlocks(){
325N/A Set<Block> blocks = new HashSet<Block>();
325N/A Iterator faults = _faults.iterator();
325N/A while(faults.hasNext()){
325N/A Fault f = (Fault)faults.next();
325N/A blocks.add(f.getBlock());
325N/A }
325N/A return blocks;
325N/A }
325N/A
325N/A public JavaMethod getJavaMethod() {
325N/A return _javaMethod;
325N/A }
325N/A
325N/A public void setJavaMethod(JavaMethod i) {
325N/A _javaMethod = i;
325N/A }
325N/A
325N/A public String getSOAPAction() {
325N/A return _soapAction;
325N/A }
325N/A
325N/A public void setSOAPAction(String s) {
325N/A _soapAction = s;
325N/A }
325N/A
325N/A public SOAPStyle getStyle() {
325N/A return _style;
325N/A }
325N/A
325N/A public void setStyle(SOAPStyle s) {
325N/A _style = s;
325N/A }
325N/A
325N/A public SOAPUse getUse() {
325N/A return _use;
325N/A }
325N/A
325N/A public void setUse(SOAPUse u) {
325N/A _use = u;
325N/A }
325N/A
325N/A public boolean isWrapped() {
325N/A return _isWrapped;
325N/A }
325N/A
325N/A public void setWrapped(boolean isWrapped) {
325N/A _isWrapped = isWrapped;
325N/A }
325N/A
325N/A
325N/A public void accept(ModelVisitor visitor) throws Exception {
325N/A visitor.visit(this);
325N/A }
325N/A
325N/A public void setCustomizedName(String name){
325N/A this.customizedName = name;
325N/A }
325N/A
325N/A public String getCustomizedName(){
325N/A return customizedName;
325N/A }
325N/A
325N/A public String getJavaMethodName(){
325N/A //if JavaMethod is created return the name
325N/A if(_javaMethod != null){
325N/A return _javaMethod.getName();
325N/A }
325N/A
325N/A //return the customized operation name if any without mangling
325N/A if(customizedName != null){
325N/A return customizedName;
325N/A }
325N/A
325N/A return JAXBRIContext.mangleNameToVariableName(_name.getLocalPart());
325N/A }
325N/A
325N/A public com.sun.tools.internal.ws.wsdl.document.Operation getWSDLPortTypeOperation(){
325N/A return wsdlOperation;
325N/A }
325N/A
325N/A public void setWSDLPortTypeOperation(com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation){
325N/A this.wsdlOperation = wsdlOperation;
325N/A }
325N/A
325N/A
325N/A
325N/A private String customizedName;
325N/A private boolean _isWrapped = true;
325N/A private QName _name;
325N/A private String _uniqueName;
325N/A private Request _request;
325N/A private Response _response;
325N/A private JavaMethod _javaMethod;
325N/A private String _soapAction;
325N/A private SOAPStyle _style = SOAPStyle.DOCUMENT;
325N/A private SOAPUse _use = SOAPUse.LITERAL;
325N/A private Set<String> _faultNames;
325N/A private Set<Fault> _faults;
325N/A private com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation;
325N/A
325N/A}