Old man Occam came a knockin'.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3857 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -150,24 +150,13 @@ public class ObjectInputStream extends DataInputStream
|
||||
}
|
||||
|
||||
// create an instance of the appropriate object
|
||||
_streamer = cmap.streamer;
|
||||
Object target = _streamer.createObject(this);
|
||||
_current = target;
|
||||
|
||||
// now read the instance data
|
||||
_streamer.readObject(target, this, true);
|
||||
|
||||
// and return the newly read object
|
||||
Object target = cmap.streamer.createObject(this);
|
||||
readBareObject(target, cmap.streamer);
|
||||
return target;
|
||||
|
||||
} catch (OutOfMemoryError oome) {
|
||||
throw (IOException)
|
||||
new IOException("Malformed object data").initCause(oome);
|
||||
|
||||
} finally {
|
||||
// clear out our current object references
|
||||
_current = null;
|
||||
_streamer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,12 +170,19 @@ public class ObjectInputStream extends DataInputStream
|
||||
public void readBareObject (Object object)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
try {
|
||||
// obtain the streamer for objects of this class
|
||||
_streamer = Streamer.getStreamer(object.getClass());
|
||||
_current = object;
|
||||
readBareObject(object, Streamer.getStreamer(object.getClass()));
|
||||
}
|
||||
|
||||
// now read the instance data
|
||||
/**
|
||||
* Reads an object from the input stream that was previously written
|
||||
* with {@link ObjectOutputStream#writeBareObject}.
|
||||
*/
|
||||
protected void readBareObject (Object object, Streamer streamer)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
_current = object;
|
||||
_streamer = streamer;
|
||||
try {
|
||||
_streamer.readObject(object, this, true);
|
||||
|
||||
} finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ObjectOutputStream.java,v 1.3 2004/08/27 02:12:36 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -81,11 +81,9 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
_classmap = new HashMap();
|
||||
}
|
||||
|
||||
try {
|
||||
// otherwise, look up the class mapping record
|
||||
Class sclass = object.getClass();
|
||||
ClassMapping cmap = (ClassMapping)_classmap.get(sclass);
|
||||
_current = object;
|
||||
|
||||
// create a class mapping for this class if we've not got one
|
||||
if (cmap == null) {
|
||||
@@ -113,15 +111,7 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
writeShort(cmap.code);
|
||||
}
|
||||
|
||||
// now write the instance data
|
||||
_streamer = cmap.streamer;
|
||||
_streamer.writeObject(object, this, true);
|
||||
|
||||
} finally {
|
||||
// clear out our current object references
|
||||
_current = null;
|
||||
_streamer = null;
|
||||
}
|
||||
writeBareObject(object, cmap.streamer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,16 +127,21 @@ public class ObjectOutputStream extends DataOutputStream
|
||||
public void writeBareObject (Object object)
|
||||
throws IOException
|
||||
{
|
||||
try {
|
||||
// get the streamer for objects of this type
|
||||
_streamer = Streamer.getStreamer(object.getClass());
|
||||
_current = object;
|
||||
writeBareObject(object, Streamer.getStreamer(object.getClass()));
|
||||
}
|
||||
|
||||
// now write the instance data
|
||||
_streamer.writeObject(object, this, true);
|
||||
/**
|
||||
* Write a {@link Streamable} instance without associated class metadata.
|
||||
*/
|
||||
protected void writeBareObject (Object obj, Streamer streamer)
|
||||
throws IOException
|
||||
{
|
||||
_current = obj;
|
||||
_streamer = streamer;
|
||||
try {
|
||||
_streamer.writeObject(obj, this, true);
|
||||
|
||||
} finally {
|
||||
// clear out our current object references
|
||||
_current = null;
|
||||
_streamer = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user