Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 75869 invoked from network); 2 May 2005 17:07:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 May 2005 17:07:36 -0000 Received: (qmail 98746 invoked by uid 500); 2 May 2005 17:02:20 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 98686 invoked by uid 500); 2 May 2005 17:02:19 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 98658 invoked by uid 99); 2 May 2005 17:02:19 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 02 May 2005 10:02:18 -0700 Received: (qmail 71912 invoked by uid 1203); 2 May 2005 17:00:46 -0000 Date: 2 May 2005 17:00:46 -0000 Message-ID: <20050502170046.71911.qmail@minotaur.apache.org> From: dims@apache.org To: ws-axis-cvs@apache.org Subject: cvs commit: ws-axis/java/src/org/apache/axis/encoding/ser BeanDeserializer.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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: + // + // value1 + // value2 + // ... + // 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: - // - // value1 - // value2 - // ... - // 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