This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes XMLEncooder can serialize SimpleAttributeSet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "XMLEncooder can serialize SimpleAttributeSet?" Watch "XMLEncooder can serialize SimpleAttributeSet?" New topic
Author

XMLEncooder can serialize SimpleAttributeSet?

Steli Niculescu
Greenhorn

Joined: Jul 14, 2009
Posts: 14
I have a task in which i have to serialize with XMLEncoder an object which contains a SimpleAttributeSet attribute.
I noticed that trying to xml serialize a SimpleAttributeSet doesn't produce any output.

The API says that :
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

What does this exactly mean ?
Can i serialize SimpleAttributeSet or i have to make a HashMap to manually add the attributes?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

The warning is a standard one on Swing classes. It means they could change the properties of the class making it incompatible with older versions as far as serialization goes. This incompatibility would only be a problem if you serialized an object to permanent storage, say a file or database, then upgraded Swing, then tried to deserialize the object. Even then it would only be a problem if they actually changed the Serialization UID on the class you serialized ... that is, they actually changed the member variables it had.

That said, XMLEncoder works by encoding properties of Java Bean classes, including the Swing classes. I'm not actually sure how it works on collections classes like HashMap or SimpleAttributeSet (which contains a HashMap). You'll probably have to experiment with that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XMLEncooder can serialize SimpleAttributeSet?
 
Similar Threads
NX:why the client mode cannot update the Jtable?
Quick question - serialization
can we send swing component to server
problem in deserialization with different versions of JDK