edu.umd.cs.jazz.io
Class ZObjectOutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--edu.umd.cs.jazz.io.ZObjectOutputStream
- All Implemented Interfaces:
- java.io.Serializable
- public class ZObjectOutputStream
- extends java.io.OutputStream
- implements java.io.Serializable
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:
- short
- integer
- long
- float
- double
- boolean
- byte
- String
- ZSerializable
- Rectangle2D
- AffineTransform
- Color
- Font
- Image
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.
- Author:
- Ben Bederson
- , Britt McAlister
- See Also:
- Serialized Form
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 |
NULL_ARGS
protected static final java.lang.Class[] NULL_ARGS
-
dos
protected java.io.DataOutputStream dos
-
id
protected int id
-
objs
protected java.util.Hashtable objs
-
unsavedObjs
protected java.util.Hashtable unsavedObjs
-
replacedObjs
protected java.util.Hashtable replacedObjs
-
writingState
protected boolean writingState
-
stateWritten
protected boolean stateWritten
-
ZObjectOutputStream
public ZObjectOutputStream(java.io.OutputStream out)
isSavable
public static boolean isSavable(java.lang.Object obj)
-
Determine if the specified object is savable.
-
-
- Parameters:
obj
- Object to check
- Returns:
- true if object is savable.
writeObject
public void writeObject(ZSerializable obj)
throws java.io.IOException
-
-
java.io.IOException
addObject
public void addObject(ZSerializable obj)
throws java.io.IOException
-
Add this ZSerializable object to the list of objects to be written out. Each object will only be written out once - so calling this method multiple times on the same object will have no effect.
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.
-
-
- Parameters:
obj
- The object to be written out
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
java.util.List value)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
short s)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
int i)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
long l)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
float f)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
double d)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
boolean b)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
byte b)
throws java.io.IOException
-
-
java.io.IOException
writeState
public void writeState(java.lang.String type,
java.lang.String name,
java.lang.Object obj)
throws java.io.IOException
-
-
java.io.IOException
isSaved
public boolean isSaved(java.lang.Object obj)
-
-
writeState
public void writeState(java.lang.Object obj)
throws java.io.IOException
-
-
java.io.IOException
write
public void write(int b)
-
- Specified by:
write
in class java.io.OutputStream
-
flush
public void flush()
-
- Overrides:
flush
in class java.io.OutputStream
-
Copyright � 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.