Thanks Scott . You are right.

-----Original Message-----
From: Scott Heaberlin [mailto:[EMAIL PROTECTED] 
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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to