commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From P.Chau...@pilz.ie
Subject Re: JXPath 1.2 - get objects by class
Date Wed, 18 Jul 2007 09:41:08 GMT
Thanks Scott.

I tried both ways but doesn't seem to work. It does return Iterator with 
one object of Boolean with false value.
Though if I give an invalid class name then it does throw an error that 
class not found.

Any suggestions?

Thanks.

- Parvez




"Scott Heaberlin" <heabdogg@gmail.com> 
17/07/2007 02:44
Please respond to
"Jakarta Commons Users List" <commons-user@jakarta.apache.org>


To
"Jakarta Commons Users List" <commons-user@jakarta.apache.org>
cc

Subject
Re: JXPath 1.2 - get objects by class






.new() will instantiate one instance.  Try using getClass() as a
pseudo property (the introspector treats this as a read-only property.
 Something along these lines:

Iterator iterator =
context.iterate("//@class=java.lang.Class.forName('com.mycompany.MyObject')");

You may even be able to get away with
"//@class/name='com.mycompany.MyObject'".

Hope this helps,

-Scott Heaberlin


On 7/16/07, P.Chauhan@pilz.ie <P.Chauhan@pilz.ie> wrote:
> Hi,
>
> Just wondering if it is possible to retrieve all objects of a specific
> class from an object tree including if they are contained somewhere in 
the
> list.
>
> Will this work
>
> Iterator iterator = context.iterate("//com.mycompany.MyObject.new()");
>
> Thanks.

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



This email is intended solely for the use of the named addressee(s). Any 
unauthorised disclosure, copying or distribution of the confidential 
information contained therein, or the taking of any action based on it, is 
prohibited. The sender disclaims any liability for the integrity of this 
email. Legally binding declarations must be in written form.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message