src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/document/Definitions.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2010, 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;
    34 import java.util.*;
    36 /**
    37  * Entity corresponding to the "definitions" WSDL element.
    38  *
    39  * @author WS Development Team
    40  */
    41 public class Definitions extends Entity implements Defining, TWSDLExtensible {
    43     public Definitions(AbstractDocument document, Locator locator) {
    44         super(locator);
    45         _document = document;
    46         _bindings = new ArrayList();
    47         _imports = new ArrayList();
    48         _messages = new ArrayList();
    49         _portTypes = new ArrayList();
    50         _services = new ArrayList();
    51         _importedNamespaces = new HashSet();
    52         _helper = new ExtensibilityHelper();
    53     }
    55     public String getName() {
    56         return _name;
    57     }
    59     public void setName(String s) {
    60         _name = s;
    61     }
    63     public String getTargetNamespaceURI() {
    64         return _targetNsURI;
    65     }
    67     public void setTargetNamespaceURI(String s) {
    68         _targetNsURI = s;
    69     }
    71     public void setTypes(Types t) {
    72         _types = t;
    73     }
    75     public Types getTypes() {
    76         return _types;
    77     }
    79     public void add(Message m) {
    80         _document.define(m);
    81         _messages.add(m);
    82     }
    84     public void add(PortType p) {
    85         _document.define(p);
    86         _portTypes.add(p);
    87     }
    89     public void add(Binding b) {
    90         _document.define(b);
    91         _bindings.add(b);
    92     }
    94     public void add(Service s) {
    95         _document.define(s);
    96         _services.add(s);
    97     }
    99     public void addServiceOveride(Service s) {
   100         _services.add(s);
   101     }
   103     public void add(Import i) {
   104         _imports.add(i);
   105         _importedNamespaces.add(i.getNamespace());
   106     }
   108     public Iterator imports() {
   109         return _imports.iterator();
   110     }
   112     public Iterator messages() {
   113         return _messages.iterator();
   114     }
   116     public Iterator portTypes() {
   117         return _portTypes.iterator();
   118     }
   120     public Iterator bindings() {
   121         return _bindings.iterator();
   122     }
   124     public Iterator<Service> services() {
   125         return _services.iterator();
   126     }
   128     public String getNameValue() {
   129         return getName();
   130     }
   132     public String getNamespaceURI() {
   133         return getTargetNamespaceURI();
   134     }
   136     public QName getWSDLElementName() {
   137         return WSDLConstants.QNAME_DEFINITIONS;
   138     }
   140     public Documentation getDocumentation() {
   141         return _documentation;
   142     }
   144     public void setDocumentation(Documentation d) {
   145         _documentation = d;
   146     }
   148     public void addExtension(TWSDLExtension e) {
   149         _helper.addExtension(e);
   150     }
   152     public Iterable<TWSDLExtension> extensions() {
   153         return _helper.extensions();
   154     }
   156     /**
   157      * wsdl:definition is the root hence no parent so return null.
   158      */
   159     public TWSDLExtensible getParent() {
   160         return null;
   161     }
   163     public void withAllSubEntitiesDo(EntityAction action) {
   164         if (_types != null) {
   165             action.perform(_types);
   166         }
   167         for (Iterator iter = _messages.iterator(); iter.hasNext();) {
   168             action.perform((Entity) iter.next());
   169         }
   170         for (Iterator iter = _portTypes.iterator(); iter.hasNext();) {
   171             action.perform((Entity) iter.next());
   172         }
   173         for (Iterator iter = _bindings.iterator(); iter.hasNext();) {
   174             action.perform((Entity) iter.next());
   175         }
   176         for (Iterator iter = _services.iterator(); iter.hasNext();) {
   177             action.perform((Entity) iter.next());
   178         }
   179         for (Iterator iter = _imports.iterator(); iter.hasNext();) {
   180             action.perform((Entity) iter.next());
   181         }
   182         _helper.withAllSubEntitiesDo(action);
   183     }
   185     public void accept(WSDLDocumentVisitor visitor) throws Exception {
   186         visitor.preVisit(this);
   188         for (Iterator iter = _imports.iterator(); iter.hasNext();) {
   189             ((Import) iter.next()).accept(visitor);
   190         }
   192         if (_types != null) {
   193             _types.accept(visitor);
   194         }
   196         for (Iterator iter = _messages.iterator(); iter.hasNext();) {
   197             ((Message) iter.next()).accept(visitor);
   198         }
   199         for (Iterator iter = _portTypes.iterator(); iter.hasNext();) {
   200             ((PortType) iter.next()).accept(visitor);
   201         }
   202         for (Iterator iter = _bindings.iterator(); iter.hasNext();) {
   203             ((Binding) iter.next()).accept(visitor);
   204         }
   205         for (Iterator iter = _services.iterator(); iter.hasNext();) {
   206             ((Service) iter.next()).accept(visitor);
   207         }
   209         _helper.accept(visitor);
   210         visitor.postVisit(this);
   211     }
   213     public void validateThis() {
   214     }
   216     private AbstractDocument _document;
   217     private ExtensibilityHelper _helper;
   218     private Documentation _documentation;
   219     private String _name;
   220     private String _targetNsURI;
   221     private Types _types;
   222     private List _messages;
   223     private List _portTypes;
   224     private List _bindings;
   225     private List<Service> _services;
   226     private List _imports;
   227     private Set _importedNamespaces;
   229     public QName getElementName() {
   230         return getWSDLElementName();
   231     }
   232 }

mercurial