From 9cdfcd81f9ca87e35488a3ad6b5d2455dc1f2ba8 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 20 Mar 2002 23:00:11 +0000 Subject: [PATCH] Now uses StreamableUtil to marshal and unmarshal streamable arrays (which means that arrays of heterogenous types are now supported). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1141 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/io/ValueMarshaller.java | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/java/com/threerings/presents/io/ValueMarshaller.java b/src/java/com/threerings/presents/io/ValueMarshaller.java index dd5db5743..7e3707f01 100644 --- a/src/java/com/threerings/presents/io/ValueMarshaller.java +++ b/src/java/com/threerings/presents/io/ValueMarshaller.java @@ -1,5 +1,5 @@ // -// $Id: ValueMarshaller.java,v 1.10 2002/02/19 03:05:56 mdb Exp $ +// $Id: ValueMarshaller.java,v 1.11 2002/03/20 23:00:11 mdb Exp $ package com.threerings.presents.io; @@ -9,6 +9,7 @@ import java.util.HashMap; import com.samskivert.util.HashIntMap; import com.threerings.presents.io.Streamable; +import com.threerings.presents.io.StreamableUtil; /** * The value marshaller provides a mechanism for marshalling and @@ -571,38 +572,13 @@ public class ValueMarshaller public void writeValue (DataOutputStream out, Object value) throws IOException { - out.writeUTF(value.getClass().getComponentType().getName()); - Streamable[] values = (Streamable[])value; - int vlength = values.length; - out.writeInt(vlength); - for (int i = 0; i < vlength; i++) { - values[i].writeTo(out); - } + StreamableUtil.writeStreamables(out, (Streamable[])value); } public Object readValue (DataInputStream in) throws IOException { - String cname = in.readUTF(); - int vlength = in.readInt(); - - try { - Class vclass = Class.forName(cname); - Streamable[] values = (Streamable[]) - Array.newInstance(vclass, vlength); - for (int i = 0; i < vlength; i++) { - Streamable value = (Streamable)vclass.newInstance(); - value.readFrom(in); - values[i] = value; - } - return values; - - } catch (Exception e) { - throw new IOException("Unable to unmarshall streamable " + - "array [cname=" + cname + - ", length=" + vlength + - ", error=" + e + "]"); - } + return StreamableUtil.readStreamables(in); } }