diff --git a/src/java/com/threerings/presents/io/ByteFieldMarshaller.java b/src/java/com/threerings/presents/io/ByteFieldMarshaller.java new file mode 100644 index 000000000..68d09f3d6 --- /dev/null +++ b/src/java/com/threerings/presents/io/ByteFieldMarshaller.java @@ -0,0 +1,27 @@ +// +// $Id: ByteFieldMarshaller.java,v 1.1 2002/02/03 06:06:10 shaper Exp $ + +package com.threerings.presents.io; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.lang.reflect.Field; + +public class ByteFieldMarshaller implements FieldMarshaller +{ + /** This is the sort of field that we marshall. */ + public byte prototype; + + public void writeTo (DataOutputStream out, Field field, Object obj) + throws IOException, IllegalAccessException + { + out.writeByte(field.getByte(obj)); + } + + public void readFrom (DataInputStream in, Field field, Object obj) + throws IOException, IllegalAccessException + { + field.setByte(obj, in.readByte()); + } +} diff --git a/src/java/com/threerings/presents/io/FieldMarshallerRegistry.java b/src/java/com/threerings/presents/io/FieldMarshallerRegistry.java index e4f9e1a07..ccc1c53ac 100644 --- a/src/java/com/threerings/presents/io/FieldMarshallerRegistry.java +++ b/src/java/com/threerings/presents/io/FieldMarshallerRegistry.java @@ -1,5 +1,5 @@ // -// $Id: FieldMarshallerRegistry.java,v 1.11 2002/02/01 23:32:37 mdb Exp $ +// $Id: FieldMarshallerRegistry.java,v 1.12 2002/02/03 06:06:10 shaper Exp $ package com.threerings.presents.io; @@ -78,6 +78,7 @@ public class FieldMarshallerRegistry static { // register our field marshallers registerMarshaller(BooleanFieldMarshaller.class); + registerMarshaller(ByteFieldMarshaller.class); registerMarshaller(ShortFieldMarshaller.class); registerMarshaller(IntFieldMarshaller.class); registerMarshaller(LongFieldMarshaller.class);