1 55 56 package org.jboss.axis.encoding.ser; 57 58 import org.jboss.axis.description.TypeDesc; 59 import org.jboss.axis.encoding.Deserializer; 60 import org.jboss.axis.utils.BeanPropertyDescriptor; 61 import org.jboss.axis.utils.BeanUtils; 62 import org.jboss.axis.utils.JavaUtils; 63 64 import javax.xml.namespace.QName ; 65 import java.util.HashMap ; 66 import java.util.Map ; 67 68 74 public class BeanDeserializerFactory extends BaseDeserializerFactory 75 { 76 77 80 protected TypeDesc typeDesc = null; 81 protected Map propertyMap = null; 82 83 public BeanDeserializerFactory(Class javaType, QName xmlType) 84 { 85 super(BeanDeserializer.class, xmlType, javaType); 86 87 if (JavaUtils.isEnumClass(javaType)) 90 { 91 deserClass = EnumDeserializer.class; 92 } 93 94 typeDesc = TypeDesc.getTypeDescForClass(javaType); 95 propertyMap = getProperties(javaType, typeDesc); 96 } 97 98 101 public static Map getProperties(Class javaType, TypeDesc typeDesc) 102 { 103 Map propertyMap = null; 104 105 if (typeDesc != null) 106 { 107 propertyMap = typeDesc.getPropertyDescriptorMap(); 108 } 109 else 110 { 111 BeanPropertyDescriptor[] pd = BeanUtils.getPd(javaType, null); 112 propertyMap = new HashMap (); 113 for (int i = 0; i < pd.length; i++) 115 { 116 BeanPropertyDescriptor descriptor = pd[i]; 117 propertyMap.put(descriptor.getName(), descriptor); 118 } 119 } 120 121 return propertyMap; 122 } 123 124 128 protected Deserializer getGeneralPurpose(String mechanismType) 129 { 130 if (javaType == null || xmlType == null) 131 { 132 return super.getGeneralPurpose(mechanismType); 133 } 134 135 if (deserClass == EnumDeserializer.class) 136 { 137 return super.getGeneralPurpose(mechanismType); 138 } 139 140 return new BeanDeserializer(javaType, xmlType, typeDesc, propertyMap); 141 } 142 } 143 | Popular Tags |