aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.tools.internal.ws.wsdl.document; aoqi@0: aoqi@0: import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; aoqi@0: import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; aoqi@0: import com.sun.tools.internal.ws.wsdl.framework.*; aoqi@0: import com.sun.tools.internal.ws.wscompile.ErrorReceiver; aoqi@0: import org.xml.sax.Locator; aoqi@0: aoqi@0: import javax.xml.namespace.QName; aoqi@0: import java.util.*; aoqi@0: aoqi@0: /** aoqi@0: * Entity corresponding to the "portType" WSDL element. aoqi@0: * aoqi@0: * @author WS Development Team aoqi@0: */ aoqi@0: public class PortType extends GlobalEntity implements TWSDLExtensible { aoqi@0: aoqi@0: public PortType(Defining defining, Locator locator, ErrorReceiver errReceiver) { aoqi@0: super(defining, locator, errReceiver); aoqi@0: _operations = new ArrayList(); aoqi@0: _operationKeys = new HashSet(); aoqi@0: _helper = new ExtensibilityHelper(); aoqi@0: } aoqi@0: aoqi@0: public void add(Operation operation) { aoqi@0: String key = operation.getUniqueKey(); aoqi@0: if (_operationKeys.contains(key)) aoqi@0: throw new ValidationException( aoqi@0: "validation.ambiguousName", aoqi@0: operation.getName()); aoqi@0: _operationKeys.add(key); aoqi@0: _operations.add(operation); aoqi@0: } aoqi@0: aoqi@0: public Iterator operations() { aoqi@0: return _operations.iterator(); aoqi@0: } aoqi@0: aoqi@0: public Set getOperationsNamed(String s) { aoqi@0: Set result = new HashSet(); aoqi@0: for (Iterator iter = _operations.iterator(); iter.hasNext();) { aoqi@0: Operation operation = (Operation) iter.next(); aoqi@0: if (operation.getName().equals(s)) { aoqi@0: result.add(operation); aoqi@0: } aoqi@0: } aoqi@0: return result; aoqi@0: } aoqi@0: aoqi@0: public Kind getKind() { aoqi@0: return Kinds.PORT_TYPE; aoqi@0: } aoqi@0: aoqi@0: public QName getElementName() { aoqi@0: return WSDLConstants.QNAME_PORT_TYPE; aoqi@0: } aoqi@0: aoqi@0: public Documentation getDocumentation() { aoqi@0: return _documentation; aoqi@0: } aoqi@0: aoqi@0: public void setDocumentation(Documentation d) { aoqi@0: _documentation = d; aoqi@0: } aoqi@0: aoqi@0: public void withAllSubEntitiesDo(EntityAction action) { aoqi@0: super.withAllSubEntitiesDo(action); aoqi@0: aoqi@0: for (Iterator iter = _operations.iterator(); iter.hasNext();) { aoqi@0: action.perform((Entity) iter.next()); aoqi@0: } aoqi@0: _helper.withAllSubEntitiesDo(action); aoqi@0: } aoqi@0: aoqi@0: public void accept(WSDLDocumentVisitor visitor) throws Exception { aoqi@0: visitor.preVisit(this); aoqi@0: _helper.accept(visitor); aoqi@0: for (Iterator iter = _operations.iterator(); iter.hasNext();) { aoqi@0: ((Operation) iter.next()).accept(visitor); aoqi@0: } aoqi@0: visitor.postVisit(this); aoqi@0: } aoqi@0: aoqi@0: public void validateThis() { aoqi@0: if (getName() == null) { aoqi@0: failValidation("validation.missingRequiredAttribute", "name"); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public String getNameValue() { aoqi@0: return getName(); aoqi@0: } aoqi@0: aoqi@0: public String getNamespaceURI() { aoqi@0: return getDefining().getTargetNamespaceURI(); aoqi@0: } aoqi@0: aoqi@0: public QName getWSDLElementName() { aoqi@0: return getElementName(); aoqi@0: } aoqi@0: aoqi@0: /* (non-Javadoc) aoqi@0: * @see TWSDLExtensible#addExtension(ExtensionImpl) aoqi@0: */ aoqi@0: public void addExtension(TWSDLExtension e) { aoqi@0: _helper.addExtension(e); aoqi@0: aoqi@0: } aoqi@0: aoqi@0: /* (non-Javadoc) aoqi@0: * @see TWSDLExtensible#extensions() aoqi@0: */ aoqi@0: public Iterable extensions() { aoqi@0: return _helper.extensions(); aoqi@0: } aoqi@0: aoqi@0: public TWSDLExtensible getParent() { aoqi@0: return parent; aoqi@0: } aoqi@0: aoqi@0: public void setParent(TWSDLExtensible parent) { aoqi@0: this.parent = parent; aoqi@0: } aoqi@0: aoqi@0: private TWSDLExtensible parent; aoqi@0: private Documentation _documentation; aoqi@0: private List _operations; aoqi@0: private Set _operationKeys; aoqi@0: private ExtensibilityHelper _helper; aoqi@0: }