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 25 class StubSupporter { 26 27 public static OMElement createRPCMappedElement(String elementName,OMNamespace ns,Object value, OMFactory fac){ 28 OMElement returnElement = fac.createOMElement(elementName,ns); 29 Class inputParamClass = value.getClass(); 30 31 if (inputParamClass.equals(String .class)){ 32 returnElement.addChild(fac.createText(returnElement,value.toString())); 33 }else if (inputParamClass.equals(Integer .class)){ 34 returnElement.addChild(fac.createText(returnElement,String.valueOf(((Integer )value).intValue()))); 35 }else if (inputParamClass.equals(Float .class)){ 36 returnElement.addChild(fac.createText(returnElement,String.valueOf(((Float )value).floatValue()))); 37 }else if (inputParamClass.equals(Double .class)){ 38 returnElement.addChild(fac.createText(returnElement,String.valueOf(((Double )value).doubleValue()))); 39 }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 getRPCMappedElementValue(OMElement elt, Class outputTypeClass){ 49 Object outputObj = null; 50 if (outputTypeClass.equals(String .class)){ 51 outputObj = elt.getText(); 52 }else if (outputTypeClass.equals(Integer .class)){ 53 outputObj = new Integer (elt.getText()); 54 }else if (outputTypeClass.equals(Float .class)){ 55 outputObj = new Float (elt.getText()); 56 }else if (outputTypeClass.equals(Double .class)){ 57 outputObj = new Double (elt.getText()); 58 59 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 |