It is not always enough to merely restore the state of a serialized object. You may need to verify that the value of a field still makes sense, you may need to notify another object that this object has come into existence, or you simply may need to have the entire graph of the object available before you can finish initializing it.
For example, valid XML documents are essentially trees of elements
combined with a document type definition (DTD). The DTD defines a
grammar the document must follow. The Document Object
Model (DOM) defines a means of representing XML (and HTML) documents
as instances of Java classes and interfaces, including
AttributeDefinition , and others.
An XML document could be saved as a set of these serialized objects.
In that case, when you deserialized the document, you would want to
check that the deserialized document is still valid; that is, that
the document adheres to the grammar given in the DTD. You can’t
do this until the entire document—all its elements, and its
entire DTD—has been read. There are also a number of smaller
checks you might want to perform. For instance, well-formedness
(well-formedness is a slightly less stringent requirement than
validity) requires that all entity references like
&date; be defined in the DTD. To check this,
it’s not enough to have deserialized the
EntityReference object. You must also have
deserialized the corresponding