Re: [jade-develop] Required to send an object of data from agents to agents as messages.


Subject: Re: [jade-develop] Required to send an object of data from agents to agents as messages.
From: Corrado Santoro (csanto@diit.unict.it)
Date: Sun Dec 01 2002 - 10:18:13 MET


Hi David,
I had a similar problem and I solved it by serializing the object into a byte
array and then encoding the array into the content slot with the Base64 class
included in the starlight utilities (Base64.jar).

I used the following code to "encode":
      ByteArrayOutputStream byte_stream = new ByteArrayOutputStream();
      ObjectOutputStream object_stream = new ObjectOutputStream(byte_stream);
      object_stream.writeObject(myObject);
      object_stream.flush();
      byte_stream.flush();
      String enCodedString = new String(
          starlight.util.Base64.encode(byte_stream.toByteArray()));

and the following code to "decode":
          ByteArrayInputStream bin = new ByteArrayInputStream(
               starlight.util.Base64.decode(contentString.toCharArray()));
          ObjectInputStream obj_in = new ObjectInputStream(bin);
          MyObject obj = (MyObject)obj_in.readObject();

I hope this will help you.

Bye,
-Corrado

Quoting David <amdawong@starhub.net.sg>:

> Hi Jaders.
>
> I am a newbie at Jade, I hope some of you guys can help me out here.
> Have an assignment due in 48 hours time!
>
> I am currently building something a simple system which consists of
> buying and selling agents.
> There is a couple of information regarding the things the seller would
> like to sell.
> For instance, his selling price per unit product, quantity of sale
> products, delivery method and stuff.
>
> I need to build this system really fast and soon and I hope I do not
> have to implement the complex
> Ontology system ( I read about it in the programmer's guide but not sure
> if it applies to me. It all seemed complex!!).
>
> The ACL message only allows a string content slot. Is there a way I can
> send this object containing the wealth of
> data pertaining to the contract/agreement ? If I can send this object
> thru the ACL message, it will be much easier
> for the other party to read the necessary infor ( ie selling price,
> quantity, delivery method.etc).
>
> Many thanks in advance.
>
> Regards
> David
>

-------------------------------------------------
This mail sent through IMP: http://www.cdc.unict.it/



This archive was generated by hypermail 2a22 : Sun Dec 01 2002 - 10:24:55 MET