From 625b2ce03f240ab37508e368ba6e498016bd2685 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 20 Mar 2002 23:08:22 +0000 Subject: [PATCH] Added support for null elements in the streamable array. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1142 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/presents/io/StreamableUtil.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/presents/io/StreamableUtil.java b/src/java/com/threerings/presents/io/StreamableUtil.java index 2a1cd6d21..98b0d063f 100644 --- a/src/java/com/threerings/presents/io/StreamableUtil.java +++ b/src/java/com/threerings/presents/io/StreamableUtil.java @@ -1,5 +1,5 @@ // -// $Id: StreamableUtil.java,v 1.2 2002/03/20 22:58:26 mdb Exp $ +// $Id: StreamableUtil.java,v 1.3 2002/03/20 23:08:22 mdb Exp $ package com.threerings.presents.io; @@ -100,6 +100,13 @@ public class StreamableUtil // get the next streamable to write out Streamable s = values[ii]; + // if this index is empty, write -1 as the class identifier to + // indicate such + if (s == null) { + out.writeShort(-1); + continue; + } + // look up the class id cname = s.getClass().getName(); short cidx = (short)ListUtil.indexOfEqual(cnames, cname); @@ -154,6 +161,12 @@ public class StreamableUtil // read the class id number short cidx = in.readShort(); + // if the class identifier is -1, that means this is a null + // element + if (cidx == -1) { + continue; + } + // look up the class name String cname = (cidx > cnames.length - 1) ? null : (String)cnames[cidx];