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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class BooleanFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public boolean prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Boolean.TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -11,8 +11,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class ByteArrayFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public byte[] prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return (new byte[0]).getClass();
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class ByteFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public byte prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Byte.TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -12,8 +12,11 @@ import com.threerings.presents.dobj.DSet;
|
||||
|
||||
public class DSetFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public DSet prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return DSet.class;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class DoubleFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public double prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Double.TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -15,6 +15,8 @@ import java.lang.reflect.Field;
|
||||
*/
|
||||
public interface FieldMarshaller
|
||||
{
|
||||
public Class getFieldType ();
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -62,8 +62,8 @@ public class FieldMarshallerRegistry
|
||||
protected static void registerMarshaller (Class clazz)
|
||||
{
|
||||
try {
|
||||
_registry.put(clazz.getField("prototype").getType(),
|
||||
clazz.newInstance());
|
||||
FieldMarshaller fm = (FieldMarshaller)clazz.newInstance();
|
||||
_registry.put(fm.getFieldType(), fm);
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to register field marshaller " +
|
||||
"[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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class FloatFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public float prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Float.TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class IntArrayFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public int[] prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return (new int[0]).getClass();
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class IntFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public int prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Integer.TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class IntegerFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public Integer prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class LongFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public long prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Long.TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -12,8 +12,11 @@ import com.threerings.presents.dobj.OidList;
|
||||
|
||||
public class OidListFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public OidList prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return OidList.class;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class ShortFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public short prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return Short.TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -14,6 +14,12 @@ import com.threerings.presents.io.Streamable;
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -15,6 +15,12 @@ import com.threerings.presents.io.Streamable;
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class StringArrayFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public String[] prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return (new String[0]).getClass();
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
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;
|
||||
|
||||
@@ -10,8 +10,11 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class StringFieldMarshaller implements FieldMarshaller
|
||||
{
|
||||
/** This is the sort of field that we marshall. */
|
||||
public String prototype;
|
||||
/** Returns the sort of field that we marshall. */
|
||||
public Class getFieldType ()
|
||||
{
|
||||
return String.class;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out, Field field, Object obj)
|
||||
throws IOException, IllegalAccessException
|
||||
|
||||
Reference in New Issue
Block a user