1 55 package org.jboss.axis.message; 56 57 import org.jboss.axis.description.ParameterDesc; 58 import org.jboss.axis.encoding.SerializationContext; 59 import org.jboss.axis.utils.JavaUtils; 60 import org.jboss.axis.utils.Messages; 61 import org.jboss.logging.Logger; 62 63 import javax.xml.namespace.QName ; 64 import java.io.IOException ; 65 import java.lang.reflect.Method ; 66 import java.util.ArrayList ; 67 68 73 public class RPCParam 74 { 75 private static Logger log = Logger.getLogger(RPCParam.class.getName()); 76 77 RPCElement myCall; 79 80 private transient QName qname; 81 private Object value; 83 private int countSetCalls; 85 86 private ParameterDesc paramDesc; 87 88 94 private Boolean wantXSIType = null; 95 96 private static Method valueSetMethod; 97 98 static 99 { 100 Class cls = RPCParam.class; 101 try 102 { 103 valueSetMethod = cls.getMethod("set", new Class []{Object .class}); 104 } 105 catch (NoSuchMethodException e) 106 { 107 log.error(Messages.getMessage("noValue00", "" + e)); 108 System.exit(-1); 109 } 110 } 111 112 115 public RPCParam(String name, Object value) 116 { 117 this.qname = new QName ("", name); 118 this.value = value; 119 } 120 121 public RPCParam(QName qname, Object value) 122 { 123 this.qname = qname; 124 this.value = value; 125 } 126 127 public RPCParam(String namespace, String name, Object value) 128 { 129 this.qname = new QName (namespace, name); 130 this.value = value; 131 } 132 133 public void setRPCCall(RPCElement call) 134 { 135 myCall = call; 136 } 137 138 public Object getValue() 139 { 140 return value; 141 } 142 143 public void setValue(Object newValue) 144 { 145 value = newValue; 146 } 147 148 157 public void set(Object newValue) 158 { 159 countSetCalls++; 160 if (countSetCalls == 1) 163 { 164 this.value = newValue; 165 return; 166 } 167 else if (countSetCalls == 2) 170 { 171 ArrayList list = new ArrayList (); 172 list.add(this.value); 173 this.value = list; 174 } 175 ((ArrayList )this.value).add(newValue); 177 } 178 179 public String getName() 180 { 181 return this.qname.getLocalPart(); 182 } 183 184 public QName getQName() 185 { 186 return this.qname; 187 } 188 189 public static Method getValueSetMethod() 190 { 191 return valueSetMethod; 192 } 193 194 public ParameterDesc getParamDesc() 195 { 196 return paramDesc; 197 } 198 199 public void setParamDesc(ParameterDesc paramDesc) 200 { 201 this.paramDesc = paramDesc; 202 } 203 204 public void setXSITypeGeneration(Boolean value) 205 { 206 this.wantXSIType = value; 207 } 208 209 public Boolean getXSITypeGeneration() 210 { 211 return this.wantXSIType; 212 } 213 214 public void serialize(SerializationContext context) 215 throws IOException 216 { 217 218 224 Object serValue = value; 225 226 QName xmlType = null; 227 if (paramDesc != null) 228 { 229 230 Class javaType = null; 231 232 xmlType = paramDesc.getTypeQName(); 233 if (xmlType != null) 234 { 235 javaType = context.getTypeMapping().getClassForQName(xmlType); 236 if (serValue != null && javaType != null && !javaType.isAssignableFrom(serValue.getClass())) 237 { 238 if (JavaUtils.isConvertable(serValue, javaType)) 239 serValue = JavaUtils.convert(serValue, javaType); 240 } 241 } 242 243 if (javaType == null) 244 { 245 javaType = paramDesc.getJavaType(); 246 } 247 248 if (javaType == null && value != null) 249 { 250 javaType = value.getClass(); 251 } 252 253 if (javaType != null && !javaType.equals(paramDesc.getJavaType())) 254 { 255 256 if (!(javaType.equals(JavaUtils.getHolderValueType(paramDesc.getJavaType())))) 257 { 258 wantXSIType = Boolean.TRUE; 261 } 262 } 263 } 264 265 context.serialize(qname, null, serValue, xmlType, true, wantXSIType); 270 } 271 } 272 | Popular Tags |