Results 1 to 2 of 2
Thread: Serialize this!
- 12-03-2010, 12:02 AM #1Member
- Join Date
- Dec 2010
- Rep Power
Well, this may not be too "advanced" for most people, but I'm unsure how to approach it...
I have a package written by someone else whose objects I now need to serialize. The package has several classes with complex relationships (objects frequently share the same objects), lots of inheritance, and is lacking in default constructors. (It's also lacking in documentation...)
The primary object I want to serialize takes two other objects from the package as parameters. It processes up to a certain point, and then I want to store it's exact state for later use. I've taken a stab at serializing it with no luck, but lots of NullPointerExceptions.
Is there any sure-fire method for serializing complex objects like this? (For instance, making every single class serializable or something.) Do I need to add default constructors? If so, do I actually need to add logic to them, or can they be empty? Would I basically need to get a PhD in understanding this package for this to work?
I don't care too much about the cost of storing the object, just that I can get it back in the exact state.
- 12-03-2010, 02:31 AM #2
i have found a good bit of success using some serializer library, such as "SOJO" or "JSONSerializer" (both sourceforge projects). They usually work with bean pattern methods and require objects have default constructors, but are capable of serializing complex objects with nested lists and other objects very well. Where as to use java serialization is more difficult, requiring they implement serializable and you would likely need to provide your own readObject() and writeObject() methods in some of the more complex classes.
- By jeremy.wilson in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 05-19-2011, 01:44 PM
- By kreyszig in forum Advanced JavaReplies: 3Last Post: 10-15-2010, 04:03 PM
- By XmisterIS in forum New To JavaReplies: 2Last Post: 09-21-2010, 02:37 PM
- By Sandia_man in forum New To JavaReplies: 8Last Post: 08-29-2010, 04:36 AM
- By theartz in forum Advanced JavaReplies: 2Last Post: 08-16-2008, 02:39 AM