From: Godmar Back (gback@cs.utah.edu)
Date: Mon Jan 25 1999 - 21:00:58 EST
>
> Godmar,
>
> Well the new methods would be public so Sun could complain about that (after
> all there are no readObject methods which take an option string identifier).
I see.
>
> More to the point though, does being able to serialize in XML seems like a
> good idea? Also, does allowing the use of a simple tag in the serialization
> operation seems a good way to do this, and could it be useful for other
> things?
>
I don't really know.
However, what's Sun's idea of allowing for alternate forms of serialization?
For instance, what if you simply subclassed ObjectOutputStream and provided
a different writeFloat, for instance? It's not final, is it?
In that case, you would either code like:
private void writeObject(ObjectOutputStream s) throws IOException {
if (s instanceof XMLOutputStream) {
((XMLOutputStream)s).writeFloat("LOADFACTOR", loadFactor);
} else {
s.writeFloat(loadFactor);
}
...
}
or like
private void writeObject(ObjectOutputStream s) throws IOException {
s.writeXMLTag("LOADFACTOR");
s.writeFloat(loadFactor);
}
where "writeXMLTag" has an empty implementation by default.
Or like
private void writeObject(ObjectOutputStream s) throws IOException {
if (s instanceof XMLOutputStream) {
((XMLOutputStream)s).writeXMLTag("LOADFACTOR");
}
s.writeFloat(loadFactor);
}
I wouldn't have an immediate use for XML serialization, but I also cannot
exclude possible uses... You will of course need an XML parser to read
those objects in.
It's also not clear to me what would be written: would it be like
<LOADFACTOR VALUE="0.75"></LOADFACTOR>
or more like
<HASHTABLE LOADFACTOR="0.75" ...> ... </HASHTABLE>
(I don't really know XML, so I am making this up.)
On the other hand, doing this as part of the serialization may be bound
to complicate things... and serialization is hard enough to get right.
So maybe it would be a good idea to first get plain serialization working
so that we can start fixing up classes to use the proper serial forms, and
then look at more fancy things.
- Godmar
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:48 EDT