001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.tools.ws.wsdl.document;
038:
039: import com.sun.tools.ws.wsdl.framework.Entity;
040: import com.sun.tools.ws.wsdl.framework.EntityReferenceAction;
041: import com.sun.tools.ws.wsdl.framework.Kind;
042: import com.sun.tools.ws.wsdl.framework.QNameAction;
043: import org.xml.sax.Locator;
044:
045: import javax.jws.WebParam.Mode;
046: import javax.xml.namespace.QName;
047:
048: /**
049: * Entity corresponding to a WSDL message part.
050: *
051: * @author WS Development Team
052: */
053: public class MessagePart extends Entity {
054:
055: public static final int SOAP_BODY_BINDING = 1;
056: public static final int SOAP_HEADER_BINDING = 2;
057: public static final int SOAP_HEADERFAULT_BINDING = 3;
058: public static final int SOAP_FAULT_BINDING = 4;
059: public static final int WSDL_MIME_BINDING = 5;
060: public static final int PART_NOT_BOUNDED = -1;
061:
062: public MessagePart(Locator locator) {
063: super (locator);
064: }
065:
066: public String getName() {
067: return _name;
068: }
069:
070: public void setName(String name) {
071: _name = name;
072: }
073:
074: public QName getDescriptor() {
075: return _descriptor;
076: }
077:
078: public void setDescriptor(QName n) {
079: _descriptor = n;
080: }
081:
082: public Kind getDescriptorKind() {
083: return _descriptorKind;
084: }
085:
086: public void setDescriptorKind(Kind k) {
087: _descriptorKind = k;
088: }
089:
090: public QName getElementName() {
091: return WSDLConstants.QNAME_PART;
092: }
093:
094: public int getBindingExtensibilityElementKind() {
095: return _bindingKind;
096: }
097:
098: public void setBindingExtensibilityElementKind(int kind) {
099: _bindingKind = kind;
100: }
101:
102: public void withAllQNamesDo(QNameAction action) {
103: if (_descriptor != null) {
104: action.perform(_descriptor);
105: }
106: }
107:
108: public void withAllEntityReferencesDo(EntityReferenceAction action) {
109: super .withAllEntityReferencesDo(action);
110: if (_descriptor != null && _descriptorKind != null) {
111: action.perform(_descriptorKind, _descriptor);
112: }
113: }
114:
115: public void accept(WSDLDocumentVisitor visitor) throws Exception {
116: visitor.visit(this );
117: }
118:
119: public void validateThis() {
120: if (_descriptor != null
121: && _descriptor.getLocalPart().equals("")) {
122: failValidation("validation.invalidElement", _descriptor
123: .toString());
124: }
125: }
126:
127: public void setMode(Mode mode) {
128: this .mode = mode;
129: }
130:
131: public Mode getMode() {
132: return mode;
133: }
134:
135: public boolean isINOUT() {
136: if (mode != null)
137: return (mode == Mode.INOUT);
138: return false;
139: }
140:
141: public boolean isIN() {
142: if (mode != null)
143: return (mode == Mode.IN);
144: return false;
145: }
146:
147: public boolean isOUT() {
148: if (mode != null)
149: return (mode == Mode.OUT);
150: return false;
151: }
152:
153: public void setReturn(boolean ret) {
154: isRet = ret;
155: }
156:
157: public boolean isReturn() {
158: return isRet;
159: }
160:
161: private boolean isRet;
162: private String _name;
163: private QName _descriptor;
164: private Kind _descriptorKind;
165: private int _bindingKind;
166:
167: private Mode mode;
168: }
|