Changed field marshaller registration to be compatible with DashO-style
field renaming. I'm a bad monkey for overusing reflection. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1587 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: BooleanFieldMarshaller.java,v 1.6 2002/02/01 23:32:37 mdb Exp $
|
// $Id: BooleanFieldMarshaller.java,v 1.7 2002/07/17 23:05:27 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class BooleanFieldMarshaller implements FieldMarshaller
|
public class BooleanFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public boolean prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Boolean.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ByteArrayFieldMarshaller.java,v 1.1 2002/02/07 05:27:07 mdb Exp $
|
// $Id: ByteArrayFieldMarshaller.java,v 1.2 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -11,8 +11,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class ByteArrayFieldMarshaller implements FieldMarshaller
|
public class ByteArrayFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public byte[] prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return (new byte[0]).getClass();
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ByteFieldMarshaller.java,v 1.1 2002/02/03 06:06:10 shaper Exp $
|
// $Id: ByteFieldMarshaller.java,v 1.2 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class ByteFieldMarshaller implements FieldMarshaller
|
public class ByteFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public byte prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Byte.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DSetFieldMarshaller.java,v 1.4 2002/02/01 23:32:37 mdb Exp $
|
// $Id: DSetFieldMarshaller.java,v 1.5 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -12,8 +12,11 @@ import com.threerings.presents.dobj.DSet;
|
|||||||
|
|
||||||
public class DSetFieldMarshaller implements FieldMarshaller
|
public class DSetFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public DSet prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return DSet.class;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DoubleFieldMarshaller.java,v 1.6 2002/02/01 23:32:37 mdb Exp $
|
// $Id: DoubleFieldMarshaller.java,v 1.7 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class DoubleFieldMarshaller implements FieldMarshaller
|
public class DoubleFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public double prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Double.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FieldMarshaller.java,v 1.6 2002/02/01 23:32:37 mdb Exp $
|
// $Id: FieldMarshaller.java,v 1.7 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -15,6 +15,8 @@ import java.lang.reflect.Field;
|
|||||||
*/
|
*/
|
||||||
public interface FieldMarshaller
|
public interface FieldMarshaller
|
||||||
{
|
{
|
||||||
|
public Class getFieldType ();
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException;
|
throws IOException, IllegalAccessException;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FieldMarshallerRegistry.java,v 1.15 2002/04/17 22:45:32 mdb Exp $
|
// $Id: FieldMarshallerRegistry.java,v 1.16 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ public class FieldMarshallerRegistry
|
|||||||
protected static void registerMarshaller (Class clazz)
|
protected static void registerMarshaller (Class clazz)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
_registry.put(clazz.getField("prototype").getType(),
|
FieldMarshaller fm = (FieldMarshaller)clazz.newInstance();
|
||||||
clazz.newInstance());
|
_registry.put(fm.getFieldType(), fm);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Unable to register field marshaller " +
|
Log.warning("Unable to register field marshaller " +
|
||||||
"[class=" + clazz.getName() + "].");
|
"[class=" + clazz.getName() + "].");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FloatFieldMarshaller.java,v 1.6 2002/02/01 23:32:37 mdb Exp $
|
// $Id: FloatFieldMarshaller.java,v 1.7 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class FloatFieldMarshaller implements FieldMarshaller
|
public class FloatFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public float prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Float.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IntArrayFieldMarshaller.java,v 1.3 2002/02/01 23:32:37 mdb Exp $
|
// $Id: IntArrayFieldMarshaller.java,v 1.4 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class IntArrayFieldMarshaller implements FieldMarshaller
|
public class IntArrayFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public int[] prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return (new int[0]).getClass();
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IntFieldMarshaller.java,v 1.6 2002/02/01 23:32:37 mdb Exp $
|
// $Id: IntFieldMarshaller.java,v 1.7 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class IntFieldMarshaller implements FieldMarshaller
|
public class IntFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public int prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Integer.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IntegerFieldMarshaller.java,v 1.1 2002/04/17 22:45:32 mdb Exp $
|
// $Id: IntegerFieldMarshaller.java,v 1.2 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class IntegerFieldMarshaller implements FieldMarshaller
|
public class IntegerFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public Integer prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Integer.class;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: LongFieldMarshaller.java,v 1.6 2002/02/01 23:32:37 mdb Exp $
|
// $Id: LongFieldMarshaller.java,v 1.7 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class LongFieldMarshaller implements FieldMarshaller
|
public class LongFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public long prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Long.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: OidListFieldMarshaller.java,v 1.4 2002/02/01 23:32:37 mdb Exp $
|
// $Id: OidListFieldMarshaller.java,v 1.5 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -12,8 +12,11 @@ import com.threerings.presents.dobj.OidList;
|
|||||||
|
|
||||||
public class OidListFieldMarshaller implements FieldMarshaller
|
public class OidListFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public OidList prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return OidList.class;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ShortFieldMarshaller.java,v 1.6 2002/02/01 23:32:37 mdb Exp $
|
// $Id: ShortFieldMarshaller.java,v 1.7 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class ShortFieldMarshaller implements FieldMarshaller
|
public class ShortFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public short prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Short.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: StreamableArrayFieldMarshaller.java,v 1.1 2002/03/20 22:58:26 mdb Exp $
|
// $Id: StreamableArrayFieldMarshaller.java,v 1.2 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -14,6 +14,12 @@ import com.threerings.presents.io.Streamable;
|
|||||||
|
|
||||||
public class StreamableArrayFieldMarshaller implements FieldMarshaller
|
public class StreamableArrayFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
|
/** Returns the sort of field that we marshall. */
|
||||||
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return (new Streamable[0]).getClass();
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: StreamableFieldMarshaller.java,v 1.5 2002/03/06 23:45:01 mdb Exp $
|
// $Id: StreamableFieldMarshaller.java,v 1.6 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -15,6 +15,12 @@ import com.threerings.presents.io.Streamable;
|
|||||||
|
|
||||||
public class StreamableFieldMarshaller implements FieldMarshaller
|
public class StreamableFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
|
/** Returns the sort of field that we marshall. */
|
||||||
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return Streamable.class;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: StringArrayFieldMarshaller.java,v 1.4 2002/02/01 23:32:37 mdb Exp $
|
// $Id: StringArrayFieldMarshaller.java,v 1.5 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class StringArrayFieldMarshaller implements FieldMarshaller
|
public class StringArrayFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public String[] prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return (new String[0]).getClass();
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: StringFieldMarshaller.java,v 1.7 2002/02/01 23:32:37 mdb Exp $
|
// $Id: StringFieldMarshaller.java,v 1.8 2002/07/17 23:05:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.io;
|
package com.threerings.presents.io;
|
||||||
|
|
||||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
|||||||
|
|
||||||
public class StringFieldMarshaller implements FieldMarshaller
|
public class StringFieldMarshaller implements FieldMarshaller
|
||||||
{
|
{
|
||||||
/** This is the sort of field that we marshall. */
|
/** Returns the sort of field that we marshall. */
|
||||||
public String prototype;
|
public Class getFieldType ()
|
||||||
|
{
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||||
throws IOException, IllegalAccessException
|
throws IOException, IllegalAccessException
|
||||||
|
|||||||
Reference in New Issue
Block a user