dims 02/04/16 11:56:16
Modified: java/src/org/apache/axis/encoding/ser BeanDeserializer.java
BeanPropertyTarget.java BeanSerializer.java
SimpleDeserializer.java SimpleSerializer.java
Added: java/src/org/apache/axis/utils BeanPropertyDescriptor.java
BeanUtils.java
Removed: java/src/org/apache/axis/encoding/ser
BeanPropertyDescriptor.java
Log:
- Move Beans related code into BeanUtils under org.apache.axis.utils package
- Cleanup imports a bit
Revision Changes Path
1.19 +11 -25
xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
Index: BeanDeserializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- BeanDeserializer.java 2 Apr 2002 21:24:40 -0000 1.18
+++ BeanDeserializer.java 16 Apr 2002 18:56:16 -0000 1.19
@@ -55,36 +55,22 @@
package org.apache.axis.encoding.ser;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import javax.xml.rpc.namespace.QName;
-import java.io.IOException;
-import org.apache.axis.message.SOAPHandler;
-
-import org.apache.axis.encoding.Serializer;
-import org.apache.axis.encoding.SerializerFactory;
-import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.Deserializer;
-import org.apache.axis.encoding.DeserializerFactory;
+import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.DeserializationContext;
+import org.apache.axis.encoding.Deserializer;
import org.apache.axis.encoding.DeserializerImpl;
import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.message.SOAPHandler;
+import org.apache.axis.utils.BeanPropertyDescriptor;
import org.apache.axis.utils.JavaUtils;
-import org.apache.axis.Constants;
-import org.apache.axis.description.TypeDesc;
-
-import java.beans.IntrospectionException;
-
-import java.lang.reflect.Method;
-import java.beans.IntrospectionException;
+import org.apache.axis.utils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.ObjectStreamField;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import javax.xml.rpc.namespace.QName;
import java.io.Serializable;
-import java.util.Vector;
import java.util.HashMap;
/**
@@ -121,7 +107,7 @@
this.javaType = javaType;
this.typeDesc = typeDesc;
// Get a list of the bean properties
- BeanPropertyDescriptor[] pd = BeanSerializer.getPd(javaType);
+ BeanPropertyDescriptor[] pd = BeanUtils.getPd(javaType);
// loop through properties and grab the names for later
for (int i = 0; i < pd.length; i++) {
BeanPropertyDescriptor descriptor = pd[i];
@@ -288,7 +274,7 @@
String attrName = attributes.getLocalName(i);
// look for the attribute property
- BeanPropertyDescriptor bpd =
+ BeanPropertyDescriptor bpd =
(BeanPropertyDescriptor) propertyMap.get(fieldName);
if (bpd != null) {
if (bpd.getWriteMethod() == null ) continue ;
1.5 +4 -5
xml-axis/java/src/org/apache/axis/encoding/ser/BeanPropertyTarget.java
Index: BeanPropertyTarget.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanPropertyTarget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BeanPropertyTarget.java 26 Feb 2002 21:15:33 -0000 1.4
+++ BeanPropertyTarget.java 16 Apr 2002 18:56:16 -0000 1.5
@@ -55,13 +55,12 @@
package org.apache.axis.encoding.ser;
-import org.xml.sax.SAXException;
+import org.apache.axis.encoding.Target;
+import org.apache.axis.utils.BeanPropertyDescriptor;
+import org.apache.axis.utils.JavaUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-import java.lang.reflect.Method;
-import org.apache.axis.utils.JavaUtils;
-import org.apache.axis.encoding.Target;
+import org.xml.sax.SAXException;
/**
* Class which knows how to update a bean property
1.27 +3 -56
xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
Index: BeanSerializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- BeanSerializer.java 9 Apr 2002 23:41:12 -0000 1.26
+++ BeanSerializer.java 16 Apr 2002 18:56:16 -0000 1.27
@@ -62,7 +62,9 @@
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.encoding.Serializer;
+import org.apache.axis.utils.BeanPropertyDescriptor;
import org.apache.axis.utils.JavaUtils;
+import org.apache.axis.utils.BeanUtils;
import org.apache.axis.wsdl.fromJava.ClassRep;
import org.apache.axis.wsdl.fromJava.FieldRep;
import org.apache.axis.wsdl.fromJava.Types;
@@ -114,7 +116,7 @@
this.xmlType = xmlType;
this.javaType = javaType;
this.typeDesc = typeDesc;
- propertyDescriptor = getPd(javaType);
+ propertyDescriptor = BeanUtils.getPd(javaType);
}
/**
@@ -216,61 +218,6 @@
context.endElement();
}
- /**
- * Create a BeanPropertyDescriptor array for the indicated class.
- */
- static BeanPropertyDescriptor[] getPd(Class javaType) {
- BeanPropertyDescriptor[] pd;
- try {
- PropertyDescriptor[] rawPd =
Introspector.getBeanInfo(javaType).getPropertyDescriptors();
- pd = BeanPropertyDescriptor.processPropertyDescriptors(rawPd,javaType);
- } catch (Exception e) {
- // this should never happen
- throw new InternalException(e);
- }
- return pd;
- }
-
- /**
- * Return a list of properties in the bean which should be attributes
- */
- static Vector getBeanAttributes(Class javaType, TypeDesc typeDesc) {
- Vector ret = new Vector();
-
- if (typeDesc == null) {
- // !!! Support old-style beanAttributeNames for now
-
- // See if this object defined the 'getAttributeElements' function
- // which returns a Vector of property names that are attributes
- try {
- Method getAttributeElements =
- javaType.getMethod("getAttributeElements",
- new Class [] {});
- // get string array
- String[] array = (String[])getAttributeElements.invoke(null,
noArgs);
-
- // convert it to a Vector
- ret = new Vector(array.length);
- for (int i = 0; i < array.length; i++) {
- ret.add(array[i]);
- }
- } catch (Exception e) {
- ret.clear();
- }
- } else {
- FieldDesc [] fields = typeDesc.getFields();
- if (fields != null) {
- for (int i = 0; i < fields.length; i++) {
- FieldDesc field = fields[i];
- if (!field.isElement()) {
- ret.add(field.getFieldName());
- }
- }
- }
- }
-
- return ret;
- }
public String getMechanismType() { return Constants.AXIS_SAX; }
1.11 +17 -27
xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java
Index: SimpleDeserializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SimpleDeserializer.java 9 Apr 2002 15:41:29 -0000 1.10
+++ SimpleDeserializer.java 16 Apr 2002 18:56:16 -0000 1.11
@@ -55,36 +55,26 @@
package org.apache.axis.encoding.ser;
-import java.beans.IntrospectionException;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Vector;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.Iterator;
-
-import org.apache.axis.InternalException;
import org.apache.axis.description.TypeDesc;
+import org.apache.axis.encoding.DeserializationContext;
+import org.apache.axis.encoding.Deserializer;
+import org.apache.axis.encoding.DeserializerImpl;
+import org.apache.axis.encoding.SimpleType;
+import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.message.SOAPHandler;
+import org.apache.axis.utils.BeanPropertyDescriptor;
import org.apache.axis.utils.JavaUtils;
-
-import javax.xml.rpc.namespace.QName;
-
+import org.apache.axis.utils.BeanUtils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
-import org.apache.axis.encoding.Serializer;
-import org.apache.axis.encoding.SerializerFactory;
-import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.Deserializer;
-import org.apache.axis.encoding.DeserializerFactory;
-import org.apache.axis.encoding.DeserializationContext;
-import org.apache.axis.encoding.DeserializerImpl;
-import org.apache.axis.encoding.TypeMapping;
-import org.apache.axis.encoding.SimpleType;
+import javax.xml.rpc.namespace.QName;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
/**
* A deserializer for any simple type with a (String) constructor. Note:
@@ -118,7 +108,7 @@
// if this type is a SimpleType bean, get bean properties
if (SimpleType.class.isAssignableFrom(javaType)) {
- this.pd = BeanSerializer.getPd(javaType);
+ this.pd = BeanUtils.getPd(javaType);
// loop through properties and grab the names for later
for (int i = 0; i < pd.length; i++) {
BeanPropertyDescriptor descriptor = pd[i];
@@ -135,7 +125,7 @@
// if this type is a SimpleType bean, get bean properties
if (SimpleType.class.isAssignableFrom(javaType)) {
- this.pd = BeanSerializer.getPd(javaType);
+ this.pd = BeanUtils.getPd(javaType);
// loop through properties and grab the names for later
for (int i = 0; i < pd.length; i++) {
BeanPropertyDescriptor descriptor = pd[i];
@@ -346,7 +336,7 @@
String name = (String) entry.getKey();
Object val = entry.getValue();
- BeanPropertyDescriptor bpd =
+ BeanPropertyDescriptor bpd =
(BeanPropertyDescriptor) propertyMap.get(name);
if (bpd.getWriteMethod() == null) continue;
try {
1.10 +18 -26
xml-axis/java/src/org/apache/axis/encoding/ser/SimpleSerializer.java
Index: SimpleSerializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/SimpleSerializer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SimpleSerializer.java 28 Mar 2002 18:41:16 -0000 1.9
+++ SimpleSerializer.java 16 Apr 2002 18:56:16 -0000 1.10
@@ -55,36 +55,28 @@
package org.apache.axis.encoding.ser;
+import org.apache.axis.AxisFault;
+import org.apache.axis.Constants;
+import org.apache.axis.description.FieldDesc;
+import org.apache.axis.description.TypeDesc;
+import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.encoding.Serializer;
+import org.apache.axis.encoding.SimpleType;
+import org.apache.axis.utils.BeanPropertyDescriptor;
+import org.apache.axis.utils.JavaUtils;
+import org.apache.axis.utils.XMLUtils;
+import org.apache.axis.utils.BeanUtils;
+import org.apache.axis.wsdl.fromJava.ClassRep;
+import org.apache.axis.wsdl.fromJava.FieldRep;
+import org.apache.axis.wsdl.fromJava.Types;
+import org.w3c.dom.Element;
import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import javax.xml.rpc.namespace.QName;
import java.io.IOException;
-import java.util.Vector;
import java.lang.reflect.Method;
-import java.lang.reflect.Field;
-
-import org.apache.axis.Constants;
-import org.apache.axis.AxisFault;
-import org.apache.axis.description.TypeDesc;
-import org.apache.axis.description.FieldDesc;
-import org.apache.axis.wsdl.fromJava.Types;
-import org.apache.axis.wsdl.fromJava.ClassRep;
-import org.apache.axis.wsdl.fromJava.FieldRep;
-import org.apache.axis.wsdl.toJava.Utils;
-import org.apache.axis.utils.JavaUtils;
-import org.apache.axis.utils.XMLUtils;
-import org.apache.axis.encoding.Serializer;
-import org.apache.axis.encoding.SerializerFactory;
-import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.Deserializer;
-import org.apache.axis.encoding.DeserializerFactory;
-import org.apache.axis.encoding.DeserializationContext;
-import org.apache.axis.encoding.DeserializerImpl;
-import org.apache.axis.encoding.SimpleType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
+import java.util.Vector;
/**
* Serializer for primitives and anything simple whose value is obtained with
toString()
*
@@ -104,7 +96,7 @@
if (SimpleType.class.isAssignableFrom(javaType)) {
// get the bean properties and the list of attributes from the bean
- propertyDescriptor = BeanSerializer.getPd(javaType);
+ propertyDescriptor = BeanUtils.getPd(javaType);
typeDesc = TypeDesc.getTypeDescForClass(javaType);
}
}
@@ -115,7 +107,7 @@
if (SimpleType.class.isAssignableFrom(javaType)) {
// get the bean properties and the list of attributes from the bean
- propertyDescriptor = BeanSerializer.getPd(javaType);
+ propertyDescriptor = BeanUtils.getPd(javaType);
}
}
/**
1.1
xml-axis/java/src/org/apache/axis/utils/BeanPropertyDescriptor.java
Index: BeanPropertyDescriptor.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.utils;
import java.io.ByteArrayOutputStream;
import org.apache.axis.utils.JavaUtils;
import java.lang.reflect.Method;
import java.beans.IntrospectionException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
/**
* This class is essentially a copy of the PropertyDescriptor information, except
* that the values in it can be modified.
* @author Rich Scheuerle <[EMAIL PROTECTED]>
**/
public class BeanPropertyDescriptor
{
protected static Log log =
LogFactory.getLog(BeanPropertyDescriptor.class.getName());
private String name;
private Method getter;
private Method setter;
public BeanPropertyDescriptor(String _name, Method _getter, Method _setter) {
name = _name;
getter = _getter;
setter = _setter;
}
public Method getReadMethod() { return getter; }
public Method getWriteMethod() { return setter; }
public String getName() {return name;}
public Class getType() {return getter.getReturnType(); }
}
1.1 xml-axis/java/src/org/apache/axis/utils/BeanUtils.java
Index: BeanUtils.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.utils;
import org.apache.axis.InternalException;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.description.FieldDesc;
import java.beans.PropertyDescriptor;
import java.beans.Introspector;
import java.util.Vector;
import java.lang.reflect.Method;
public class BeanUtils {
public static final Object[] noArgs = new Object[] {}; // For convenience
/**
* Create a BeanPropertyDescriptor array for the indicated class.
*/
public static BeanPropertyDescriptor[] getPd(Class javaType) {
BeanPropertyDescriptor[] pd;
try {
PropertyDescriptor[] rawPd =
Introspector.getBeanInfo(javaType).getPropertyDescriptors();
pd = processPropertyDescriptors(rawPd,javaType);
} catch (Exception e) {
// this should never happen
throw new InternalException(e);
}
return pd;
}
/**
* Return a list of properties in the bean which should be attributes
*/
public static Vector getBeanAttributes(Class javaType, TypeDesc typeDesc) {
Vector ret = new Vector();
if (typeDesc == null) {
// !!! Support old-style beanAttributeNames for now
// See if this object defined the 'getAttributeElements' function
// which returns a Vector of property names that are attributes
try {
Method getAttributeElements =
javaType.getMethod("getAttributeElements",
new Class [] {});
// get string array
String[] array = (String[])getAttributeElements.invoke(null, noArgs);
// convert it to a Vector
ret = new Vector(array.length);
for (int i = 0; i < array.length; i++) {
ret.add(array[i]);
}
} catch (Exception e) {
ret.clear();
}
} else {
FieldDesc [] fields = typeDesc.getFields();
if (fields != null) {
for (int i = 0; i < fields.length; i++) {
FieldDesc field = fields[i];
if (!field.isElement()) {
ret.add(field.getFieldName());
}
}
}
}
return ret;
}
/**
* This method attempts to sort the property descriptors to match the
* order defined in the class. This is necessary to support
* xsd:sequence processing, which means that the serialized order of
* properties must match the xml element order. (This method assumes that the
* order of the set methods matches the xml element order...the emitter
* will always order the set methods according to the xml order.)
*
* This routine also looks for set(i, type) and get(i) methods and adjusts the
* property to use these methods instead. These methods are generated by the
* emitter for "collection" of properties (i.e. maxOccurs="unbounded" on an
element).
* JAX-RPC is silent on this issue, but web services depend on this kind of
behaviour.
* The method signatures were chosen to match bean indexed properties.
*/
public static BeanPropertyDescriptor[] processPropertyDescriptors(
PropertyDescriptor[] rawPd, Class cls) {
BeanPropertyDescriptor[] myPd = new BeanPropertyDescriptor[rawPd.length];
for (int i=0; i < rawPd.length; i++) {
myPd[i] = new BeanPropertyDescriptor(rawPd[i].getName(),
rawPd[i].getReadMethod(),
rawPd[i].getWriteMethod());
}
try {
// Create a new pd array and index into the array
int index = 0;
// Build a new pd array
// defined by the order of the get methods.
BeanPropertyDescriptor[] newPd = new
BeanPropertyDescriptor[rawPd.length];
Method[] methods = cls.getMethods();
for (int i=0; i < methods.length; i++) {
Method method = methods[i];
if (method.getName().startsWith("set")) {
boolean found = false;
for (int j=0; j < myPd.length && !found; j++) {
if (myPd[j].getWriteMethod() != null &&
myPd[j].getWriteMethod().equals(method)) {
found = true;
newPd[index] = myPd[j];
index++;
}
}
}
}
// Now if there are any additional property descriptors, add them to the
end.
if (index < myPd.length) {
for (int m=0; m < myPd.length && index < myPd.length; m++) {
boolean found = false;
for (int n=0; n < index && !found; n++) {
found = (myPd[m]==newPd[n]);
}
if (!found) {
newPd[index] = myPd[m];
index++;
}
}
}
// If newPd has same number of elements as myPd, use newPd.
if (index == myPd.length) {
myPd = newPd;
}
// Get the methods of the class and look for the special set and
// get methods for property "collections"
for (int i=0; i < methods.length; i++) {
if (methods[i].getName().startsWith("set") &&
methods[i].getParameterTypes().length == 2) {
for (int j=0; j < methods.length; j++) {
if ((methods[j].getName().startsWith("get") ||
methods[j].getName().startsWith("is")) &&
methods[j].getParameterTypes().length == 1 &&
methods[j].getReturnType() ==
methods[i].getParameterTypes()[1] &&
methods[j].getParameterTypes()[0] == int.class &&
methods[i].getParameterTypes()[0] == int.class) {
for (int k=0; k < myPd.length; k++) {
if (myPd[k].getReadMethod() != null &&
myPd[k].getWriteMethod() != null &&
myPd[k].getReadMethod().getName().equals(methods[j].getName()) &&
myPd[k].getWriteMethod().getName().equals(methods[i].getName())) {
myPd[k] = new
BeanPropertyDescriptor(myPd[k].getName(),
methods[j],
methods[i]);
}
}
}
}
}
}
} catch (Exception e) {
// Don't process Property Descriptors if problems occur
return myPd;
}
return myPd;
}
}