commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frost, Gary [IT]" <>
Subject RE: [BeanUtils] how to determine whether a class has a [nested] m etho d
Date Thu, 24 Apr 2003 00:32:59 GMT
Sure, but it would work lovely for interfaces and abstract classes, and
would therefore suit my needs.

Anyway thanks for the info


-----Original Message-----
From: robert burrell donkin
Sent: Thursday, 24 April 2003 1:40 AM
To: Jakarta Commons Users List
Subject: Re: [BeanUtils] how to determine whether a class has a [nested]
metho d

i don't think that beanutils contains anything like that at the moment.

i'd say that it should be possible to create such a validator but it would 
probably be of limited usefulness. one issue would be that it's the 
runtime type of the beans that matters for the method, not the compile 
time type.

for example, think about a bean with a property

Mammal getCritter()

Mammal might have no favouriteComposer property but Human (a Mammal 
subclass) does (let's say). so something like critter.favouriteComposer 
would be failed by a validator that used the compile time type but would 
execute successfully at runtime provided that the the runtime class was 
Human (or any other mammal with such a property).

- robert

On Tuesday, April 15, 2003, at 08:31 AM, Frost, Gary [IT] wrote:

> Hi,
> I've started looking at using beanUtils, specifically
> PropertyUtil.getProperty(someObject, someNestedString);
> I was wondering whether there is the facility in the utils to determine
> whether for a given class object (not instance) the nested method string 
> is
> valid.. That is if I have
> public class SomeBean
> 	{
> 	private SubBean subBean;
> 	public SubBean getSubBean() { return subBean; }
> 	public void setSubBean(SubBean subBean) { this.subBean = subBean; }
> 	}
> And
> public class SubBean
> 	{
> 	private Integer someInteger;
> 	public Integer getSomeInteger() { return someInteger; }
> 	public void setSomeInteger(Integer someInteger) { this.someInteger =
> someInteger; }
> 	}
> I understand that for an *instance* of SomeBean, that the Integer anInt =
> (Integer)PropertyUtil.getProperty(someInstance, "subBean.someInteger"); 
> gets
> me the appropriate value from, lovely, I mean really really handy stuff..
> Now the question is, is it possible form me to determine (upfront without 
> an
> instance os SomeBean) whether subBean.someInteger is valid.. i.e. 
> something
> like boolean hasMethod = PropertyUtil.hasMethod(SomeBean.class,
> "subBean.someInteger");
> Gary Frost
> Programmer Analyst
> CitiTech
> Level 11, 2 Park Street
> Sydney NSW Australia 2000
> Phone: 		(+612) 82251572
> Email:
> Important  Information
> This message may contain confidential or proprietary information.  If you
> are not the intended recipient, please notify the sender immediately and
> delete the message from your system.  You should not copy or use it for 
> any
> purpose, nor disclose its contents to any other person.  E-mail 
> transmission
> cannot be guaranteed to be secure or error-free.  No guarantee is made 
> that
> any attachments are virus free.  We reserve the right to monitor all 
> e-mail
> communications.
> This e-mail does not take into account your investment objectives or
> financial situation and you should obtain advice based on your own
> individual circumstances before making an investment decision
> This e-mail is made available to you in Australia by Citigroup Global
> Markets Australia Pty Limited ABN 64 003 114 832, a licensed securities
> dealer and futures broker, a Participating Organisation of the Australian
> Stock Exchange Limited and a participant of the Sydney Futures Exchange
> Limited.  In New Zealand it is made available through Citigroup Global
> Markets New Zealand Limited, a member firm of the New Zealand Stock
> Exchange.
> Although the information is believed to be reliable, we do not guarantee 
> its
> accuracy and it may be incomplete or condensed.  All opinions and 
> estimates
> constitute Citigroup's judgement at the date of issue and are subject to
> change without notice. Unless stated otherwise, pricing information is
> indicative only, subject to change and is not an offer to deal at any 
> price
> quoted.  Any reference to the terms of executed transactions is 
> preliminary
> only and subject to written confirmation.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message