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: package com.sun.xml.internal.ws.wsdl.parser;
026:
027: import com.sun.xml.internal.ws.model.Mode;
028: import com.sun.xml.internal.ws.model.ParameterBinding;
029:
030: import javax.xml.namespace.QName;
031: import java.util.HashMap;
032:
033: public class Binding extends HashMap<String, BindingOperation> {
034: private QName name;
035: private QName portTypeName;
036: private PortType portType;
037: private String bindingId;
038: private WSDLDocument wsdlDoc;
039: private boolean finalized = false;
040:
041: public Binding(QName name, QName portTypeName) {
042: super ();
043: this .name = name;
044: this .portTypeName = portTypeName;
045: }
046:
047: public QName getName() {
048: return name;
049: }
050:
051: public QName getPortTypeName() {
052: return portTypeName;
053: }
054:
055: public PortType getPortType() {
056: return portType;
057: }
058:
059: public void setPortType(PortType portType) {
060: this .portType = portType;
061: }
062:
063: public String getBindingId() {
064: return bindingId;
065: }
066:
067: public void setBindingId(String bindingId) {
068: this .bindingId = bindingId;
069: }
070:
071: public void setWsdlDocument(WSDLDocument wsdlDoc) {
072: this .wsdlDoc = wsdlDoc;
073: }
074:
075: public ParameterBinding getBinding(String operation, String part,
076: Mode mode) {
077: BindingOperation op = get(operation);
078: if (op == null) {
079: //TODO throw exception
080: return null;
081: }
082: if ((Mode.IN == mode) || (Mode.INOUT == mode))
083: return op.getInputBinding(part);
084: else
085: return op.getOutputBinding(part);
086: }
087:
088: /**
089: * Gives binding for a given {@link BindingOperation} a wsdl part and {@link Mode}
090: * @param op must be non-null
091: * @param part must be non-null
092: * @param mode must be non-null
093: * @return parameter Binding, null the binding could not be determined.
094: */
095: public ParameterBinding getBinding(BindingOperation op,
096: String part, Mode mode) {
097: if ((Mode.IN == mode) || (Mode.INOUT == mode))
098: return op.getInputBinding(part);
099: else
100: return op.getOutputBinding(part);
101: }
102:
103: public String getMimeType(String operation, String part, Mode mode) {
104: BindingOperation op = get(operation);
105: if (Mode.IN == mode)
106: return op.getMimeTypeForInputPart(part);
107: else
108: return op.getMimeTypeForOutputPart(part);
109: }
110:
111: public void finalizeBinding() {
112: if (!finalized) {
113: wsdlDoc.finalizeBinding(this );
114: finalized = true;
115: }
116: }
117:
118: }
|