Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

xmlencoder/decoder persistence delegate

Thread view: 
slightlykirix - 11 Oct 2005 21:02 GMT
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 - 11 Oct 2005 23:10 GMT
>which do not have no-argument constructors.

Why not give them private no-arg constructors?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

slightlykirix - 12 Oct 2005 17:40 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.