com.threerings.io
Class Streamer.ClassStreamer

java.lang.Object
  extended by com.threerings.io.Streamer
      extended by com.threerings.io.Streamer.ClassStreamer
Direct Known Subclasses:
Streamer.CustomClassStreamer
Enclosing class:
Streamer

protected static class Streamer.ClassStreamer
extends Streamer

A streamer that streams the fields of a class.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.io.Streamer
Streamer.ArrayStreamer, Streamer.ByteEnumStreamer, Streamer.ByteOrdEnumStreamer, Streamer.ClassStreamer, Streamer.CustomClassStreamer, Streamer.EnumPolicy, Streamer.EnumStreamer, Streamer.FinalArrayStreamer, Streamer.IntOrdEnumStreamer, Streamer.NameEnumStreamer, Streamer.OrdEnumStreamer, Streamer.ShortOrdEnumStreamer
 
Field Summary
protected  Constructor<?> _ctor
          The constructor we use to create instances.
protected  Object[] _ctorArgs
          The arguments we pass to said constructor (empty or all null/zero).
protected  Field[] _fields
          The non-transient, non-static public fields that we will stream when requested.
protected  FieldMarshaller[] _marshallers
          Field marshallers for each field that will be read or written in our objects.
protected  Class<?> _target
          The class for which this streamer instance is configured.
 
Fields inherited from class com.threerings.io.Streamer
_streamers, ENUM_POLICY, FIELD_NAME_ORDER, IS_STREAMABLE, IS_STREAMCLOSURE, READER_ARGS, READER_METHOD_NAME, SORT_FIELDS, WRITER_ARGS, WRITER_METHOD_NAME
 
Constructor Summary
protected Streamer.ClassStreamer(Class<?> target)
          Constructor.
 
Method Summary
protected  FieldMarshaller[] createMarshallers()
          Creates and returns the reading and writing marshallers.
 Object createObject(ObjectInputStream in)
          Creates a blank object that can subsequently be read by this streamer.
protected  void initConstructor()
          Locates the appropriate constructor for creating instances.
 void readObject(Object object, ObjectInputStream in, boolean useReader)
          Reads and populates the fields of the supplied object from the specified stream.
protected  Objects.ToStringHelper toStringHelper()
          Overrideable to add more information to this class' toString() representation.
 void writeObject(Object object, ObjectOutputStream out, boolean useWriter)
          Writes the supplied object to the specified stream.
 
Methods inherited from class com.threerings.io.Streamer
create, getCollectionClass, getStreamer, getStreamerClass, isStreamable, maybeInit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_target

protected Class<?> _target
The class for which this streamer instance is configured.


_ctor

protected Constructor<?> _ctor
The constructor we use to create instances.


_ctorArgs

protected Object[] _ctorArgs
The arguments we pass to said constructor (empty or all null/zero).


_fields

protected Field[] _fields
The non-transient, non-static public fields that we will stream when requested.


_marshallers

protected FieldMarshaller[] _marshallers
Field marshallers for each field that will be read or written in our objects.

Constructor Detail

Streamer.ClassStreamer

protected Streamer.ClassStreamer(Class<?> target)
Constructor.

Method Detail

writeObject

public void writeObject(Object object,
                        ObjectOutputStream out,
                        boolean useWriter)
                 throws IOException
Description copied from class: Streamer
Writes the supplied object to the specified stream.

Specified by:
writeObject in class Streamer
Parameters:
object - the instance to be written to the stream.
out - the stream to which to write the instance.
useWriter - whether or not to use the custom writeObject if one exists.
Throws:
IOException

createObject

public Object createObject(ObjectInputStream in)
                    throws IOException,
                           ClassNotFoundException
Description copied from class: Streamer
Creates a blank object that can subsequently be read by this streamer. Data may be read from the input stream as a result of this method (in the case of arrays, the length of the array must be read before creating the array).

Specified by:
createObject in class Streamer
Throws:
IOException
ClassNotFoundException

readObject

public void readObject(Object object,
                       ObjectInputStream in,
                       boolean useReader)
                throws IOException,
                       ClassNotFoundException
Description copied from class: Streamer
Reads and populates the fields of the supplied object from the specified stream.

Specified by:
readObject in class Streamer
Parameters:
object - the instance to be read from the stream.
in - the stream from which to read the instance.
useReader - whether or not to use the custom readObject if one exists.
Throws:
IOException
ClassNotFoundException

initConstructor

protected void initConstructor()
Locates the appropriate constructor for creating instances.


createMarshallers

protected FieldMarshaller[] createMarshallers()
Creates and returns the reading and writing marshallers.


toStringHelper

protected Objects.ToStringHelper toStringHelper()
Description copied from class: Streamer
Overrideable to add more information to this class' toString() representation.

Overrides:
toStringHelper in class Streamer