KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > clientapi > StubSupporter


1 package org.apache.axis2.clientapi;
2
3 import org.apache.axis2.om.OMElement;
4 import org.apache.axis2.om.OMFactory;
5 import org.apache.axis2.om.OMNamespace;
6
7 /*
8  * Copyright 2004,2005 The Apache Software Foundation.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * A utility class for the use of the stub
23  * Not visible outside
24  */

25 class StubSupporter {
26
27     public static OMElement createRPCMappedElement(String JavaDoc elementName,OMNamespace ns,Object JavaDoc value, OMFactory fac){
28        OMElement returnElement = fac.createOMElement(elementName,ns);
29        Class JavaDoc inputParamClass = value.getClass();
30
31        if (inputParamClass.equals(String JavaDoc.class)){
32            returnElement.addChild(fac.createText(returnElement,value.toString()));
33        }else if (inputParamClass.equals(Integer JavaDoc.class)){
34             returnElement.addChild(fac.createText(returnElement,String.valueOf(((Integer JavaDoc)value).intValue())));
35        }else if (inputParamClass.equals(Float JavaDoc.class)){
36             returnElement.addChild(fac.createText(returnElement,String.valueOf(((Float JavaDoc)value).floatValue())));
37        }else if (inputParamClass.equals(Double JavaDoc.class)){
38             returnElement.addChild(fac.createText(returnElement,String.valueOf(((Double JavaDoc)value).doubleValue())));
39        //todo this seems to be a long list... need to complete this
40
}else if (inputParamClass.equals(OMElement.class)){
41            returnElement.addChild((OMElement)value);
42        }else{
43            returnElement.addChild(fac.createText(returnElement,value.toString()));
44        }
45         return returnElement;
46     }
47
48     public static Object JavaDoc getRPCMappedElementValue(OMElement elt, Class JavaDoc outputTypeClass){
49        Object JavaDoc outputObj = null;
50        if (outputTypeClass.equals(String JavaDoc.class)){
51            outputObj = elt.getText();
52        }else if (outputTypeClass.equals(Integer JavaDoc.class)){
53             outputObj = new Integer JavaDoc(elt.getText());
54        }else if (outputTypeClass.equals(Float JavaDoc.class)){
55             outputObj = new Float JavaDoc(elt.getText());
56        }else if (outputTypeClass.equals(Double JavaDoc.class)){
57             outputObj = new Double JavaDoc(elt.getText());
58
59        //todo this seems to be a long list... need to complete this
60

61        }else if (outputTypeClass.equals(OMElement.class)){
62            outputObj = elt;
63        }else{
64            outputObj = elt.toString();
65        }
66
67         return outputObj;
68     }
69
70 }
71
Popular Tags