XML or Serialization? Need advice!

T

Tobi Krausl

Hi!

I'm developing an application in which there's the need given to
manage some kind of status-information. Everytime the status changes
the corresponding data-structure containing the status-information
must be updated and stored in a file.

I was thinking of using Serialization and maybe a TreeMap for holding
the status-data. Using this method would allow to save/restore the
TreeMap-object pretty easily, right? However, I'm not sure whether
this is really a good solution.

An alternative to Serialization would in my opinion be to use XML
(preferred DOM). I think that I'll never need some special features
provided by XML in terms of my problem.

So I'm thinking about what kind of persistence- and storage-
mechanisms I should use?! Performance isn't an issue too, so I
wouldn't mind that XML is a little bit slower than Serialization.

What would you use and why?
If you would use XML (DOM), which Parser (Standard API, JDOM, XERCES,
DOM4J) and why?

Thank you very much,
Tobi
 
D

Davor Cengija

Hi!

I'm developing an application in which there's the need given to
manage some kind of status-information. Everytime the status changes
the corresponding data-structure containing the status-information
must be updated and stored in a file.

What would you use and why?
If you would use XML (DOM), which Parser (Standard API, JDOM, XERCES,
DOM4J) and why?

I was working on a project where some session data used to be serialized
and stored for recovery retrieval. It worked good until the need rose to
upgrade the application. Deserialization of the data generated by the older
version of out application was not possible anymore and we lost some data.

So, if you recognize yourself in similar situation you might consider using
XML. Which XML parser you use actually depends on your preferences. I like
dom4j.
 
P

Peter the Swede

During my currecnt project I have been having difficulties determining what
to use, serialization or XML. I decided to use XML when it is more flexible
and "debuggable", you get a good overview of your objects with that. I made
a mistake trying to store an object that had around 120000 integers, but it
got a littlebit to big files, now I'm using BufferedImage for that. I use
XML for basicly all my storing of data exept images and image-like objects.

Cheers, Peter
 
M

Michael Holtermann

Hi Tobi!

Am 19 Nov 2003 01:01:26 -0800 schrieb Tobi Krausl:
So I'm thinking about what kind of persistence- and storage-
mechanisms I should use?!

I'd prefer XMLEncoding. If you take a look in the api-docs Sun placed a
notice for many classes (e.g. JFrame): serialized objects won't be
compatible to future releases of Swing.

I'm not sure if this is a only-swing-related issue, but it won't make sense
to use two different storing concepts...

HTH, Michael.
 
M

Michael Borgwardt

Davor said:
I was working on a project where some session data used to be serialized
and stored for recovery retrieval. It worked good until the need rose to
upgrade the application. Deserialization of the data generated by the older
version of out application was not possible anymore and we lost some data.

Unnecessary and fixable by setting an explicit serialVersionUID.
 
M

Michael Borgwardt

Michael said:
I'd prefer XMLEncoding. If you take a look in the api-docs Sun placed a
notice for many classes (e.g. JFrame): serialized objects won't be
compatible to future releases of Swing.

I'm not sure if this is a only-swing-related issue,

It is.
but it won't make sense
to use two different storing concepts...

It doesn't make sense to serialize GUI components in the first place.
 
T

Tobi Krausl

Ok, tnx guys!
I guess that I'll use XML (JAXP and DOM) for my problem. Though it may
take longer to implement it, I guess it's worth to do it. Another
Issue I'll come across will be how to wrap my XML-based
status-handling-class as a ListModel for JList...

Tnx,
Tobi!
 
S

Stefan Tiemann

Ok, tnx guys!
I guess that I'll use XML (JAXP and DOM) for my problem. Though it may
take longer to implement it, I guess it's worth to do it. Another
Issue I'll come across will be how to wrap my XML-based
status-handling-class as a ListModel for JList...

You may want to take a look at java.beans.XMLEncoder, it could save you a
lot of work. And a status class should be easy to transfer into a bean.

Greetings
Stefan Tiemann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top