Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
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 */
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 com.sun.tools.internal.ws.wscompile.ErrorReceiver;
32 import org.xml.sax.Locator;
34 import javax.xml.namespace.QName;
35 import java.util.*;
37 /**
38 * Entity corresponding to the "portType" WSDL element.
39 *
40 * @author WS Development Team
41 */
42 public class PortType extends GlobalEntity implements TWSDLExtensible {
44 public PortType(Defining defining, Locator locator, ErrorReceiver errReceiver) {
45 super(defining, locator, errReceiver);
46 _operations = new ArrayList();
47 _operationKeys = new HashSet();
48 _helper = new ExtensibilityHelper();
49 }
51 public void add(Operation operation) {
52 String key = operation.getUniqueKey();
53 if (_operationKeys.contains(key))
54 throw new ValidationException(
55 "validation.ambiguousName",
56 operation.getName());
57 _operationKeys.add(key);
58 _operations.add(operation);
59 }
61 public Iterator operations() {
62 return _operations.iterator();
63 }
65 public Set getOperationsNamed(String s) {
66 Set result = new HashSet();
67 for (Iterator iter = _operations.iterator(); iter.hasNext();) {
68 Operation operation = (Operation) iter.next();
69 if (operation.getName().equals(s)) {
70 result.add(operation);
71 }
72 }
73 return result;
74 }
76 public Kind getKind() {
77 return Kinds.PORT_TYPE;
78 }
80 public QName getElementName() {
81 return WSDLConstants.QNAME_PORT_TYPE;
82 }
84 public Documentation getDocumentation() {
85 return _documentation;
86 }
88 public void setDocumentation(Documentation d) {
89 _documentation = d;
90 }
92 public void withAllSubEntitiesDo(EntityAction action) {
93 super.withAllSubEntitiesDo(action);
95 for (Iterator iter = _operations.iterator(); iter.hasNext();) {
96 action.perform((Entity) iter.next());
97 }
98 _helper.withAllSubEntitiesDo(action);
99 }
101 public void accept(WSDLDocumentVisitor visitor) throws Exception {
102 visitor.preVisit(this);
103 _helper.accept(visitor);
104 for (Iterator iter = _operations.iterator(); iter.hasNext();) {
105 ((Operation) iter.next()).accept(visitor);
106 }
107 visitor.postVisit(this);
108 }
110 public void validateThis() {
111 if (getName() == null) {
112 failValidation("validation.missingRequiredAttribute", "name");
113 }
114 }
116 public String getNameValue() {
117 return getName();
118 }
120 public String getNamespaceURI() {
121 return getDefining().getTargetNamespaceURI();
122 }
124 public QName getWSDLElementName() {
125 return getElementName();
126 }
128 /* (non-Javadoc)
129 * @see TWSDLExtensible#addExtension(ExtensionImpl)
130 */
131 public void addExtension(TWSDLExtension e) {
132 _helper.addExtension(e);
134 }
136 /* (non-Javadoc)
137 * @see TWSDLExtensible#extensions()
138 */
139 public Iterable<TWSDLExtension> extensions() {
140 return _helper.extensions();
141 }
143 public TWSDLExtensible getParent() {
144 return parent;
145 }
147 public void setParent(TWSDLExtensible parent) {
148 this.parent = parent;
149 }
151 private TWSDLExtensible parent;
152 private Documentation _documentation;
153 private List _operations;
154 private Set _operationKeys;
155 private ExtensibilityHelper _helper;
156 }