Re: Using XMLEncoder to persist PlainDocument
- From: Roedy Green <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx>
- Date: Fri, 28 Oct 2005 21:27:52 GMT
On Fri, 28 Oct 2005 16:23:18 -0400, Dave Neuendorf <dwn@xxxxxxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :
>I'm trying to use XMLEncoder for the first time. My need is to persist a
>PlainDocument to a file. Here is the code I'm using to do this:
quoting from http://mindprod.com/jgloss/xml.html#XMLSERIALIZATION
There is another form of serialization that produces XML instead of
binary ObjectOutputStreams. It uses the java.beans.XMLEncoder class.
It does not use the Serializable interface, but writes ordinary
Objects that have JavaBean-style getter and setter methods and a
no-arg constructor. It does not persist fields, but rather properties
(in the Delphi sense, not System. setProperty), implemented with
get/set. Basically it looks for all the get methods, and calls them,
and emits a stream of tags named after the properties. To
reconstitute, XMLDecoder instantiates an Object of the class, and
calls the corresponding set methods from the values in the XML stream.
The source and target classes need not have matching code the way they
do with true serialization. Most trouble using this features comes
from thinking it behaves like ordinary serialization. They have almost
nothing in common.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.
- References:
- Using XMLEncoder to persist PlainDocument
- From: Dave Neuendorf
- Using XMLEncoder to persist PlainDocument
- Prev by Date: Using XMLEncoder to persist PlainDocument
- Next by Date: persisting dialog items
- Previous by thread: Using XMLEncoder to persist PlainDocument
- Next by thread: persisting dialog items
- Index(es):