com.threerings.io
Class UnreliableObjectOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.io.DataOutputStream
              extended by com.threerings.io.ObjectOutputStream
                  extended by com.threerings.io.UnreliableObjectOutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable

public class UnreliableObjectOutputStream
extends ObjectOutputStream

Extends ObjectOutputStream for use in unreliable channels, where we must transmit class mappings with every object until we are explicitly notified that the receiver has cached the mappings.


Field Summary
protected  Set<Class<?>> _mappedClasses
          The set of classes for which we have written mappings.
protected  Set<String> _mappedInterns
          The set of pooled strings for which we have written mappings.
 
Fields inherited from class com.threerings.io.ObjectOutputStream
_classmap, _current, _internmap, _nextClassCode, _nextInternCode, _streamer, _translations
 
Fields inherited from class java.io.DataOutputStream
written
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
UnreliableObjectOutputStream(OutputStream target)
          Constructs an object output stream which will write its data to the supplied target stream.
 
Method Summary
protected  com.threerings.io.ClassMapping createClassMapping(short code, Class<?> sclass, Streamer streamer)
          Creates and returns a new class mapping.
protected  Short createInternMapping(short code)
          Creates and returns a new intern mapping.
 Set<Class<?>> getMappedClasses()
          Returns a reference to the set of classes for which mappings have been written.
 Set<String> getMappedInterns()
          Returns a reference to the set of pooled strings for which mappings have been written.
 void noteClassMappingsReceived(Collection<Class<?>> sclasses)
          Notes that the receiver has received the mappings for a group of classes and thus that from now on, only the codes need be sent.
 void noteInternMappingsReceived(Collection<String> sinterns)
          Notes that the receiver has received the mappings for a group of interns and thus that from now on, only the codes need be sent.
 void setMappedClasses(Set<Class<?>> mappedClasses)
          Sets the reference to the set that will hold the classes for which mappings have been written.
 void setMappedInterns(Set<String> mappedInterns)
          Sets the reference to the set that will hold the pooled strings for which mappings have been written.
protected  void writeClassMapping(int code, Class<?> sclass)
          Writes out the mapping for a class.
protected  void writeExistingClassMapping(com.threerings.io.ClassMapping cmap)
          Writes an existing class mapping to the stream.
protected  void writeExistingInternMapping(short code, String value)
          Writes an existing intern mapping to the stream.
protected  void writeInternMapping(int code, String value)
          Writes out the mapping for an intern.
protected  void writeNewClassMapping(com.threerings.io.ClassMapping cmap)
          Writes a new class mapping to the stream.
protected  void writeNewInternMapping(short code, String value)
          Writes a new intern mapping to the stream.
 
Methods inherited from class com.threerings.io.ObjectOutputStream
addTranslation, defaultWriteObject, writeBareObject, writeBareObject, writeClassMapping, writeIntern, writeObject, writeUnmodifiedUTF
 
Methods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.io.FilterOutputStream
close, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataOutput
write
 

Field Detail

_mappedClasses

protected Set<Class<?>> _mappedClasses
The set of classes for which we have written mappings.


_mappedInterns

protected Set<String> _mappedInterns
The set of pooled strings for which we have written mappings.

Constructor Detail

UnreliableObjectOutputStream

public UnreliableObjectOutputStream(OutputStream target)
Constructs an object output stream which will write its data to the supplied target stream.

Method Detail

setMappedClasses

public void setMappedClasses(Set<Class<?>> mappedClasses)
Sets the reference to the set that will hold the classes for which mappings have been written.


getMappedClasses

public Set<Class<?>> getMappedClasses()
Returns a reference to the set of classes for which mappings have been written.


setMappedInterns

public void setMappedInterns(Set<String> mappedInterns)
Sets the reference to the set that will hold the pooled strings for which mappings have been written.


getMappedInterns

public Set<String> getMappedInterns()
Returns a reference to the set of pooled strings for which mappings have been written.


noteClassMappingsReceived

public void noteClassMappingsReceived(Collection<Class<?>> sclasses)
Notes that the receiver has received the mappings for a group of classes and thus that from now on, only the codes need be sent.


noteInternMappingsReceived

public void noteInternMappingsReceived(Collection<String> sinterns)
Notes that the receiver has received the mappings for a group of interns and thus that from now on, only the codes need be sent.


createInternMapping

protected Short createInternMapping(short code)
Description copied from class: ObjectOutputStream
Creates and returns a new intern mapping.

Overrides:
createInternMapping in class ObjectOutputStream

writeNewInternMapping

protected void writeNewInternMapping(short code,
                                     String value)
                              throws IOException
Description copied from class: ObjectOutputStream
Writes a new intern mapping to the stream.

Overrides:
writeNewInternMapping in class ObjectOutputStream
Throws:
IOException

writeExistingInternMapping

protected void writeExistingInternMapping(short code,
                                          String value)
                                   throws IOException
Description copied from class: ObjectOutputStream
Writes an existing intern mapping to the stream.

Overrides:
writeExistingInternMapping in class ObjectOutputStream
Throws:
IOException

writeInternMapping

protected void writeInternMapping(int code,
                                  String value)
                           throws IOException
Description copied from class: ObjectOutputStream
Writes out the mapping for an intern.

Overrides:
writeInternMapping in class ObjectOutputStream
Throws:
IOException

createClassMapping

protected com.threerings.io.ClassMapping createClassMapping(short code,
                                                            Class<?> sclass,
                                                            Streamer streamer)
Description copied from class: ObjectOutputStream
Creates and returns a new class mapping.

Overrides:
createClassMapping in class ObjectOutputStream

writeNewClassMapping

protected void writeNewClassMapping(com.threerings.io.ClassMapping cmap)
                             throws IOException
Description copied from class: ObjectOutputStream
Writes a new class mapping to the stream.

Overrides:
writeNewClassMapping in class ObjectOutputStream
Throws:
IOException

writeExistingClassMapping

protected void writeExistingClassMapping(com.threerings.io.ClassMapping cmap)
                                  throws IOException
Description copied from class: ObjectOutputStream
Writes an existing class mapping to the stream.

Overrides:
writeExistingClassMapping in class ObjectOutputStream
Throws:
IOException

writeClassMapping

protected void writeClassMapping(int code,
                                 Class<?> sclass)
                          throws IOException
Description copied from class: ObjectOutputStream
Writes out the mapping for a class.

Overrides:
writeClassMapping in class ObjectOutputStream
Throws:
IOException