public interface Storable
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(); } }
Modifier and Type | Method and Description |
---|---|
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.
|
byte getID()
Storable getInstance()
void saveState(DataStream ds) throws IOException
IOException
void loadState(DataStream ds) throws IOException
IOException