9bafa5e7c8
anything up! git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5090 542714f4-19e9-0310-aa3c-eee0fc999fb1
47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
//
|
|
// $Id$
|
|
|
|
package com.threerings.io;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
|
|
/**
|
|
* The counterpart of {@link UnreliableObjectOutputStream}.
|
|
*/
|
|
public class UnreliableObjectInputStream extends ObjectInputStream
|
|
{
|
|
/**
|
|
* Constructs an object input stream which will read its data from the supplied source stream.
|
|
*/
|
|
public UnreliableObjectInputStream (InputStream source)
|
|
{
|
|
super(source);
|
|
}
|
|
|
|
@Override // documentation inherited
|
|
protected ClassMapping mapClass (short code, String cname)
|
|
throws IOException, ClassNotFoundException
|
|
{
|
|
// see if we already have a mapping
|
|
ClassMapping cmap = (code < _classmap.size()) ? _classmap.get(code) : null;
|
|
if (cmap != null) {
|
|
// sanity check
|
|
if (!cmap.sclass.getName().equals(cname)) {
|
|
throw new RuntimeException(
|
|
"Received mapping for class that conflicts with existing mapping " +
|
|
"[code=" + code + ", oclass=" + cmap.sclass.getName() + ", nclass=" +
|
|
cname + "]");
|
|
}
|
|
return cmap;
|
|
}
|
|
// insert null entries for missing mappings
|
|
cmap = createClassMapping(code, cname);
|
|
for (int ii = 0, nn = (code + 1) - _classmap.size(); ii < nn; ii++) {
|
|
_classmap.add(null);
|
|
}
|
|
_classmap.set(code, cmap);
|
|
return cmap;
|
|
}
|
|
}
|