You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2006/03/16 12:43:12 UTC
svn commit: r386314 -
/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
Author: deepal
Date: Thu Mar 16 03:43:10 2006
New Revision: 386314
URL: http://svn.apache.org/viewcvs?rev=386314&view=rev
Log:
fixing 490
(I tried to apply the patch then I got few test failures so I fixed the bug getting some data from patch)
Modified:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=386314&r1=386313&r2=386314&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Thu Mar 16 03:43:10 2006
@@ -159,43 +159,66 @@
public static Object deserialize(Class beanClass, OMElement beanElement) throws AxisFault {
Object beanObj;
try {
- if (SimpleTypeMapper.isSimpleType(beanClass)) {
- return SimpleTypeMapper.getSimpleTypeObject(beanClass, beanElement);
- }
- HashMap properties = new HashMap();
- BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
- PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
- for (int i = 0; i < propDescs.length; i++) {
- PropertyDescriptor proprty = propDescs[i];
- properties.put(proprty.getName(), proprty);
- }
+ if (beanClass.isArray()) {
+ ArrayList valueList = new ArrayList();
+ Class arrayClassType = beanClass.getComponentType();
+ Iterator parts = beanElement.getChildElements();
+ OMElement omElement;
+ while (parts.hasNext()) {
+ Object objValue = parts.next();
+ if (objValue instanceof OMElement) {
+ omElement = (OMElement) objValue;
+ valueList.add(deserialize(arrayClassType, omElement));
+ }
+ }
+ return ConverterUtil.convertToArray(arrayClassType,
+ valueList);
+ } else {
+ if (SimpleTypeMapper.isSimpleType(beanClass)) {
+ return SimpleTypeMapper.getSimpleTypeObject(beanClass, beanElement);
+ }
+ HashMap properties = new HashMap();
+ BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
+ PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
+ for (int i = 0; i < propDescs.length; i++) {
+ PropertyDescriptor proprty = propDescs[i];
+ properties.put(proprty.getName(), proprty);
+ }
- beanObj = beanClass.newInstance();
- Iterator elements = beanElement.getChildren();
- while (elements.hasNext()) {
- OMElement parts = (OMElement) elements.next();
- // if parts/@href != null then need to find element with id and deserialize.
- // before that first check whether we already have it in the hashtable
- String partsLocalName = parts.getLocalName();
- PropertyDescriptor prty = (PropertyDescriptor) properties.get(partsLocalName);
- if (prty != null) {
- Class parameters = prty.getPropertyType();
- if (prty.equals("class"))
+ beanObj = beanClass.newInstance();
+ Iterator elements = beanElement.getChildren();
+ while (elements.hasNext()) {
+ OMElement parts;
+ Object objValue = elements.next();
+ if (objValue instanceof OMElement) {
+ parts = (OMElement) objValue;
+ } else {
continue;
+ }
+ // if parts/@href != null then need to find element with id and deserialize.
+ // before that first check whether we already have it in the hashtable
+ String partsLocalName = parts.getLocalName();
+ PropertyDescriptor prty = (PropertyDescriptor) properties.get(partsLocalName);
+ if (prty != null) {
+ Class parameters = prty.getPropertyType();
+ if (prty.equals("class"))
+ continue;
- Object partObj;
- if (SimpleTypeMapper.isSimpleType(parameters)) {
- partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
- } else if (SimpleTypeMapper.isArrayList(parameters)) {
- //todo : Deepal , the array handling is completely wrong , this has to be
- // improved
- partObj = SimpleTypeMapper.getArrayList((OMElement) parts.getParent(), prty.getName());
- } else {
- partObj = deserialize(parameters, parts);
+ Object partObj;
+ if (SimpleTypeMapper.isSimpleType(parameters)) {
+ partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
+ } else if (SimpleTypeMapper.isArrayList(parameters)) {
+ //todo : Deepal , the array handling is completely wrong , this has to be
+ // improved
+ partObj = SimpleTypeMapper.getArrayList((OMElement) parts.getParent(), prty.getName());
+ } else {
+ partObj = deserialize(parameters, parts);
+ }
+ Object [] parms = new Object[]{partObj};
+ prty.getWriteMethod().invoke(beanObj, parms);
}
- Object [] parms = new Object[]{partObj};
- prty.getWriteMethod().invoke(beanObj, parms);
}
+ return beanObj;
}
} catch (InstantiationException e) {
throw new AxisFault("InstantiationException : " + e);
@@ -206,7 +229,8 @@
} catch (IntrospectionException e) {
throw new AxisFault("IntrospectionException : " + e);
}
- return beanObj;
+
+
}
public static Object deserialize(Class beanClass,