commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Heaberlin" <heabd...@gmail.com>
Subject Re: Jxpath get object's type by path
Date Wed, 03 Jan 2007 04:27:06 GMT
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


Mime
View raw message