001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.webservices;
018    
019    import java.util.ArrayList;
020    import java.util.HashMap;
021    
022    public class WebServiceDescription {
023        private String webServiceDescriptionName;
024        private String wsdlFile;
025        private String jaxrpcMappingFile;
026    
027        /**
028         * List of PortComponent objects
029         *
030         * @see org.apache.geronimo.webservices.PortComponent
031         */
032        private ArrayList portComponentList = new ArrayList();
033        /**
034         * Map of PortComponent objects indexed by portComponentName
035         *
036         * @see org.apache.geronimo.webservices.PortComponent#getPortComponentName
037         */
038        private HashMap portComponentMap = new HashMap();
039    
040        public String getWebServiceDescriptionName() {
041            return webServiceDescriptionName;
042        }
043    
044        public void setWebServiceDescriptionName(String webServiceDescriptionName) {
045            this.webServiceDescriptionName = webServiceDescriptionName;
046        }
047    
048        public String getWsdlFile() {
049            return wsdlFile;
050        }
051    
052        public void setWsdlFile(String wsdlFile) {
053            this.wsdlFile = wsdlFile;
054        }
055    
056        public String getJaxrpcMappingFile() {
057            return jaxrpcMappingFile;
058        }
059    
060        public void setJaxrpcMappingFile(String jaxrpcMappingFile) {
061            this.jaxrpcMappingFile = jaxrpcMappingFile;
062        }
063    
064        public void addPortComponent(PortComponent portComponent) throws IndexOutOfBoundsException {
065            portComponentList.add(portComponent);
066            portComponentMap.put(portComponent.getPortComponentName(), portComponent);
067        }
068    
069        public void addPortComponent(int index, PortComponent portComponent) throws IndexOutOfBoundsException {
070            portComponentList.add(index, portComponent);
071            portComponentMap.put(portComponent.getPortComponentName(), portComponent);
072        }
073    
074        public boolean removePortComponent(PortComponent portComponent) {
075            portComponentMap.remove(portComponent.getPortComponentName());
076            return portComponentList.remove(portComponent);
077        }
078    
079        public PortComponent getPortComponent(int index) throws IndexOutOfBoundsException {
080            if ((index < 0) || (index > portComponentList.size())) {
081                throw new IndexOutOfBoundsException();
082            }
083            return (PortComponent) portComponentList.get(index);
084        }
085    
086        public PortComponent[] getPortComponent() {
087            int size = portComponentList.size();
088            PortComponent[] mArray = new PortComponent[size];
089            for (int index = 0; index < size; index++) {
090                mArray[index] = (PortComponent) portComponentList.get(index);
091            }
092            return mArray;
093        }
094    
095        public PortComponent getPortComponent(String portComponentName) {
096            return (PortComponent) portComponentMap.get(portComponentName);
097        }
098    
099        public void setPortComponent(int index, PortComponent portComponent) throws IndexOutOfBoundsException {
100            if ((index < 0) || (index > portComponentList.size())) {
101                throw new IndexOutOfBoundsException();
102            }
103            PortComponent removed = (PortComponent) portComponentList.set(index, portComponent);
104            portComponentMap.remove(removed.getPortComponentName());
105            portComponentMap.put(portComponent.getPortComponentName(), portComponent);
106        }
107    
108        public void setPortComponent(PortComponent[] portComponentArray) {
109            portComponentList.clear();
110            for (int i = 0; i < portComponentArray.length; i++) {
111                PortComponent portComponent = portComponentArray[i];
112                portComponentList.add(portComponent);
113                portComponentMap.put(portComponent.getPortComponentName(), portComponent);
114            }
115        }
116    
117        public void clearPortComponent() {
118            portComponentList.clear();
119            portComponentMap.clear();
120        }
121    
122    }