I've been looking at BeanUtil.java and I was looking at the copy method.

given that the fieldMaps are cached in objectMap wouldn't it make more sense
to use

static protected PropertyDescriptor getPropertyDescriptor(String property, Ob
ject obj)

instead of the inner loop?

Couldn't you do a lookup for pdTo with

BeanUtil.getPropertyDescriptor(pdFrom.getName(), to);

public static void copy(Object from, Object to, boolean includeNull)
throws IllegalArgumentException
{
try
{
Object[] readParameters = new Object[0];
Object[] writeParameters = new Object[1];
PropertyDescriptor[] propertiesFrom = getPropertyDescriptors(from.getCl
ass());
PropertyDescriptor[] propertiesTo = getPropertyDescriptors(to.getClass(
));
for (int i = 0; i < propertiesFrom.length; i++)
{
PropertyDescriptor pdFrom = propertiesFrom[i];
for (int j = 0; j < propertiesTo.length; j++)
{
PropertyDescriptor pdTo = propertiesTo[j];
if (pdFrom.getName().equals(pdTo.getName()))
{
Method readMethod = pdFrom.getReadMethod();
Method writeMethod = pdTo.getWriteMethod();
if (writeMethod != null && readMethod != null)
{
writeParameters[0] = pdFrom.getReadMethod().invoke(from, re
adParameters);
if (!(!includeNull && writeParameters[0] == null))
pdTo.getWriteMethod().invoke(to, writeParameters);
}
break;
}
}
}
} catch (Exception e)
{
log.warn("Bean copy failed:"+e, e);
throw new IllegalArgumentException("Bean copy failed:" + e);
}
}



-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
allow you to extend the highest allowed 128 bit encryption to all your clients even if they use browsers that are limited to 40 bit encryption. Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to