org.jfree.io

Class SerialUtilities

public class SerialUtilities extends Object

A class containing useful utility methods relating to serialization.

Author: David Gilbert

Method Summary
static booleanisSerializable(Class c)
Returns true if a class implements Serializable and false otherwise.
static AttributedStringreadAttributedString(ObjectInputStream stream)
Reads a AttributedString object that has been serialised by the SerialUtilities method.
static PaintreadPaint(ObjectInputStream stream)
Reads a Paint object that has been serialised by the SerialUtilities method.
static Point2DreadPoint2D(ObjectInputStream stream)
Reads a Point2D object that has been serialised by the SerialUtilities method.
static ShapereadShape(ObjectInputStream stream)
Reads a Shape object that has been serialised by the SerialUtilities method.
static StrokereadStroke(ObjectInputStream stream)
Reads a Stroke object that has been serialised by the SerialUtilities method.
static voidwriteAttributedString(AttributedString as, ObjectOutputStream stream)
Serialises an AttributedString object.
static voidwritePaint(Paint paint, ObjectOutputStream stream)
Serialises a Paint object.
static voidwritePoint2D(Point2D p, ObjectOutputStream stream)
Serialises a Point2D object.
static voidwriteShape(Shape shape, ObjectOutputStream stream)
Serialises a Shape object.
static voidwriteStroke(Stroke stroke, ObjectOutputStream stream)
Serialises a Stroke object.

Method Detail

isSerializable

public static boolean isSerializable(Class c)
Returns true if a class implements Serializable and false otherwise.

Parameters: c the class.

Returns: A boolean.

readAttributedString

public static AttributedString readAttributedString(ObjectInputStream stream)
Reads a AttributedString object that has been serialised by the SerialUtilities method.

Parameters: stream the input stream (null not permitted).

Returns: The attributed string object (possibly null).

Throws: IOException if there is an I/O problem. ClassNotFoundException if there is a problem loading a class.

readPaint

public static Paint readPaint(ObjectInputStream stream)
Reads a Paint object that has been serialised by the SerialUtilities method.

Parameters: stream the input stream (null not permitted).

Returns: The paint object (possibly null).

Throws: IOException if there is an I/O problem. ClassNotFoundException if there is a problem loading a class.

readPoint2D

public static Point2D readPoint2D(ObjectInputStream stream)
Reads a Point2D object that has been serialised by the SerialUtilities method.

Parameters: stream the input stream (null not permitted).

Returns: The point object (possibly null).

Throws: IOException if there is an I/O problem.

readShape

public static Shape readShape(ObjectInputStream stream)
Reads a Shape object that has been serialised by the SerialUtilities method.

Parameters: stream the input stream (null not permitted).

Returns: The shape object (possibly null).

Throws: IOException if there is an I/O problem. ClassNotFoundException if there is a problem loading a class.

readStroke

public static Stroke readStroke(ObjectInputStream stream)
Reads a Stroke object that has been serialised by the SerialUtilities method.

Parameters: stream the input stream (null not permitted).

Returns: The stroke object (possibly null).

Throws: IOException if there is an I/O problem. ClassNotFoundException if there is a problem loading a class.

writeAttributedString

public static void writeAttributedString(AttributedString as, ObjectOutputStream stream)
Serialises an AttributedString object.

Parameters: as the attributed string object (null permitted). stream the output stream (null not permitted).

Throws: IOException if there is an I/O error.

writePaint

public static void writePaint(Paint paint, ObjectOutputStream stream)
Serialises a Paint object.

Parameters: paint the paint object (null permitted). stream the output stream (null not permitted).

Throws: IOException if there is an I/O error.

writePoint2D

public static void writePoint2D(Point2D p, ObjectOutputStream stream)
Serialises a Point2D object.

Parameters: p the point object (null permitted). stream the output stream (null not permitted).

Throws: IOException if there is an I/O error.

writeShape

public static void writeShape(Shape shape, ObjectOutputStream stream)
Serialises a Shape object.

Parameters: shape the shape object (null permitted). stream the output stream (null not permitted).

Throws: IOException if there is an I/O error.

writeStroke

public static void writeStroke(Stroke stroke, ObjectOutputStream stream)
Serialises a Stroke object. This code handles the BasicStroke class which is the only Stroke implementation provided by the JDK (and isn't directly Serializable).

Parameters: stroke the stroke object (null permitted). stream the output stream (null not permitted).

Throws: IOException if there is an I/O error.