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] StackOverflowError with xpath to Map object
Date Fri, 18 Mar 2005 03:07:05 GMT
Scott,

I was trying to follow your description and here's what I got:


public void testCollectionPointer() {
    List list = new ArrayList();

    Map map = new HashMap();
    map.put("KeyOne", "SomeStringOne");
    map.put("KeyTwo", "SomeStringTwo");

    Map map2 = new HashMap();
    map2.put("KeyA", "StringA");
    map2.put("KeyB", "StringB");

    map.put("KeyThree", map2);

    list.add(map);

    context = JXPathContext.newContext(list);

    System.out.println(context.getValue(".[1]/KeyOne"));
    System.out.println(context.getValue(".[1]/KeyThree/KeyA"));
    System.out.println(context.getValue(".[1]/KeyThree"));
    System.out.println(context.getValue("count(.[1]/KeyThree/*)"));
}

This printed:
   SomeStringOne
   StringA
   {KeyB=StringB, KeyA=StringA}
   2.0

What's the difference between what you do and what I do?

Regards,

- Dmitri

----- Original Message ----- 
From: "Scott Heaberlin" <heabdogg@gmail.com>
To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Thursday, March 17, 2005 6:58 PM
Subject: [JXPATH] StackOverflowError with xpath to Map object


> Hello JXPath users -
>
> Preface:  I am using JXPath release 1.2
> My object graph is as follows:
> Vector
> index[1]: Hashtable, 3 entries, all String keyed. For 2 of the entries
> the value is another String; for  one key the value is another
> Hashtable with its own String keyed values.
> index[2]: Vector, not relevant for this message.
>
> It somewhat looks as follows (I hope this looks ok in your email client)
>
> Vector
>    [1] Hashtable
>           KeyOne="SomeStringOne"
>           KeyTwo="SomeStringTwo"
>           KeyThree=Hashtable
>                    KeyA="StringA"
>                    KeyB="StringB"
>                    KeyC="StringC" ... etc
>    [2] Array
>        [1]
>        [2]
>        [3]...etc
>
>
> When I do a getValue() using the following xpaths:
>
> .[1]/KeyOne
> .[1]KeyTwo
>
> I have no problems - this works as expected.
>
> When I do a getValue() using
>
> .[1]/KeyThree/KeyA
>
> I also have no problem - the result is "StringA"
>
> When I do getValue() using ".[1]/KeyThree" I get a StackOverflowError.
>
> java.lang.StackOverflowError
>        at 
> org.apache.commons.jxpath.ri.model.beans.CollectionPointer.getValuePointer(CollectionPointer.java:98)
>        at 
> org.apache.commons.jxpath.ri.model.beans.CollectionPointer.testNode(CollectionPointer.java:202)
>        at 
> org.apache.commons.jxpath.ri.model.beans.CollectionPointer.testNode(CollectionPointer.java:202)
> ...
>
> I see dozens of lines following in the stack trace all at
> CollectionPointer.testNode(). Lots.
>
>
> It appears that when my xpath evaluates to a specific element in the
> "KeyThree" hashtable, there is no problem.  Trying to reference the
> actual "KeyThree" object itself always causes the problem.
>
> Ultimately I'm trying to perform an xpath function "size()" to receive
> the size of the inner Hashtable keyed in the outer hashtable by
> "KeyThree".  I've tried different xpaths:
> .[1]/KeyThree/*
> .[1]/KeyThree//
> .[1]/KeyThree/
>
> I've also tried writing my own static method and using xpath
> "com.mypkg.MyClass.mapSize(.[1]/KeyThree)"  but I get the same result.
> During this approach I tried having the argument to my mapSize()
> method be a Node, NodeSet, a Map, and finally ExpressionContext... but
> in the debugger I never EVER make it to my method... the
> StackOverflowError occurs before any breakpoints in my method.
>
> Am I missing something?  Is there anyway I can either A) get a direct
> reference to a non-empty hashtable in an object graph via xpath, or B)
> write an xpath query that will cause JXPath to return me the size of
> said hashtable?  I am unable to do either.
>
> Thanks in advance for any help,
>
> -- 
>
>
> -Scott
>
>
> Scott Heaberlin
>
> ---------------------------------------------------------------------
> 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