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.wsdl.document;
027:
028: import javax.xml.namespace.QName;
029:
030: import com.sun.tools.internal.ws.wsdl.framework.Entity;
031: import com.sun.tools.internal.ws.wsdl.framework.EntityReferenceAction;
032: import com.sun.tools.internal.ws.wsdl.framework.Kind;
033: import com.sun.tools.internal.ws.wsdl.framework.QNameAction;
034: import com.sun.xml.internal.ws.model.Mode;
035:
036: /**
037: * Entity corresponding to a WSDL message part.
038: *
039: * @author WS Development Team
040: */
041: public class MessagePart extends Entity {
042:
043: public static final int SOAP_BODY_BINDING = 1;
044: public static final int SOAP_HEADER_BINDING = 2;
045: public static final int SOAP_HEADERFAULT_BINDING = 3;
046: public static final int SOAP_FAULT_BINDING = 4;
047: public static final int WSDL_MIME_BINDING = 5;
048: public static final int PART_NOT_BOUNDED = -1;
049:
050: public MessagePart() {
051: }
052:
053: public String getName() {
054: return _name;
055: }
056:
057: public void setName(String name) {
058: _name = name;
059: }
060:
061: public QName getDescriptor() {
062: return _descriptor;
063: }
064:
065: public void setDescriptor(QName n) {
066: _descriptor = n;
067: }
068:
069: public Kind getDescriptorKind() {
070: return _descriptorKind;
071: }
072:
073: public void setDescriptorKind(Kind k) {
074: _descriptorKind = k;
075: }
076:
077: public QName getElementName() {
078: return WSDLConstants.QNAME_PART;
079: }
080:
081: public int getBindingExtensibilityElementKind() {
082: return _bindingKind;
083: }
084:
085: public void setBindingExtensibilityElementKind(int kind) {
086: _bindingKind = kind;
087: }
088:
089: public void withAllQNamesDo(QNameAction action) {
090: if (_descriptor != null) {
091: action.perform(_descriptor);
092: }
093: }
094:
095: public void withAllEntityReferencesDo(EntityReferenceAction action) {
096: super .withAllEntityReferencesDo(action);
097: if (_descriptor != null && _descriptorKind != null) {
098: action.perform(_descriptorKind, _descriptor);
099: }
100: }
101:
102: public void accept(WSDLDocumentVisitor visitor) throws Exception {
103: visitor.visit(this );
104: }
105:
106: public void validateThis() {
107: if (_descriptorKind == null || _descriptor == null) {
108: failValidation("validation.missingRequiredProperty",
109: "descriptor");
110: } else if (_descriptor.getLocalPart().equals("")) {
111: failValidation("validation.invalidElement", _descriptor
112: .toString());
113: }
114: }
115:
116: public void setMode(Mode mode) {
117: this .mode = mode;
118: }
119:
120: public Mode getMode() {
121: return mode;
122: }
123:
124: public boolean isINOUT() {
125: if (mode != null)
126: return (mode == Mode.INOUT);
127: return false;
128: }
129:
130: public boolean isIN() {
131: if (mode != null)
132: return (mode == Mode.IN);
133: return false;
134: }
135:
136: public boolean isOUT() {
137: if (mode != null)
138: return (mode == Mode.OUT);
139: return false;
140: }
141:
142: public void setReturn(boolean ret) {
143: isRet = ret;
144: }
145:
146: public boolean isReturn() {
147: return isRet;
148: }
149:
150: private boolean isRet;
151: private String _name;
152: private QName _descriptor;
153: private Kind _descriptorKind;
154: private int _bindingKind;
155:
156: private Mode mode;
157: }
|