View Javadoc
1 package org.codehaus.ivory.serialize; 2 3 import java.util.HashMap; 4 import java.util.Map; 5 6 import javax.xml.namespace.QName; 7 8 import org.apache.axis.description.TypeDesc; 9 import org.apache.axis.encoding.Deserializer; 10 import org.apache.axis.encoding.ser.BeanDeserializerFactory; 11 import org.apache.axis.encoding.ser.EnumSerializer; 12 import org.apache.axis.utils.BeanPropertyDescriptor; 13 14 /*** 15 * DeserializerFactory which uses MetaBeanUtils. 16 * 17 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 18 * @since May 21, 2003 19 */ 20 public class MetadataDeserializerFactory extends BeanDeserializerFactory 21 { 22 23 public MetadataDeserializerFactory(Class javaType, QName xmlType) 24 { 25 super(javaType, xmlType); 26 } 27 28 /*** 29 * Get a list of the bean properties 30 */ 31 public static Map getProperties(Class javaType, TypeDesc typeDesc) 32 { 33 Map propertyMap = null; 34 35 if (typeDesc != null) 36 { 37 propertyMap = typeDesc.getPropertyDescriptorMap(); 38 } 39 else 40 { 41 BeanPropertyDescriptor[] pd = MetaBeanUtils.getPd(javaType, null); 42 propertyMap = new HashMap(); 43 // loop through properties and grab the names for later 44 for (int i = 0; i < pd.length; i++) 45 { 46 BeanPropertyDescriptor descriptor = pd[i]; 47 propertyMap.put(descriptor.getName(), descriptor); 48 } 49 } 50 51 return propertyMap; 52 } 53 /*** 54 * Optimize construction of a BeanDeserializer by caching the 55 * type descriptor and property map. 56 */ 57 protected Deserializer getGeneralPurpose(String mechanismType) 58 { 59 if (javaType == null || xmlType == null) 60 { 61 return super.getGeneralPurpose(mechanismType); 62 } 63 64 if (deserClass == EnumSerializer.class) 65 { 66 return super.getGeneralPurpose(mechanismType); 67 } 68 69 return new MetadataDeserializer( 70 javaType, 71 xmlType, 72 typeDesc, 73 propertyMap); 74 } 75 76 }

This page was automatically generated by Maven