commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: [BeanUtils] Handling array creation?
Date Thu, 08 Sep 2005 19:44:38 GMT
I believe I found the problem... it looks like the line:

Class componentType = type.getComponentType();

...is superfluous because the value that is needed is gotten by the call
to PropertyUtils.getPropertyType().

What I'm seeing is that PropertyUtils.getPropertyType() returns "class
java.lang.String", which is exactly what I expect.  If I then call
isArray() on that returned Class object, if comes up false.  Then, trying
to call getComponentType() on that Class returns null, which breaks
everything after it.  So, just taking that line out seems to make it work
as expected.

I have to do a little more verification to be sure, but I know my
exceptions went away as soon as I took it out, and I can see content in
the array now, so assuming other data types aren't a problem, that does
seem to be it.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, September 8, 2005 3:27 pm, Frank W. Zammetti said:
>> The problem is the indexed setter, it confuses the BeanUtils class,
>> probably because it (in contrast to PropertyUtils) tries to convert
>> the value to the type expected by the setter method. Since you know
>> the target type already, you could use PropertyUtils instead.
>
> Could you explain how it "confuses" it?  Is it maybe just a matter of not
> having both setters (that doesn't seem right to me, but who knows??  I
> don't!)  In reality I won't always know the type of the array being set,
> it's only in this specific test case that I do, hence the reason Niall
> provided the code like this.
>
>> Tom
>
> Frank
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message