Thu, 31 Aug 2017 15:18:52 +0800
merge
1 /*
2 * Copyright (c) 1997, 2013, 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 */
26 package com.sun.tools.internal.ws.wsdl.document;
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 org.xml.sax.Locator;
33 import javax.xml.namespace.QName;
35 /**
36 * Entity corresponding to the "fault" child element of a port type operation.
37 *
38 * @author WS Development Team
39 */
40 public class Fault extends Entity implements TWSDLExtensible {
42 public Fault(Locator locator) {
43 super(locator);
44 _helper = new ExtensibilityHelper();
45 }
47 public String getName() {
48 return _name;
49 }
51 public void setName(String name) {
52 _name = name;
53 }
55 public QName getMessage() {
56 return _message;
57 }
59 public void setMessage(QName n) {
60 _message = n;
61 }
63 public Message resolveMessage(AbstractDocument document) {
64 return (Message) document.find(Kinds.MESSAGE, _message);
65 }
67 @Override
68 public QName getElementName() {
69 return WSDLConstants.QNAME_FAULT;
70 }
72 public Documentation getDocumentation() {
73 return _documentation;
74 }
76 public void setDocumentation(Documentation d) {
77 _documentation = d;
78 }
80 @Override
81 public void withAllQNamesDo(QNameAction action) {
82 if (_message != null) {
83 action.perform(_message);
84 }
85 }
87 @Override
88 public void withAllEntityReferencesDo(EntityReferenceAction action) {
89 super.withAllEntityReferencesDo(action);
90 if (_message != null) {
91 action.perform(Kinds.MESSAGE, _message);
92 }
93 }
95 public void accept(WSDLDocumentVisitor visitor) throws Exception {
96 visitor.preVisit(this);
97 visitor.postVisit(this);
98 }
100 @Override
101 public void validateThis() {
102 if (_name == null) {
103 failValidation("validation.missingRequiredAttribute", "name");
104 }
105 if (_message == null) {
106 failValidation("validation.missingRequiredAttribute", "message");
107 }
108 }
110 private Documentation _documentation;
111 private String _name;
112 private QName _message;
113 private String _action;
114 private ExtensibilityHelper _helper;
116 @Override
117 public String getNameValue() {
118 return getName();
119 }
121 @Override
122 public String getNamespaceURI() {
123 return (parent == null) ? null : parent.getNamespaceURI();
124 }
126 @Override
127 public QName getWSDLElementName() {
128 return getElementName();
129 }
131 /* (non-Javadoc)
132 * @see TWSDLExtensible#addExtension(ExtensionImpl)
133 */
134 @Override
135 public void addExtension(TWSDLExtension e) {
136 _helper.addExtension(e);
138 }
140 /* (non-Javadoc)
141 * @see TWSDLExtensible#extensions()
142 */
143 @Override
144 public Iterable<TWSDLExtension> extensions() {
145 return _helper.extensions();
146 }
148 @Override
149 public TWSDLExtensible getParent() {
150 return parent;
151 }
154 public void setParent(TWSDLExtensible parent) {
155 this.parent = parent;
156 }
158 private TWSDLExtensible parent;
160 public String getAction() {
161 return _action;
162 }
164 public void setAction(String _action) {
165 this._action = _action;
166 }
167 }