ArrayList,Map between AS and Java..

14 views
Skip to first unread message

CSMR

unread,
Nov 2, 2009, 7:32:50 PM11/2/09
to Merapi
Hi all

I'm trying to recreate a hashmap in AS and send it form Air to Java,
here is the code:

message.mapp = {"key1":[20","30","20"],"key2":["50","50","50"]}
message.send();

In my java code i have:

public class TestMessage extends Message {


public Map mapp= new HashMap();

}

In AS:
public var mapp:Object=new Object();

In Java, i got the value as a Map, everything it's ok, i can iterate
over the map and "see" the keys: key1 and key2, but then i'm trying to
obtain the value inside the map with the key.. i'm trying to obtain
the value as a ArrayList.. like this:

Iterator it = mapp.entrySet().iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry)it.next();
String keey = (String)e.getKey();
System.out.println(keey);//Here, everything it's ok, I
obtain the key
ArrayList arrayL= (ArrayList)mapp.get(keey); //here is when I got
the error!
}

So, my question is if it is valid/correct/permited what am i trying to
do... I don't know if I explain myself well... what do you recomend me
to do??

Regards

mglazer

unread,
Nov 3, 2009, 8:36:42 AM11/3/09
to Merapi
Can you please provide the content of the error message?

CSMR

unread,
Nov 3, 2009, 10:55:39 AM11/3/09
to Merapi
Hi mglazer,

The error message I receive is : java.lang.Object; cannot be cast to
java.util.ArrayList. But this is I don't understand, see I'm kind a
newbie, and according to me, I'm sending an ArrayList from AS, so, Is
supposed I will get an Array in Java... or at least that's what i'm
thinking, because even I declare in AS my map as Object, I read that
Object is the corresponding value from Map in Java...So if I put a
string and an array in mi object, i expect to get those values in
java.. or am I assuming wrong?? thanks for your comments.

Best Regards

Michael Glazer

unread,
Nov 3, 2009, 2:28:24 PM11/3/09
to merapi-...@googlegroups.com
First thing comes to mind is to use flash.utils.Dictionary instead of
Object...BlazeDS will properly convert it to Map...
I will play around and will post my results later...

Thanks,
Mike
--
Regards,
Michael Glazer
Bus: 770 857-0392
Cell: 347 420-1474

CSMR

unread,
Nov 3, 2009, 5:42:16 PM11/3/09
to Merapi
Thx for the tip.. I'll try that too.

Thx

On 3 nov, 13:28, Michael Glazer <migla...@gmail.com> wrote:
> First thing comes to mind is to use flash.utils.Dictionary instead of
> Object...BlazeDS will properly convert it to Map...
> I will play around and will post my results later...
>
> Thanks,
> Mike
>
Reply all
Reply to author
Forward
0 new messages