[Home] [By Thread] [By Date] [Recent Entries]

  • To: xml-dev@l...
  • Subject: RE: XMLEncoder and PersistenceDelegates
  • From: Jeff Lowery <Jeff.Lowery@c...>
  • Date: Tue, 1 Jul 2003 13:45:06 -0700

Anybody here using java.beans.XMLEncoder?  I've got a class with a data
member that gets initialized to a default instance. I want to overwrite the
default instance with a persisted instance.  I thought the following
persistence delegate would do the job:

       encoder.setPersistenceDelegate(ContainerOfX.class,
           new DefaultPersistenceDelegate()
           {
                    protected void initialize(Class type, Object
oldInstance,
                                             Object newInstance, Encoder
out)
                   {
                       super.initialize(type, oldInstance, newInstance,
out);
                       out.writeStatement(new Statement(oldInstance,
                                                        "setX",
                                                        new Object[]
                                                        {
                                                            ((ContainerOfX)
oldInstance).getX()
                                                        }));
                   }
           });

Which I would expect to produce and XML-encoded setX statement in the output
file with the correct value from the original instance, but no such
statement is printed.  I've checked that out.executeStatements == true right
before the writeStatement() call, so what gives?


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member