Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Serialize and deserialize object to and from text (http://www.velocityreviews.com/forums/t143079-serialize-and-deserialize-object-to-and-from-text.html)

Edmond wong 04-28-2005 04:14 AM

Serialize and deserialize object to and from text
 
Hi,

I am looking for a text encoder and text decoder for object
serialization and deserialization. Any one have work on such a tool
before and can share the source code?

I have the encoder working using recursion and reflection, but I don't
have a clue on the way to use recursion and reflection to read the text
back to object. In fact, I have been trying to build the decoder and
have been stucked on the case where the object contain a collection of
objects.

The encoder I build have the following text output:

{book:Book={{name:java.lang.String="Hitchhiker
Guide"}{author:Author={{name:java.lang.String="Edm ond
Wong"}{email:java.lang.String="edmond.wong@pacbell .net"}{address:java.lang.String="123
Olive
Ave"}}}{price:double=49.99}{chapters:java.util.Vec tor={{chapter:Chapter={{no:int=1}{name:java.lang.S tring="Act
I"}}}{chapter:Chapter={{no:int=2}{name:java.lang.S tring="Act
II"}}}{chapter:Chapter={{no:int=3}{name:java.lang. String="Act III"}}}}}}}


Thanks,

Edmond

Wendy S 04-28-2005 04:56 AM

Re: Serialize and deserialize object to and from text
 
"Edmond wong" <wywong@pacbell.net> wrote

> I am looking for a text encoder and text decoder for object serialization
> and deserialization. Any one have work on such a tool before and can
> share the source code?


Serialization means binary data, doesn't it? I suppose you could base-64
encode the bytes, that would be text...

Is this homework?? I guess I'm just questioning inventing yet another
proprietary text format that you have to maintain code for.

But to answer the question, if I had to dump an object to text knowing that
I would need to reconstitute it later, I would use XML and the following
libraries from Jakarta:
http://jakarta.apache.org/commons/betwixt/ Object to XML
http://jakarta.apache.org/commons/digester/ XML to Object

--
Wendy S



Edmond wong 04-29-2005 04:21 AM

Re: Serialize and deserialize object to and from text
 
Wendy S wrote:
> "Edmond wong" <wywong@pacbell.net> wrote
>
>
>>I am looking for a text encoder and text decoder for object serialization
>>and deserialization. Any one have work on such a tool before and can
>>share the source code?

>
>
> Serialization means binary data, doesn't it? I suppose you could base-64
> encode the bytes, that would be text...
>
> Is this homework?? I guess I'm just questioning inventing yet another
> proprietary text format that you have to maintain code for.
>
> But to answer the question, if I had to dump an object to text knowing that
> I would need to reconstitute it later, I would use XML and the following
> libraries from Jakarta:
> http://jakarta.apache.org/commons/betwixt/ Object to XML
> http://jakarta.apache.org/commons/digester/ XML to Object
>


I am more looking for an text encoder and decoder. I have the encoder
working using reflection and recursion.

I probably failed to convince my colleage who is a C++ programmer and
the project lead that xml is the best choice to log message, and to
regenerate the java object from log for simulation purpose. Anyway, I
will try again to convince the lead until I figure out the trick to
finish the decoder.

Thanks,

Edmond


All times are GMT. The time now is 03:05 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.