XMLencoder custom

Y

Yamin

Hey all,

I'm using XML encoder for long term storage. However, I'd like to be
able to customize what is saved at runtime. Why? There are several
data structures, which can balloon the size of the file to a few
megabytes. This data is not something every user might want to save
on load. I'd like to give them the option of whether or not to encode
these particular data structures. The rest of the code is perfectly
capable to dealing with these structures set to null. They often are
null.

I was thinking the easiest way for me to do this would be as follows:
I know this is not XMLEncoder code (but java serialization type
code...but that's what I need help with :) ) I have a feeling this is
going into the realm of persistance delegates, but I really have no
idea.

private Hashtable details= null;
private void writeObject(ObjectOutputStream s) throws IOException
{
if( dontSaveDetails)
{
Hashtable detailsBackup = details;
//clear the details, so they're not saved
setDetails(new Hashtable());
s.defaultWriteObject();
//restore details for the current session
details = bckdetails;
}
else
{
s.defaultWriteObject();
}
}

Any ideas on how to put this logic into the XMLencoder world?

Thanks,

Ymain
 
Joined
Aug 29, 2011
Messages
1
Reaction score
0
Is it possible ?

Hey all,

I want to customize the XMLEncoder.
Now in the current XMLEncoder,
XML tags are generated from space(" ")and NUll (""),
I want to customize the XMLEncoder
what XML tags are not be generated from space(" ")and NUll (""),
Is it possible?
And how to do it ?

Thanks.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top