XMLencoder custom

Discussion in 'Java' started by Yamin, Oct 6, 2004.

  1. Yamin

    Yamin Guest

    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
     
    Yamin, Oct 6, 2004
    #1
    1. Advertising

  2. Yamin

    monder

    Joined:
    Aug 29, 2011
    Messages:
    1
    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.
     
    monder, Aug 29, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cory Musselman

    Problems with XMLEncoder and BigDecimal

    Cory Musselman, Oct 30, 2003, in forum: Java
    Replies:
    0
    Views:
    2,327
    Cory Musselman
    Oct 30, 2003
  2. Cory Musselman

    Help with errors from XMLEncoder

    Cory Musselman, Nov 3, 2003, in forum: Java
    Replies:
    1
    Views:
    509
    Michael Borgwardt
    Nov 3, 2003
  3. Chris Riesbeck

    XMLEncoder can clobber arrays

    Chris Riesbeck, Dec 18, 2003, in forum: Java
    Replies:
    7
    Views:
    2,011
    Adam Jenkins
    Dec 19, 2003
  4. Paul Kaiser
    Replies:
    1
    Views:
    609
    Chris Riesbeck
    May 24, 2004
  5. Yamin

    Solved: XMLencoder custom

    Yamin, Oct 6, 2004, in forum: Java
    Replies:
    0
    Views:
    409
    Yamin
    Oct 6, 2004
Loading...

Share This Page