|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
com.threerings.io.ObjectOutputStream
public class ObjectOutputStream
Used to write Streamable objects to an OutputStream. Other common object types
are supported as well: Boolean, Byte, Character, Short, Integer, Long, Float, Double,
boolean[], byte[], char[], short[], int[], long[], float[], double[], Object[].
Streamable| Field Summary | |
|---|---|
protected Map<Class<?>,com.threerings.io.ClassMapping> |
_classmap
Used to map classes to numeric codes and the Streamer instance used to write
them. |
protected Object |
_current
The object currently being written to the stream. |
protected Map<String,Short> |
_internmap
Used to map pooled strings to numeric codes. |
protected short |
_nextClassCode
A counter used to assign codes to streamed classes. |
protected short |
_nextInternCode
A counter used to assign codes to pooled strings. |
protected Streamer |
_streamer
The streamer being used currently. |
protected Map<String,String> |
_translations
An optional set of class name translations to use when serializing objects. |
| Fields inherited from class java.io.DataOutputStream |
|---|
written |
| Fields inherited from class java.io.FilterOutputStream |
|---|
out |
| Constructor Summary | |
|---|---|
ObjectOutputStream(OutputStream target)
Constructs an object output stream which will write its data to the supplied target stream. |
|
| Method Summary | |
|---|---|
void |
addTranslation(String className,
String streamedName)
Configures this object output stream with a mapping from a classname to a streamed name. |
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. |
void |
defaultWriteObject()
Uses the default streamable mechanism to write the contents of the object currently being streamed. |
void |
writeBareObject(Object object)
Writes a Streamable instance or one of the support object types without
associated class metadata to the output stream. |
protected void |
writeBareObject(Object obj,
Streamer streamer,
boolean useWriter)
Write a Streamable instance without associated class metadata. |
protected com.threerings.io.ClassMapping |
writeClassMapping(Class<?> sclass)
Retrieves or creates the class mapping for the supplied class, writes it out to the stream, and returns a reference to it. |
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. |
void |
writeIntern(String value)
Writes a pooled string value to the output 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. |
void |
writeObject(Object object)
Writes a Streamable instance or one of the support object types to the output
stream. |
void |
writeUnmodifiedUTF(String str)
Write a string encoded as real UTF-8 (rather than the modified format handled by {link #writeUTF}). |
| 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 |
|---|
protected Map<Class<?>,com.threerings.io.ClassMapping> _classmap
Streamer instance used to write
them.
protected Map<String,Short> _internmap
protected short _nextClassCode
protected short _nextInternCode
protected Object _current
protected Streamer _streamer
protected Map<String,String> _translations
| Constructor Detail |
|---|
public ObjectOutputStream(OutputStream target)
| Method Detail |
|---|
public void addTranslation(String className,
String streamedName)
public void writeObject(Object object)
throws IOException
Streamable instance or one of the support object types to the output
stream.
IOException
public void writeIntern(String value)
throws IOException
IOExceptionprotected Short createInternMapping(short code)
protected void writeNewInternMapping(short code,
String value)
throws IOException
IOException
protected void writeExistingInternMapping(short code,
String value)
throws IOException
IOException
protected void writeInternMapping(int code,
String value)
throws IOException
IOException
protected com.threerings.io.ClassMapping writeClassMapping(Class<?> sclass)
throws IOException
IOException
protected com.threerings.io.ClassMapping createClassMapping(short code,
Class<?> sclass,
Streamer streamer)
protected void writeNewClassMapping(com.threerings.io.ClassMapping cmap)
throws IOException
IOException
protected void writeExistingClassMapping(com.threerings.io.ClassMapping cmap)
throws IOException
IOException
protected void writeClassMapping(int code,
Class<?> sclass)
throws IOException
IOException
public void writeBareObject(Object object)
throws IOException
Streamable instance or one of the support object types without
associated class metadata to the output stream. The caller is responsible for knowing
the exact class of the written object, creating an instance of such and calling ObjectInputStream.readBareObject(Object) to read its data from the stream.
object - the object to be written. It cannot be null.
IOException
protected void writeBareObject(Object obj,
Streamer streamer,
boolean useWriter)
throws IOException
Streamable instance without associated class metadata.
IOException
public void defaultWriteObject()
throws IOException
writeObject implementation in a
Streamable object.
IOException
public void writeUnmodifiedUTF(String str)
throws IOException
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||