1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.Constants; 58 import org.jboss.axis.encoding.SerializationContext; 59 import org.jboss.axis.utils.ClassUtils; 60 import org.jboss.axis.utils.JavaUtils; 61 import org.jboss.axis.utils.Messages; 62 import org.jboss.axis.utils.XMLUtils; 63 import org.w3c.dom.Attr ; 64 import org.w3c.dom.Element ; 65 import org.xml.sax.helpers.AttributesImpl ; 66 67 import javax.xml.namespace.QName ; 68 import java.io.IOException ; 69 70 71 74 public class WSDDTypeMapping 75 extends WSDDElement 76 { 77 protected QName qname = null; 78 protected String serializer = null; 79 protected String deserializer = null; 80 protected QName typeQName = null; 81 protected String ref = null; 82 protected String encodingStyle = null; 83 84 87 public WSDDTypeMapping() 88 { 89 } 90 91 95 public WSDDTypeMapping(Element e) 96 throws WSDDException 97 { 98 serializer = e.getAttribute(ATTR_SERIALIZER); 99 deserializer = e.getAttribute(ATTR_DESERIALIZER); 100 Attr attrNode = e.getAttributeNode(ATTR_ENCSTYLE); 101 102 if (attrNode == null) 103 { 104 encodingStyle = Constants.URI_DEFAULT_SOAP_ENC; 105 } 106 else 107 { 108 encodingStyle = attrNode.getValue(); 109 } 110 111 String qnameStr = e.getAttribute(ATTR_QNAME); 112 qname = XMLUtils.getQNameFromString(qnameStr, e); 113 114 116 String typeStr = e.getAttribute(ATTR_TYPE); 117 typeQName = XMLUtils.getQNameFromString(typeStr, e); 118 if (typeStr == null || typeStr.equals("")) 119 { 120 typeStr = e.getAttribute(ATTR_LANG_SPEC_TYPE); 121 typeQName = XMLUtils.getQNameFromString(typeStr, e); 122 } 123 } 124 125 128 public void writeToContext(SerializationContext context) 129 throws IOException 130 { 131 AttributesImpl attrs = new AttributesImpl (); 132 attrs.addAttribute("", ATTR_ENCSTYLE, ATTR_ENCSTYLE, "CDATA", encodingStyle); 133 attrs.addAttribute("", ATTR_SERIALIZER, ATTR_SERIALIZER, "CDATA", serializer); 134 attrs.addAttribute("", ATTR_DESERIALIZER, ATTR_DESERIALIZER, "CDATA", deserializer); 135 136 String typeStr = context.qName2String(typeQName); 137 attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE, 139 "CDATA", typeStr); 140 141 String qnameStr = context.qName2String(qname); 142 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, "CDATA", qnameStr); 143 144 context.startElement(QNAME_TYPEMAPPING, attrs); 145 context.endElement(); 146 } 147 148 protected QName getElementName() 149 { 150 return QNAME_TYPEMAPPING; 151 } 152 153 156 public String getRef() 157 { 158 return ref; 159 } 160 161 164 public void setRef(String ref) 165 { 166 this.ref = ref; 167 } 168 169 172 public String getEncodingStyle() 173 { 174 return encodingStyle; 175 } 176 177 180 public void setEncodingStyle(String es) 181 { 182 encodingStyle = es; 183 } 184 185 188 public QName getQName() 189 { 190 return qname; 191 } 192 193 196 public void setQName(QName name) 197 { 198 qname = name; 199 } 200 201 205 public Class getLanguageSpecificType() 206 throws ClassNotFoundException 207 { 208 if (typeQName != null) 209 { 210 if (!URI_WSDD_JAVA.equals(typeQName.getNamespaceURI())) 211 { 212 throw new ClassNotFoundException (Messages.getMessage("badTypeNamespace00", 213 typeQName.getNamespaceURI(), 214 URI_WSDD_JAVA)); 215 } 216 String loadName = JavaUtils.getLoadableClassName(typeQName.getLocalPart()); 217 if (JavaUtils.getWrapper(loadName) != null) 218 { 219 } 221 return ClassUtils.forName(loadName); 222 } 223 224 throw new ClassNotFoundException (Messages.getMessage("noTypeQName00")); 225 } 226 227 232 public void setLanguageSpecificType(Class javaType) 233 { 234 String type = javaType.getName(); 235 typeQName = new QName (URI_WSDD_JAVA, type); 236 } 237 238 244 public void setLanguageSpecificType(String javaType) 245 { 246 typeQName = new QName (URI_WSDD_JAVA, javaType); 247 } 248 249 253 public Class getSerializer() 254 throws ClassNotFoundException 255 { 256 return ClassUtils.forName(serializer); 257 } 258 259 262 public String getSerializerName() 263 { 264 return serializer; 265 } 266 267 270 public void setSerializer(Class ser) 271 { 272 serializer = ser.getName(); 273 } 274 275 280 public void setSerializer(String ser) 281 { 282 serializer = ser; 283 } 284 285 289 public Class getDeserializer() 290 throws ClassNotFoundException 291 { 292 return ClassUtils.forName(deserializer); 293 } 294 295 298 public String getDeserializerName() 299 { 300 return deserializer; 301 } 302 303 306 public void setDeserializer(Class deser) 307 { 308 deserializer = deser.getName(); 309 } 310 311 316 public void setDeserializer(String deser) 317 { 318 deserializer = deser; 319 } 320 } 321 322 323 324 | Popular Tags |