1 16 package org.apache.axis.deployment.wsdd; 17 18 import org.apache.axis.Constants; 19 import org.apache.axis.encoding.SerializationContext; 20 import org.apache.axis.utils.ClassUtils; 21 import org.apache.axis.utils.JavaUtils; 22 import org.apache.axis.utils.Messages; 23 import org.apache.axis.utils.XMLUtils; 24 import org.w3c.dom.Attr ; 25 import org.w3c.dom.Element ; 26 import org.xml.sax.helpers.AttributesImpl ; 27 28 import javax.xml.namespace.QName ; 29 import java.io.IOException ; 30 31 32 35 public class WSDDTypeMapping 36 extends WSDDElement 37 { 38 protected QName qname = null; 39 protected String serializer = null; 40 protected String deserializer = null; 41 protected QName typeQName = null; 42 protected String ref = null; 43 protected String encodingStyle = null; 44 45 49 public WSDDTypeMapping() 50 { 51 } 52 53 58 public WSDDTypeMapping(Element e) 59 throws WSDDException 60 { 61 serializer = e.getAttribute(ATTR_SERIALIZER); 62 deserializer = e.getAttribute(ATTR_DESERIALIZER); 63 Attr attrNode = e.getAttributeNode(ATTR_ENCSTYLE); 64 65 if (attrNode == null) { 66 encodingStyle = Constants.URI_DEFAULT_SOAP_ENC; 67 } else { 68 encodingStyle = attrNode.getValue(); 69 } 70 71 String qnameStr = e.getAttribute(ATTR_QNAME); 72 qname = XMLUtils.getQNameFromString(qnameStr, e); 73 74 76 String typeStr = e.getAttribute(ATTR_TYPE); 77 typeQName = XMLUtils.getQNameFromString(typeStr, e); 78 if (typeStr == null || typeStr.equals("")) { 79 typeStr = e.getAttribute(ATTR_LANG_SPEC_TYPE); 80 typeQName = XMLUtils.getQNameFromString(typeStr, e); 81 } 82 } 83 84 87 public void writeToContext(SerializationContext context) 88 throws IOException { 89 AttributesImpl attrs = new AttributesImpl (); 90 attrs.addAttribute("", ATTR_ENCSTYLE, ATTR_ENCSTYLE, "CDATA", encodingStyle); 91 attrs.addAttribute("", ATTR_SERIALIZER, ATTR_SERIALIZER, "CDATA", serializer); 92 attrs.addAttribute("", ATTR_DESERIALIZER, ATTR_DESERIALIZER, "CDATA", deserializer); 93 94 String typeStr = context.qName2String(typeQName); 95 attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE, 97 "CDATA", typeStr); 98 99 String qnameStr = context.attributeQName2String(qname); 100 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, "CDATA", qnameStr); 101 102 context.startElement(QNAME_TYPEMAPPING, attrs); 103 context.endElement(); 104 } 105 106 protected QName getElementName() { 107 return QNAME_TYPEMAPPING; 108 } 109 110 114 public String getRef() 115 { 116 return ref; 117 } 118 119 123 public void setRef(String ref) 124 { 125 this.ref = ref; 126 } 127 128 132 public String getEncodingStyle() 133 { 134 return encodingStyle; 135 } 136 137 141 public void setEncodingStyle(String es) 142 { 143 encodingStyle = es; 144 } 145 146 150 public QName getQName() 151 { 152 return qname; 153 } 154 155 159 public void setQName(QName name) 160 { 161 qname = name; 162 } 163 164 169 public Class getLanguageSpecificType() 170 throws ClassNotFoundException 171 { 172 if (typeQName != null) { 173 if (!URI_WSDD_JAVA.equals(typeQName.getNamespaceURI())) { 174 throw new ClassNotFoundException (Messages.getMessage("badTypeNamespace00", 175 typeQName.getNamespaceURI(), 176 URI_WSDD_JAVA)); 177 } 178 String loadName = JavaUtils.getLoadableClassName(typeQName.getLocalPart()); 179 if (JavaUtils.getWrapper(loadName) != null) { 180 loadName = "java.lang." + JavaUtils.getWrapper(loadName); 182 } 183 return ClassUtils.forName(loadName); 184 } 185 186 throw new ClassNotFoundException (Messages.getMessage("noTypeQName00")); 187 } 188 189 193 public void setLanguageSpecificType(Class javaType) 194 { 195 String type = javaType.getName(); 196 typeQName = new QName (URI_WSDD_JAVA, type); 197 } 198 199 204 public void setLanguageSpecificType(String javaType) 205 { 206 typeQName = new QName (URI_WSDD_JAVA, javaType); 207 } 208 209 214 public Class getSerializer() 215 throws ClassNotFoundException 216 { 217 return ClassUtils.forName(serializer); 218 } 219 220 224 public String getSerializerName() 225 { 226 return serializer; 227 } 228 232 public void setSerializer(Class ser) 233 { 234 serializer = ser.getName(); 235 } 236 237 241 public void setSerializer(String ser) 242 { 243 serializer = ser; 244 } 245 246 251 public Class getDeserializer() 252 throws ClassNotFoundException 253 { 254 return ClassUtils.forName(deserializer); 255 } 256 257 261 public String getDeserializerName() 262 { 263 return deserializer; 264 } 265 266 270 public void setDeserializer(Class deser) 271 { 272 deserializer = deser.getName(); 273 } 274 275 279 public void setDeserializer(String deser) 280 { 281 deserializer = deser; 282 } 283 } 284 285 286 287 | Popular Tags |