public class SerialUtilities extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isSerializable(java.lang.Class c)
Returns
true if a class implements Serializable
and false otherwise. |
static java.text.AttributedString |
readAttributedString(java.io.ObjectInputStream stream)
Reads a
AttributedString object that has been serialised by
the writeAttributedString(AttributedString,
ObjectOutputStream) method. |
static java.awt.Composite |
readComposite(java.io.ObjectInputStream stream)
Reads a
Composite object that has been serialised by the
writeComposite(Composite, ObjectOutputStream)
method. |
static java.awt.Paint |
readPaint(java.io.ObjectInputStream stream)
Reads a
Paint object that has been serialised by the
writePaint(Paint, ObjectOutputStream) method. |
static java.awt.geom.Point2D |
readPoint2D(java.io.ObjectInputStream stream)
Reads a
Point2D object that has been serialised by the
writePoint2D(Point2D, ObjectOutputStream) method. |
static java.awt.Shape |
readShape(java.io.ObjectInputStream stream)
Reads a
Shape object that has been serialised by the
writeShape(Shape, ObjectOutputStream) method. |
static java.awt.Stroke |
readStroke(java.io.ObjectInputStream stream)
Reads a
Stroke object that has been serialised by the
writeStroke(Stroke, ObjectOutputStream) method. |
static void |
writeAttributedString(java.text.AttributedString as,
java.io.ObjectOutputStream stream)
Serialises an
AttributedString object. |
static void |
writeComposite(java.awt.Composite composite,
java.io.ObjectOutputStream stream)
Serialises a
Composite object. |
static void |
writePaint(java.awt.Paint paint,
java.io.ObjectOutputStream stream)
Serialises a
Paint object. |
static void |
writePoint2D(java.awt.geom.Point2D p,
java.io.ObjectOutputStream stream)
Serialises a
Point2D object. |
static void |
writeShape(java.awt.Shape shape,
java.io.ObjectOutputStream stream)
Serialises a
Shape object. |
static void |
writeStroke(java.awt.Stroke stroke,
java.io.ObjectOutputStream stream)
Serialises a
Stroke object. |
public static boolean isSerializable(java.lang.Class c)
true
if a class implements Serializable
and false
otherwise.c
- the class.public static java.awt.Paint readPaint(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Paint
object that has been serialised by the
writePaint(Paint, ObjectOutputStream)
method.stream
- the input stream (null
not permitted).null
).java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.public static void writePaint(java.awt.Paint paint, java.io.ObjectOutputStream stream) throws java.io.IOException
Paint
object.paint
- the paint object (null
permitted).stream
- the output stream (null
not permitted).java.io.IOException
- if there is an I/O error.public static java.awt.Stroke readStroke(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Stroke
object that has been serialised by the
writeStroke(Stroke, ObjectOutputStream)
method.stream
- the input stream (null
not permitted).null
).java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.public static void writeStroke(java.awt.Stroke stroke, java.io.ObjectOutputStream stream) throws java.io.IOException
Stroke
object. This code handles the
BasicStroke
class which is the only Stroke
implementation provided by the JDK (and isn't directly
Serializable
).stroke
- the stroke object (null
permitted).stream
- the output stream (null
not permitted).java.io.IOException
- if there is an I/O error.public static java.awt.Composite readComposite(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Composite
object that has been serialised by the
writeComposite(Composite, ObjectOutputStream)
method.stream
- the input stream (null
not permitted).null
).java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.public static void writeComposite(java.awt.Composite composite, java.io.ObjectOutputStream stream) throws java.io.IOException
Composite
object.composite
- the composite object (null
permitted).stream
- the output stream (null
not permitted).java.io.IOException
- if there is an I/O error.public static java.awt.Shape readShape(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Shape
object that has been serialised by the
writeShape(Shape, ObjectOutputStream)
method.stream
- the input stream (null
not permitted).null
).java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.public static void writeShape(java.awt.Shape shape, java.io.ObjectOutputStream stream) throws java.io.IOException
Shape
object.shape
- the shape object (null
permitted).stream
- the output stream (null
not permitted).java.io.IOException
- if there is an I/O error.public static java.awt.geom.Point2D readPoint2D(java.io.ObjectInputStream stream) throws java.io.IOException
Point2D
object that has been serialised by the
writePoint2D(Point2D, ObjectOutputStream)
method.stream
- the input stream (null
not permitted).null
).java.io.IOException
- if there is an I/O problem.public static void writePoint2D(java.awt.geom.Point2D p, java.io.ObjectOutputStream stream) throws java.io.IOException
Point2D
object.p
- the point object (null
permitted).stream
- the output stream (null
not permitted).java.io.IOException
- if there is an I/O error.public static java.text.AttributedString readAttributedString(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
AttributedString
object that has been serialised by
the writeAttributedString(AttributedString,
ObjectOutputStream)
method.stream
- the input stream (null
not permitted).null
).java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.public static void writeAttributedString(java.text.AttributedString as, java.io.ObjectOutputStream stream) throws java.io.IOException
AttributedString
object.as
- the attributed string object (null
permitted).stream
- the output stream (null
not permitted).java.io.IOException
- if there is an I/O error.