1 57 58 package org.apache.wsif.providers; 59 60 import java.io.Externalizable ; 61 62 import javax.xml.namespace.QName ; 63 64 import org.apache.wsif.logging.Trc; 65 66 73 public class WSIFDynamicTypeMapping implements Externalizable { 74 private static final long serialVersionUID = 1L; 75 protected QName xmlType; 76 protected Class javaType; 77 78 82 public WSIFDynamicTypeMapping() { 83 xmlType = null; 84 javaType = null; 85 } 86 87 public WSIFDynamicTypeMapping(QName xmlType, Class javaType) { 88 Trc.entry(this, xmlType, javaType); 89 this.xmlType = xmlType; 90 this.javaType = javaType; 91 Trc.exit(); 92 } 93 94 public QName getXmlType() { 95 return xmlType; 96 } 97 98 public Class getJavaType() { 99 return javaType; 100 } 101 102 public String toString() { 103 return "QName:" + xmlType + " Class:" + javaType; 104 } 105 106 109 public void writeExternal(java.io.ObjectOutput out) 110 throws java.io.IOException { 111 out.writeObject(xmlType); 112 if (javaType.isPrimitive()) { 113 out.writeBoolean(true); 114 out.writeObject(javaType.getName()); 115 } else { 116 out.writeBoolean(false); 117 out.writeObject(javaType); 118 } 119 120 } 121 122 125 public void readExternal(java.io.ObjectInput in) 126 throws java.io.IOException , ClassNotFoundException { 127 xmlType = (QName ) in.readObject(); 128 boolean primitive = in.readBoolean(); 129 if (primitive) { 130 String primitiveClassName = (String ) in.readObject(); 131 if (primitiveClassName.equals("int")) 132 javaType = int.class; 133 else if (primitiveClassName.equals("float")) 134 javaType = float.class; 135 else if (primitiveClassName.equals("double")) 136 javaType = double.class; 137 else if (primitiveClassName.equals("boolean")) 138 javaType = boolean.class; 139 else if (primitiveClassName.equals("long")) 140 javaType = long.class; 141 else if (primitiveClassName.equals("short")) 142 javaType = short.class; 143 else if (primitiveClassName.equals("byte")) 144 javaType = byte.class; 145 else if (primitiveClassName.equals("void")) 146 javaType = void.class; 147 } else 148 javaType = (Class ) in.readObject(); 149 } 150 } | Popular Tags |