xmlencoder/decoder persistence delegate  
Author Message
slightlykirix





PostPosted: 2005-10-12 4:02:00 Top

java-programmer, xmlencoder/decoder persistence delegate Hi,
I am using the xmlencoder/decoder classes to save objects, some of
which do not have no-argument constructors. I understand that one could
use something like:

String[] prop = {"param1", "param2"};
MyEncoder.setPersistenceDelegate(MyClass.class
new DefaultPersistenceDelegate(prop);

My question is, what if one has a class like:
class A{
-----
B objB = new B(C c, D d);
-----
}

class B{
-----
E objE = new E(F f, G g);
-----
}

I need to save an object of A that contains an object of B that does
not have a default constructor and B in turn needs to store an object
of E which again does not have a default constructor. Assuming that all
attributes of all classes that need to be saved do have the required
setter and getter methods, I couldn't find a way to save all those
objects because I can set the persistence delegate for only one class.
Is it possible to save all the objects?
TIA.
--Jo

 
Roedy Green





PostPosted: 2005-10-12 6:10:00 Top

java-programmer >> xmlencoder/decoder persistence delegate On 11 Oct 2005 13:02:09 -0700, "slightlykirix" <email***@***.com>
wrote or quoted :

>which do not have no-argument constructors.

Why not give them private no-arg constructors?
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
slightlykirix





PostPosted: 2005-10-13 0:40:00 Top

java-programmer >> xmlencoder/decoder persistence delegate the XMLEncoder/Decoder requires that the default constructor has public
access because that is what is called by the XMLDecoder when decoding
the xml data.
--Jo