File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes multiple serialization depths? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "multiple serialization depths?" Watch "multiple serialization depths?" New topic

multiple serialization depths?

Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
I have an application relying on serialization for persistent storage. Specifically, the app should be able to serialize at 2 different "depths" meaning that a "quick save" saves/reads only high level information while a "full save" saves the entire serializable structure of the class.
Does anyone know if this is possible - and if so, any general implementation ideas?
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
Hi surasak
Can you give more details like what kind of information you have.
I am not able to visualize that you have one object and you want to partially serialize the state in 1st step and rest of it in 2nd step. Why one would need that?
Can we model this by breaking the single object into two separate objects- ToplevelInfo and WholeInfo (which contains ref to ToplevelInfo or extends it)? This way we can control serialization of two separately.
Also, we can implement Externalization in WholeInfo object and in its serializing methods read/write External just deal with the whole info as we already serialized ToplevelInfo in some previous step...
I hope I didn't missed your question.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
When you serialise an object all underlying data is serialised as well.
You would need to override the serialisation code to make it different.

I agree. Here's the link:
subject: multiple serialization depths?
jQuery in Action, 3rd edition