|
From: <php...@li...> - 2006-11-03 21:54:25
|
I'm using php-java-bridge-3.1.8, and have run into something really
confusing when creating
HashMaps.
I have a method in a Java class that accepts a HashMap. If I create an
empty HashMap in
php and add elements with put like this:
$h = new java("java.util.HashMap");
$h->put(0 , "Some Text");
...and pass that to my class I can get it's value with get(0) no problem.
However if I create
the HashMap in php with something like this:
$h = new java("java.util.HashMap", array(0=>"Some Text"));
...and pass that to the java class it wasn't able to get the key 0. Also,
trying to use $h->get(0)
within php didn't work either.
What I found is that the key to the resulting HashMap using the latter
syntax isn't an
Integer 0, but rather an Object of the class
php.java.bridge.Request$PhpArrayKey.
I see that creating a Vector directly from an array in a similar manner such
as:
$h = new java("java.util.Vector", array(44.6, 5, 5.6, "some string"));
...works fine, and I get elements with all the expected data types in java.
Is this the expected behavior and possible something I missed in the
documentation? It had
me going for hours. I see that there's at least one other email on the list
were someone
couldn't read a value with get()...possibly the same issue.
Thanks in advance.
Tom
_________________________________________________________________
Try the next generation of search with Windows Live Search today!
http://imagine-windowslive.com/minisites/searchlaunch/?locale=en-us&source=hmtagline
|