commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Plotnikov" <dmi...@apache.org>
Subject Re: [jxpath] problem with Container interface
Date Tue, 09 Mar 2004 16:08:13 GMT
I'll look into this.  I haven't tried putting a collection in a container -
it's quite possible there is a bug there.

Out of curiosity - what purpose does the container serve in your situation?
Why don't you use the contents of the container as the context object?

Thanks,

- Dmitri

----- Original Message ----- 
From: "Uwe Janner" <janner@anecon.com>
To: <commons-user@jakarta.apache.org>
Sent: Monday, March 08, 2004 1:38 PM
Subject: Re: [jxpath] problem with Container interface


> to describe my problem more precisely, i also append this test;
> i dont understand why it evaluates correcty with index [1], but not with
> index [2].
> both ctx.getValue("/a") and ctx.getValue("/b") correctly evaluate to the
> whole arraylist "[x,y]";
>
> thank you in advance for any help, uwe!
>
> public class XpathUtilTest extends TestCase {
>     public void testEval(){
>         JXPathContext ctx = JXPathContext.newContext(new MyObject());
>         // this test succeeds:
>         assertEquals("x", ctx.getValue("/a[1]"));
>         // this test fails because of:
>         // "JXPathException: No value for xpath: /a[2]"
>         assertEquals("y", ctx.getValue("/a[2]"));
>     }
>     public class MyObject implements Container{
>         Map map;
>         public MyObject(){
>             map = new HashMap();
>             map.put( "a", new ListEntry()); map.put( "b", new
ListEntry());
>         }
>         public Object getValue() {
>             return map;
>         }
>         public void setValue(Object arg0) {}
>     }
>     public class ListEntry  implements Container{
>         private List list;
>         public ListEntry(){
>             this.list = new ArrayList();
>             list.add("x"); list.add("y");
>         }
>         public Object getValue() {
>             return list;
>         }
>         public void setValue(Object arg0) {}
>     }
> }
>
>
> ---------------------------------------------------------------------
> 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