blob: c301ad98463f3a12cd31adad204f8dd53991a20c [file] [log] [blame]
/*
* Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.xml.internal.ws.wsdl.parser;
import com.sun.xml.internal.ws.model.ParameterBinding;
import com.sun.xml.internal.ws.model.Mode;
import javax.xml.ws.Response;
import java.util.HashMap;
import java.util.Map;
public class BindingOperation {
private String name;
// map of wsdl:part to the binding
private Map<String, ParameterBinding> inputParts;
private Map<String, ParameterBinding> outputParts;
private Map<String, String> inputMimeTypes;
private Map<String, String> outputMimeTypes;
private boolean explicitInputSOAPBodyParts = false;
private boolean explicitOutputSOAPBodyParts = false;
private Boolean emptyInputBody;
private Boolean emptyOutputBody;
private Map<String, Part> inParts;
private Map<String, Part> outParts;
/**
*
* @param name wsdl:operation name qualified value
*/
public BindingOperation(String name) {
this.name = name;
inputParts = new HashMap<String, ParameterBinding>();
outputParts = new HashMap<String, ParameterBinding>();
inputMimeTypes = new HashMap<String, String>();
outputMimeTypes = new HashMap<String, String>();
inParts = new HashMap<String, Part>();
outParts = new HashMap<String, Part>();
}
public String getName(){
return name;
}
public Part getPart(String partName, Mode mode){
if(mode.equals(Mode.IN)){
return inParts.get(partName);
}else if(mode.equals(Mode.OUT)){
return outParts.get(partName);
}
return null;
}
public void addPart(Part part, Mode mode){
if(mode.equals(Mode.IN))
inParts.put(part.getName(), part);
else if(mode.equals(Mode.OUT))
outParts.put(part.getName(), part);
}
public Map<String, ParameterBinding> getInputParts() {
return inputParts;
}
public Map<String, ParameterBinding> getOutputParts() {
return outputParts;
}
public Map<String, String> getInputMimeTypes() {
return inputMimeTypes;
}
public Map<String, String> getOutputMimeTypes() {
return outputMimeTypes;
}
public ParameterBinding getInputBinding(String part){
if(emptyInputBody == null){
if(inputParts.get(" ") != null)
emptyInputBody = true;
else
emptyInputBody = false;
}
ParameterBinding block = inputParts.get(part);
if(block == null){
if(explicitInputSOAPBodyParts || emptyInputBody)
return ParameterBinding.UNBOUND;
return ParameterBinding.BODY;
}
return block;
}
public ParameterBinding getOutputBinding(String part){
if(emptyOutputBody == null){
if(outputParts.get(" ") != null)
emptyOutputBody = true;
else
emptyOutputBody = false;
}
ParameterBinding block = outputParts.get(part);
if(block == null){
if(explicitOutputSOAPBodyParts || emptyOutputBody)
return ParameterBinding.UNBOUND;
return ParameterBinding.BODY;
}
return block;
}
public String getMimeTypeForInputPart(String part){
return inputMimeTypes.get(part);
}
public String getMimeTypeForOutputPart(String part){
return outputMimeTypes.get(part);
}
public void setInputExplicitBodyParts(boolean b) {
explicitInputSOAPBodyParts = b;
}
public void setOutputExplicitBodyParts(boolean b) {
explicitOutputSOAPBodyParts = b;
}
String reqNamespace;
String respNamespace;
/**
* For rpclit gives namespace value on soapbinding:body@namespace
*
* @return non-null for rpclit and null for doclit
* @see com.sun.xml.internal.ws.modeler.RuntimeModeler#processRpcMethod(com.sun.xml.internal.ws.model.JavaMethod, String, javax.jws.WebMethod, String, java.lang.reflect.Method, javax.jws.WebService)
*/
public String getRequestNamespace(){
return reqNamespace;
}
/**
* For rpclit gives namespace value on soapbinding:body@namespace
*
* @return non-null for rpclit and null for doclit
* * @see com.sun.xml.internal.ws.modeler.RuntimeModeler#processRpcMethod(com.sun.xml.internal.ws.model.JavaMethod, String, javax.jws.WebMethod, String, java.lang.reflect.Method, javax.jws.WebService)
*/
public String getResponseNamespace(){
return respNamespace;
}
}