com.threerings.export
Class ObjectMarshaller

java.lang.Object
  extended by com.threerings.export.ObjectMarshaller

public class ObjectMarshaller
extends Object

Used to read and write object fields.


Nested Class Summary
protected  class ObjectMarshaller.FieldData
          Contains information on a single field.
 
Field Summary
protected  ObjectMarshaller.FieldData[] _fields
          The object's field data.
protected static HashMap<Class<?>,ObjectMarshaller> _marshallers
          Maps classes to created marshallers.
protected  Object _prototype
          The prototype object.
protected  Method _reader
          The custom read method.
protected  Method _writer
          The custom write method.
 
Constructor Summary
protected ObjectMarshaller(Class<?> clazz)
          Creates a marshaller for objects of the specified class.
 
Method Summary
protected static void getExportableFields(Class<?> clazz, ArrayList<Field> fields)
          Places all of the given class's exportable fields into the supplied list.
static ObjectMarshaller getObjectMarshaller(Class<?> clazz)
          Retrieves or creates a marshaller for objects of the specified class.
 Object getPrototype()
          Returns a reference to the prototype object (used to determine field defaults).
 void readFields(Object object, Importer importer, boolean useReader)
          Reads the fields of an object from the specified importer.
 void writeFields(Object object, Exporter exporter, boolean useWriter)
          Writes the fields of an object to the specified exporter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_reader

protected Method _reader
The custom read method.


_writer

protected Method _writer
The custom write method.


_fields

protected ObjectMarshaller.FieldData[] _fields
The object's field data.


_prototype

protected Object _prototype
The prototype object.


_marshallers

protected static HashMap<Class<?>,ObjectMarshaller> _marshallers
Maps classes to created marshallers.

Constructor Detail

ObjectMarshaller

protected ObjectMarshaller(Class<?> clazz)
Creates a marshaller for objects of the specified class.

Method Detail

getObjectMarshaller

public static ObjectMarshaller getObjectMarshaller(Class<?> clazz)
Retrieves or creates a marshaller for objects of the specified class.


getPrototype

public Object getPrototype()
Returns a reference to the prototype object (used to determine field defaults).


readFields

public void readFields(Object object,
                       Importer importer,
                       boolean useReader)
                throws IOException
Reads the fields of an object from the specified importer.

Throws:
IOException

writeFields

public void writeFields(Object object,
                        Exporter exporter,
                        boolean useWriter)
                 throws IOException
Writes the fields of an object to the specified exporter.

Throws:
IOException

getExportableFields

protected static void getExportableFields(Class<?> clazz,
                                          ArrayList<Field> fields)
Places all of the given class's exportable fields into the supplied list.