1 /* 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.tools.internal.ws.wsdl.document; 27 28 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; 29 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; 30 import com.sun.tools.internal.ws.wsdl.framework.*; 31 import com.sun.tools.internal.ws.wscompile.ErrorReceiver; 32 import com.sun.tools.internal.ws.wscompile.AbortException; 33 import com.sun.tools.internal.ws.resources.WsdlMessages; 34 import org.xml.sax.Locator; 35 36 import javax.xml.namespace.QName; 37 38 /** 39 * Entity corresponding to the "input" child element of a port type operation. 40 * 41 * @author WS Development Team 42 */ 43 public class Input extends Entity implements TWSDLExtensible { 44 45 public Input(Locator locator, ErrorReceiver errReceiver) { 46 super(locator); 47 this.errorReceiver = errReceiver; 48 _helper = new ExtensibilityHelper(); 49 } 50 51 public String getName() { 52 return _name; 53 } 54 55 public void setName(String name) { 56 _name = name; 57 } 58 59 public QName getMessage() { 60 return _message; 61 } 62 63 public void setMessage(QName n) { 64 _message = n; 65 } 66 67 public Message resolveMessage(AbstractDocument document) { 68 return (Message) document.find(Kinds.MESSAGE, _message); 69 } 70 71 public QName getElementName() { 72 return WSDLConstants.QNAME_INPUT; 73 } 74 75 public Documentation getDocumentation() { 76 return _documentation; 77 } 78 79 public void setDocumentation(Documentation d) { 80 _documentation = d; 81 } 82 83 public void withAllQNamesDo(QNameAction action) { 84 if (_message != null) { 85 action.perform(_message); 86 } 87 } 88 89 public void withAllEntityReferencesDo(EntityReferenceAction action) { 90 super.withAllEntityReferencesDo(action); 91 if (_message != null) { 92 action.perform(Kinds.MESSAGE, _message); 93 } 94 } 95 96 public void accept(WSDLDocumentVisitor visitor) throws Exception { 97 visitor.preVisit(this); 98 visitor.postVisit(this); 99 } 100 101 public void validateThis() { 102 if (_message == null) { 103 errorReceiver.error(getLocator(), WsdlMessages.VALIDATION_MISSING_REQUIRED_ATTRIBUTE("name", "wsdl:message")); 104 throw new AbortException(); 105 } 106 } 107 108 private Documentation _documentation; 109 private String _name; 110 private QName _message; 111 private String _action; 112 private ExtensibilityHelper _helper; 113 private TWSDLExtensible parent; 114 115 public void addExtension(TWSDLExtension e) { 116 _helper.addExtension(e); 117 } 118 119 public QName getWSDLElementName() { 120 return getElementName(); 121 } 122 123 public TWSDLExtensible getParent() { 124 return parent; 125 } 126 127 public void setParent(TWSDLExtensible parent) { 128 this.parent = parent; 129 } 130 131 public String getNamespaceURI() { 132 return getElementName().getNamespaceURI(); 133 } 134 135 public String getNameValue() { 136 return null; 137 } 138 139 public Iterable<? extends TWSDLExtension> extensions() { 140 return _helper.extensions(); 141 } 142 143 public String getAction() { 144 return _action; 145 } 146 147 public void setAction(String _action) { 148 this._action = _action; 149 } 150 }