KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > wsdl > SkeletonImpl


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis.wsdl;
17
18 import javax.xml.namespace.QName JavaDoc;
19 import javax.xml.rpc.ParameterMode JavaDoc;
20 import java.util.HashMap JavaDoc;
21
22 /**
23  * Provides Base function implementation for the Skeleton interface
24  */

25 public class SkeletonImpl implements Skeleton {
26
27     /** Field table */
28     private static HashMap JavaDoc table = null;
29
30     /**
31      * Constructor
32      */

33     public SkeletonImpl() {
34
35         if (table == null) {
36             table = new HashMap JavaDoc();
37         }
38     }
39
40     /**
41      * Class MetaInfo
42      *
43      * @version %I%, %G%
44      */

45     class MetaInfo {
46
47         /** Field names */
48         QName JavaDoc[] names;
49
50         /** Field modes */
51         ParameterMode JavaDoc[] modes;
52
53         /** Field inputNamespace */
54         String JavaDoc inputNamespace;
55
56         /** Field outputNamespace */
57         String JavaDoc outputNamespace;
58
59         /** Field soapAction */
60         String JavaDoc soapAction;
61
62         /**
63          * Constructor MetaInfo
64          *
65          * @param names
66          * @param modes
67          * @param inputNamespace
68          * @param outputNamespace
69          * @param soapAction
70          */

71         MetaInfo(QName JavaDoc[] names, ParameterMode JavaDoc[] modes, String JavaDoc inputNamespace,
72                  String JavaDoc outputNamespace, String JavaDoc soapAction) {
73
74             this.names = names;
75             this.modes = modes;
76             this.inputNamespace = inputNamespace;
77             this.outputNamespace = outputNamespace;
78             this.soapAction = soapAction;
79         }
80     }
81
82     /**
83      * Add operation name and vector containing return and parameter names.
84      * The first name in the array is either the return name (which
85      * should be set to null if there is no return name)
86      *
87      * @param operation
88      * @param names
89      * @param modes
90      * @param inputNamespace
91      * @param outputNamespace
92      * @param soapAction
93      */

94     public void add(String JavaDoc operation, QName JavaDoc[] names, ParameterMode JavaDoc[] modes,
95                     String JavaDoc inputNamespace, String JavaDoc outputNamespace,
96                     String JavaDoc soapAction) {
97
98         table.put(operation,
99                 new MetaInfo(names, modes, inputNamespace, outputNamespace,
100                         soapAction));
101     }
102
103     /**
104      * Convenience method which allows passing an array of Strings which
105      * will be converted into QNames with no namespace.
106      *
107      * @param operation
108      * @param names
109      * @param modes
110      * @param inputNamespace
111      * @param outputNamespace
112      * @param soapAction
113      */

114     public void add(String JavaDoc operation, String JavaDoc[] names, ParameterMode JavaDoc[] modes,
115                     String JavaDoc inputNamespace, String JavaDoc outputNamespace,
116                     String JavaDoc soapAction) {
117
118         QName JavaDoc[] qnames = new QName JavaDoc[names.length];
119
120         for (int i = 0; i < names.length; i++) {
121             QName JavaDoc qname = new QName JavaDoc(null, names[i]);
122
123             qnames[i] = qname;
124         }
125
126         add(operation, qnames, modes, inputNamespace, outputNamespace,
127                 soapAction);
128     }
129
130     /**
131      * Used to return the name of the n-th parameter of the specified
132      * operation. Use -1 to get the return type name
133      * Returns null if problems occur or the parameter is not known.
134      *
135      * @param operationName
136      * @param n
137      * @return
138      */

139     public QName JavaDoc getParameterName(String JavaDoc operationName, int n) {
140
141         MetaInfo value = (MetaInfo) table.get(operationName);
142
143         if ((value == null) || (value.names == null)
144                 || (value.names.length <= n + 1)) {
145             return null;
146         }
147
148         return value.names[n + 1];
149     }
150
151     /**
152      * Used to return the mode of the n-th parameter of the specified
153      * operation. Use -1 to get the return mode.
154      * Returns null if problems occur or the parameter is not known.
155      *
156      * @param operationName
157      * @param n
158      * @return
159      */

160     public ParameterMode JavaDoc getParameterMode(String JavaDoc operationName, int n) {
161
162         MetaInfo value = (MetaInfo) table.get(operationName);
163
164         if ((value == null) || (value.modes == null)
165                 || (value.modes.length <= n + 1)) {
166             return null;
167         }
168
169         return value.modes[n + 1];
170     }
171
172     /**
173      * Used to return the namespace of the input clause of the given
174      * operation. Returns null if problems occur.
175      *
176      * @param operationName
177      * @return
178      */

179     public String JavaDoc getInputNamespace(String JavaDoc operationName) {
180
181         MetaInfo value = (MetaInfo) table.get(operationName);
182
183         if (value == null) {
184             return null;
185         }
186
187         return value.inputNamespace;
188     }
189
190     /**
191      * Used to return the namespace of the output clause of the given
192      * operation. Returns null if problems occur.
193      *
194      * @param operationName
195      * @return
196      */

197     public String JavaDoc getOutputNamespace(String JavaDoc operationName) {
198
199         MetaInfo value = (MetaInfo) table.get(operationName);
200
201         if (value == null) {
202             return null;
203         }
204
205         return value.outputNamespace;
206     }
207
208     /**
209      * Used to return the SOAPAction of the given operation.
210      * Returns null if problems occur.
211      *
212      * @param operationName
213      * @return
214      */

215     public String JavaDoc getSOAPAction(String JavaDoc operationName) {
216
217         MetaInfo value = (MetaInfo) table.get(operationName);
218
219         if (value == null) {
220             return null;
221         }
222
223         return value.soapAction;
224     }
225 }
226
Popular Tags