|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An interface for all objects that support loading and saving themselves through the ObjectCatalog class. This works in a similar manner to the Externalizable interface in Java. When saveState() is called, the value of any fields should be written to the given DataStream. When loadState() is called these values should be read back using the equivalent methods, making sure the order remains the same. After loadState() the new object should behave exactly as it did before the corresponding saveState(). Here is an example of the methods in use.
public class MyClass implements Storable { int i; String s; public MyClass() { } public MyClass(int i,String s) { this.i=i; this.s=s; } public byte getID() { return (byte)123; } public Storable getInstance() { return new MyClass(); } public void saveState(DataStream ds) { ds.writeInt(i); ds.writeString(s); } public void loadState(DataStream ds) { i=ds.readInt(); s=ds.readString(); } }
Method Summary | |
byte |
getID()
Gets a unique ID for this class. |
Storable |
getInstance()
Returns an object of the same class as this object. |
void |
loadState(DataStream ds)
Load state information from the given DataStream into this object If any Storable objects need to be loaded as part of the state, their loadState() method can be called too. |
void |
saveState(DataStream ds)
Send the state information of this object to the given object catalog using the given DataStream. |
Method Detail |
public byte getID()
public Storable getInstance()
public void saveState(DataStream ds)
public void loadState(DataStream ds)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |