Saving and loading the object description

To save and read an object in a Rogue Wave® JViews formatted file, you need to implement the write method and a constructor that takes an IlvInputStream parameter.
Important
The recommended way to serialize any IlvManager object is through IVL serialization and not Java serialization. Serialization cannot work for managers that contain graphic objects such as IlvIcon or some other classes, since these classes manage internally Java SE objects that are not serializable.

The write method

The method write writes the colors of the object, the dimensions of the rectangle, and the thickness of the shadow to the provided output stream:
 /**
   * Writes the object to an output stream.
   */ 
  public  void write(IlvOutputStream stream) 
    throws IOException
  {
    // Calls the super class method that will write
    // the fields specific to the super class.
    super.write(stream);
    // Writes the colors.
    stream.write("color", getColor());
    stream.write("shadowColor", getShadowColor());
    // Writes the thickness.
    stream.write("thickness", getThickness());
    // Writes the definition rectangle.
    stream.write("rectangle", drawrect);
  }
In the write method, the write method of the superclass is called to save the information specific to the superclass. Then the write methods of the class IlvOutputStream are used to save the information specific to the class.

The read constructor

To read a graphic object from a file, you must provide a specific constructor with an IlvInputStream parameter. This constructor must be public to allow the file reader to call it. Also, the constructor must read the same information, and in the same order, as that written by the write method.
 /**
   * Reads the object from an IlvInputStream
   * @param stream the input stream.
   * @exception IlvReadFileException an error occurs when reading.
   */
  public ShadowEllipse(IlvInputStream stream) throws
                                               IlvReadFileException
  {
    // Calls the super class constructor that reads
    // the information for the super class in the file.
    super(stream);
    // Reads the color.
    setColor(stream.readColor("color"));
    // Reads the shadow color.
    setShadowColor(stream.readColor("shadowColor"));
    // Reads the thickness
    setThickness(stream.readInt("thickness"));
    // reads the definition rectangle.
    IlvRect rect = stream.readRect("rectangle");
    drawrect.reshape(rect.x, rect.y, rect.width, rect.height);
  }
The above constructor calls the read constructor of the superclass which reads the information specific to the superclass from the stream object. The subclass can then read its own information. The constructor uses the read methods defined in the class IlvInputStream