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
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