commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kovgan, Peter" <peter.kov...@sap.com>
Subject RE: Jxpath get object's type by path
Date Wed, 03 Jan 2007 06:33:28 GMT
Thanks Scott . You are right.

-----Original Message-----
From: Scott Heaberlin [mailto:heabdogg@gmail.com] 
Sent: ד, ינואר 03, 2007 6:27 
To: Jakarta Commons Users List
Subject: Re: Jxpath get object's type by path

I think you can access the class and name of the type as getClass() is
available on any Object.  The xpath would look like:

"./employee/address/class/name"

This should be the rough equivalent of <context
object>.getEmployee().getAddress().getClass().getName()

You could also try specifically invoking those methods in your xpath -

"getName(getClass(employee/address))"

Let's say your root-node object is a Manager object (e.g. it has the
Employee property accessible via getEmployee()):

JXPathContext myContext = JXPathContext.newContext(myManagerObject);
System.out.println("Address type: " +
myContext.getValue("./employee/address/class/name");

Hope this helps,

-Scott Heaberlin

On 1/1/07, Kovgan, Peter <peter.kovgan@sap.com> wrote:
>
>
> Hi!
> How can I  retrieve type information using jxpath?
>
> I need to determine type of element that resides in specified location.
>
>
> Something like :
>
> String addressType = <some>.getTypeByPath("/employee/address");
>
> ,so
>
> System.out.println(addressType);
>
>
> prints full qualified class name: com.myapp.Address
>
>
>
>
>
> Thanks a lot!
>
> Peter Kovgan
>
>
>

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


---------------------------------------------------------------------
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