Share via


IPersistable Interface

Methods | This Package | All Packages

Allows an object to be written to a stream and read from a stream.

package com.ms.wfc.core

public interface IPersistable

Remarks

This interface defines the save method, which persists the class object to a stream.

Note   In order to read the object from the stream, the class must implement a constructor that takes an IDataStream object, which contains data for instantiating the class.

The following example shows a Point class that implements IPersistable:

public class Point implements IPersistable
{
   public int x;  // The horizontal position of the point.
   public int y;  // The vertical position of the point.

   // Constructor that takes an IDataStream object.
   public Point(IDataStream stream) {
       x = stream.readInt();
       y = stream.readInt();
   }

   // Implementation of IPersistable.save.
   public void save(IDataStream stream) {
       stream.writeInt(x);
       stream.writeInt(y);
   }

   // Implementation of IPersistable.getExtension.
   public String getExtension() {
       return null;
   }

   ...  // Remaining class implementation.
}

The IPersistable interface enables a class to be used as a property value for a component or control. For more information, see the IConstructable overview.