|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--java.io.OutputStream
|
+--edu.umd.cs.jazz.io.ZObjectOutputStream
ZObjectOutputStream writes Jazz objects that are ZSerializable. The process of writing out Jazz scenes is to make an instance of this class, and then call writeObject() on a ZSerializable object.
Every object that gets written out must implement two methods that control the writing process. The first method, writeObjectRecurse() specifies (recursively) the objects related to this one that should be written out by calling addObject() for those objects. The second method, writeObject gets called on each object so it can specify how to write out its state.
An object can specify a replacment object that should be written out instead of itself by declaring the method: ZSerializable writeReplace(). If the replacement object is null, then the original object will note be written out at all. If it specifies a ZSerializable object, then that object will be written out instead, and any references to the original object will be replaced with references to the replacement object.
Note that there is a potential for conflict where an object can define that it should not be written out, and yet a second object can reference it in its state. Because no object can be allowed to reference an object that wasn't written out, this io code will skip any such references, and instead insert a comment into the file specifying that the reference was skipped.
ZObjectOutputStream knows how to write out the following types:
Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.
| Field Summary | |
protected java.io.DataOutputStream |
dos
|
protected int |
id
|
protected static java.lang.Class[] |
NULL_ARGS
|
protected java.util.Hashtable |
objs
|
protected java.util.Hashtable |
replacedObjs
|
protected boolean |
stateWritten
|
protected java.util.Hashtable |
unsavedObjs
|
protected boolean |
writingState
|
| Constructor Summary | |
ZObjectOutputStream(java.io.OutputStream out)
|
|
| Method Summary | |
void |
addObject(ZSerializable obj)
Add this ZSerializable object to the list of objects to be written out. |
void |
flush()
|
static boolean |
isSavable(java.lang.Object obj)
Determine if the specified object is savable. |
boolean |
isSaved(java.lang.Object obj)
|
void |
write(int b)
|
void |
writeObject(ZSerializable obj)
|
void |
writeState(java.lang.Object obj)
|
void |
writeState(java.lang.String type,
java.lang.String name,
boolean b)
|
void |
writeState(java.lang.String type,
java.lang.String name,
byte b)
|
void |
writeState(java.lang.String type,
java.lang.String name,
double d)
|
void |
writeState(java.lang.String type,
java.lang.String name,
float f)
|
void |
writeState(java.lang.String type,
java.lang.String name,
int i)
|
void |
writeState(java.lang.String type,
java.lang.String name,
java.util.List value)
|
void |
writeState(java.lang.String type,
java.lang.String name,
long l)
|
void |
writeState(java.lang.String type,
java.lang.String name,
java.lang.Object obj)
|
void |
writeState(java.lang.String type,
java.lang.String name,
short s)
|
| Methods inherited from class java.io.OutputStream |
close, write, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final java.lang.Class[] NULL_ARGS
protected java.io.DataOutputStream dos
protected int id
protected java.util.Hashtable objs
protected java.util.Hashtable unsavedObjs
protected java.util.Hashtable replacedObjs
protected boolean writingState
protected boolean stateWritten
| Constructor Detail |
public ZObjectOutputStream(java.io.OutputStream out)
| Method Detail |
public static boolean isSavable(java.lang.Object obj)
obj - Object to check
public void writeObject(ZSerializable obj)
throws java.io.IOException
java.io.IOException
public void addObject(ZSerializable obj)
throws java.io.IOException
If the object declares the ZSerializable writeReplace() method, then the specified object will be written out instead of the one passed in. If writeReplace() is specified, and returns null, then this object is not written out at all.
obj - The object to be written out
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
java.util.List value)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
short s)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
int i)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
long l)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
float f)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
double d)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
boolean b)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
byte b)
throws java.io.IOException
java.io.IOException
public void writeState(java.lang.String type,
java.lang.String name,
java.lang.Object obj)
throws java.io.IOException
java.io.IOExceptionpublic boolean isSaved(java.lang.Object obj)
public void writeState(java.lang.Object obj)
throws java.io.IOException
java.io.IOExceptionpublic void write(int b)
write in class java.io.OutputStreampublic void flush()
flush in class java.io.OutputStream
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||