axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/encoding/ser BeanDeserializer.java
Date Mon, 02 May 2005 17:00:46 GMT
dims        2005/05/02 10:00:46

  Modified:    java/src/org/apache/axis/encoding/ser BeanDeserializer.java
  Log:
  Clean up the accumulated junk :) fixes marshall3 failures as well.
  
  Revision  Changes    Path
  1.75      +28 -51    ws-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
  
  Index: BeanDeserializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- BeanDeserializer.java	30 Apr 2005 00:19:18 -0000	1.74
  +++ BeanDeserializer.java	2 May 2005 17:00:46 -0000	1.75
  @@ -190,13 +190,21 @@
           }  
           prevQName = elemQName;
   
  -        if (typeDesc != null) {       
  +        boolean isArray = false;
  +        QName itemQName = null;
  +        if (typeDesc != null) {
               // Lookup the name appropriately (assuming an unqualified
               // name for SOAP encoding, using the namespace otherwise)
               String fieldName = typeDesc.getFieldNameForElement(elemQName, 
                                                                  isEncoded);
               propDesc = (BeanPropertyDescriptor)propertyMap.get(fieldName);
  -            fieldDesc = typeDesc.getFieldByName(fieldName); 
  +            fieldDesc = typeDesc.getFieldByName(fieldName);
  +
  +            if (fieldDesc != null) {
  +               ElementDesc element = (ElementDesc)fieldDesc;
  +               isArray = element.isMaxOccursUnbounded();
  +               itemQName = element.getItemQName();
  +           }
           }
   
           if (propDesc == null) {
  @@ -259,17 +267,12 @@
   
           // If no xsi:type or href, check the meta-data for the field
           if (childXMLType == null && fieldDesc != null && href == null)
{
  -            if (fieldDesc instanceof ElementDesc) {
  -                ElementDesc edesc = (ElementDesc)fieldDesc;
  -                QName itemQName = edesc.getItemQName();
  -                if (itemQName != null) {
  -                    // This is actually a wrapped literal array and should be
  -                    // deserialized with the ArrayDeserializer
  -                    childXMLType = Constants.SOAP_ARRAY;
  -                    fieldType = propDesc.getActualType();
  -                } else {
  -                    childXMLType = fieldDesc.getXmlType();
  -                }
  +            childXMLType = fieldDesc.getXmlType();
  +            if (itemQName != null) {
  +                // This is actually a wrapped literal array and should be
  +                // deserialized with the ArrayDeserializer
  +                childXMLType = Constants.SOAP_ARRAY;
  +                fieldType = propDesc.getActualType();
               } else {
                   childXMLType = fieldDesc.getXmlType();
               }
  @@ -291,7 +294,7 @@
   
           // Fastpath nil checks...
           if (context.isNil(attributes)) {
  -            if (propDesc != null && propDesc.isIndexed()) {
  +            if (propDesc != null && (propDesc.isIndexed()||isArray)) {
                   if (!((dSer != null) && (dSer instanceof ArrayDeserializer))) {
                       collectionIndex++;
                       dSer.registerValueTarget(new BeanPropertyTarget(value,
  @@ -299,14 +302,6 @@
                       addChildDeserializer(dSer);
                       return (SOAPHandler)dSer;
                   }
  -            } else if (propDesc != null && fieldDesc != null && fieldDesc
instanceof ElementDesc) {
  -                if(((ElementDesc)fieldDesc).isMaxOccursUnbounded()){
  -                    collectionIndex++;
  -                    dSer.registerValueTarget(new BeanPropertyTarget(value,
  -                            propDesc, collectionIndex));
  -                    addChildDeserializer(dSer);
  -                    return (SOAPHandler)dSer;
  -                }
               }
               return null;
           }            
  @@ -322,8 +317,18 @@
               }
               dSer.registerValueTarget(constructorTarget);
           } else if (propDesc.isWriteable()) {
  +            // If this is an indexed property, and the deserializer we found
  +            // was NOT the ArrayDeserializer, this is a non-SOAP array:
  +            // <bean>
  +            //   <field>value1</field>
  +            //   <field>value2</field>
  +            // ...
  +            // In this case, we want to use the collectionIndex and make sure
  +            // the deserialized value for the child element goes into the
  +            // right place in the collection.
  +
               // Register value target
  -            if (isCollectionable(propDesc, dSer, context)) {
  +            if (itemQName != null || propDesc.isIndexed() || isArray) {
                   collectionIndex++;
                   dSer.registerValueTarget(new BeanPropertyTarget(value,
                           propDesc, collectionIndex));
  @@ -344,34 +349,6 @@
           return (SOAPHandler)dSer;
       }
   
  -    private boolean isCollectionable(BeanPropertyDescriptor propDesc, Deserializer dSer,
DeserializationContext context) {
  -        // If the property is indexed/array and the deserializer happens
  -        // to be DeserializerImpl then check the type of the class, if both
  -        // the destination class and the actual type are the same class/array
  -        // then use the BeanPropertyTarget with collectionIndex = -1
  -        if (propDesc.isIndexedOrArray() && dSer instanceof DeserializerImpl &&
  -                context.getDestinationClass() != null && propDesc.getActualType()
!= null) {
  -            if (context.getDestinationClass().equals(propDesc.getActualType()))
  -                return false;
  -        }
  -        // If this is an indexed property, and the deserializer we found
  -        // was NOT the ArrayDeserializer, this is a non-SOAP array:
  -        // <bean>
  -        //   <field>value1</field>
  -        //   <field>value2</field>
  -        // ...
  -        // In this case, we want to use the collectionIndex and make sure
  -        // the deserialized value for the child element goes into the
  -        // right place in the collection.
  -
  -        // list of deserializers that shouldn't use the indexed way to recreate the Bean
  -        boolean shouldUseArray = (!(dSer instanceof ArrayDeserializer) &&
  -                !(dSer instanceof Base64Deserializer) &&
  -                !(dSer instanceof HexDeserializer) &&
  -                !(dSer instanceof SimpleListDeserializer));
  -        return propDesc.isIndexedOrArray() &&  shouldUseArray;
  -    }
  -
       /**
        * Get a BeanPropertyDescriptor which indicates where we should
        * put extensibility elements (i.e. XML which falls under the
  
  
  

Mime
View raw message