commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <>
Subject [Beanutils] Determine type of bean field
Date Thu, 01 Jun 2006 18:19:28 GMT

I'm struggling a bit with something, and I think I may be making it harder
than it is.  Here's my requirement...

I need to be able to take an arbitrary bean, and given the name of a field
in it, determine whether the field is (a) a simple scalar (i.e., String
for istnance), (b) a subclass of List, (c) a subclass of Map or (d) an
array (of any type).

I've been playing with PropertyUtils.getPropertyDescriptor(), but I've
kind of gotten stumped where to go after that... I've toyed with getting
the Class from that, playing with getName() and getInterfaces(), both of
which get me close, but I'd have to do string comparisons, which isn't the
right answer I think... I've also thought of getting an instance from the
Class, then doing a simple instanceof, but of course this won't work for
Maps and Lists since they can't be instantiated.

Like I said, I think I may be over-thinking this a bit, hopefully someone
can quickly set me straight.  Also, while I suspect Beanutils will make
this easier, I don't so much care if I use it or not :)  It just seemed
the natural choice.  Thanks!

Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
AIM: fzammetti
Yahoo: fzammetti
Java Web Parts -
Supplying the wheel, so you don't have to reinvent it!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message