Fixed up some things and added streaming translations.

I'm to the point where I need to go back to array streaming and straighten
that out.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3905 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-02 03:44:37 +00:00
parent 961f3ffdfe
commit cec3ffe59d
5 changed files with 56 additions and 7 deletions
@@ -8,6 +8,8 @@ import flash.util.IDataInput;
import com.threerings.util.ClassUtil;
import com.threerings.util.SimpleMap;
import com.threerings.presents.Log;
public class ObjectInputStream
{
public function ObjectInputStream (source :IDataInput = null)
@@ -26,6 +28,14 @@ public class ObjectInputStream
_source = source;
}
/**
* Add a translation that should be used when writing objects.
*/
public function addTranslation (oldName :String, newName :String) :void
{
_translations[oldName] = newName;
}
public function readObject () :Object
//throws IOError
{
@@ -48,6 +58,12 @@ public class ObjectInputStream
// read in the class metadata
var cname :String = readUTF();
Log.debug("read cname: " + cname);
// if we have a translation, use it
var tname :String = _translations[cname];
if (tname != null) {
cname = tname;
}
var streamer :Streamer = Streamer.getStreamerByJavaName(cname);
cmap = new ClassMapping(code, cname, streamer);
@@ -199,5 +215,9 @@ public class ObjectInputStream
/** A map of short class code to ClassMapping info. */
protected var _classMap :Array = new Array();
/** An collection of class name translations to use when unserializing
* objects. */
protected var _translations :SimpleMap = new SimpleMap();
}
}