You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Paul DeCoursey <pa...@decoursey.net> on 2006/02/15 22:04:38 UTC

[jxpath] Question about Collections and Maps

I have a List (a Vector to be specific) that has nothing except HashMaps
in it with all sorts of values in them.. What I am trying to get is find
a fast way to get the specific HashMap that has a key with a specific
value in it.  I thought that JXPath was the way to get but it doesn't
appear to be treating the HashMaps as seperate objects.  I can find out
if one exists with the specific value, and I can set values but I cannot
set a value for a field on a HashMap with a specific value on another key...

Example:

[{ID: dude, NAME: Pen}, {ID: man, NAME: Crayon}, {ID: sir, NAME: Pencil}]

How can I set the NAME property of the Hash with the ID man?

Paul


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


Re: [jxpath] Question about Collections and Maps

Posted by Paul DeCoursey <pa...@decoursey.net>.
Never-mind... I've figured it out.  It just took some getting used to 
using more parts of XPath.  The path "/.[@ID='man']" gave me the result 
I was looking for.  It's really simple and I'm embarrassed that the 
answer escaped me for so long.

Thanks.

Paul

On Feb 15, 2006, at 3:04 PM, Paul DeCoursey wrote:

>
> I have a List (a Vector to be specific) that has nothing except 
> HashMaps
> in it with all sorts of values in them.. What I am trying to get is 
> find
> a fast way to get the specific HashMap that has a key with a specific
> value in it.  I thought that JXPath was the way to get but it doesn't
> appear to be treating the HashMaps as seperate objects.  I can find out
> if one exists with the specific value, and I can set values but I 
> cannot
> set a value for a field on a HashMap with a specific value on another 
> key...
>
> Example:
>
> [{ID: dude, NAME: Pen}, {ID: man, NAME: Crayon}, {ID: sir, NAME: 
> Pencil}]
>
> How can I set the NAME property of the Hash with the ID man?
>
> Paul
>
>
> ---------------------------------------------------------------------
> 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