Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## superwaba.ext.xplat.io
Interface Storable

All Known Implementing Classes:
  Address, Datebook, Mail, Memo, ToDo, Waypoint

public interface Storable

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

### getID

    public byte getID()

  Gets a unique ID for this class. It is up to the user to ensure that the ID of each class of Storable contained in a single ObjectCatalog is unique and the ID of each instance in a class is the same. If the ID returned is zero, no type information will be saved to the catalog and ObjectCatalog.loadObjectAt(int) cannot be used. It is useful, however when accessing Catalogs from other programs using the ObjectCatalog model.

### getInstance

    public Storable getInstance()

  Returns an object of the same class as this object.
  Returns:
    a class. Any data is irrelevent.

### saveState

    public void saveState(DataStream ds)

  Send the state information of this object to the given object catalog using the given DataStream. If any Storable objects need to be saved as part of the state, their saveState() method can be called too.

### loadState

    public 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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD