Package org.jfree.chart.util
Class SerialUtils
java.lang.Object
org.jfree.chart.util.SerialUtils
A class containing useful utility methods relating to serialization.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returnstrue
if a class implementsSerializable
andfalse
otherwise.static AttributedString
Reads aAttributedString
object that has been serialised by thewriteAttributedString(AttributedString, ObjectOutputStream)
method.static Composite
readComposite
(ObjectInputStream stream) Reads aComposite
object that has been serialised by thewriteComposite(Composite, ObjectOutputStream)
method.static Paint
readPaint
(ObjectInputStream stream) Reads aPaint
object that has been serialised by thewritePaint(Paint, ObjectOutputStream)
method.static Point2D
readPoint2D
(ObjectInputStream stream) Reads aPoint2D
object that has been serialised by thewritePoint2D(Point2D, ObjectOutputStream)
method.static Shape
readShape
(ObjectInputStream stream) Reads aShape
object that has been serialised by thewriteShape(Shape, ObjectOutputStream)
method.static Stroke
readStroke
(ObjectInputStream stream) Reads aStroke
object that has been serialised by thewriteStroke(Stroke, ObjectOutputStream)
method.static void
writeAttributedString
(AttributedString as, ObjectOutputStream stream) Serialises anAttributedString
object.static void
writeComposite
(Composite composite, ObjectOutputStream stream) Serialises aComposite
object.static void
writePaint
(Paint paint, ObjectOutputStream stream) Serialises aPaint
object.static void
writePoint2D
(Point2D p, ObjectOutputStream stream) Serialises aPoint2D
object.static void
writeShape
(Shape shape, ObjectOutputStream stream) Serialises aShape
object.static void
writeStroke
(Stroke stroke, ObjectOutputStream stream) Serialises aStroke
object.
-
Method Details
-
isSerializable
Returnstrue
if a class implementsSerializable
andfalse
otherwise.- Parameters:
c
- the class.- Returns:
- A boolean.
-
readPaint
Reads aPaint
object that has been serialised by thewritePaint(Paint, ObjectOutputStream)
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.
-
writePaint
Serialises aPaint
object.- Parameters:
paint
- the paint object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
IOException
- if there is an I/O error.
-
readStroke
public static Stroke readStroke(ObjectInputStream stream) throws IOException, ClassNotFoundException Reads aStroke
object that has been serialised by thewriteStroke(Stroke, ObjectOutputStream)
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.
-
writeStroke
Serialises aStroke
object. This code handles theBasicStroke
class which is the onlyStroke
implementation provided by the JDK (and isn't directlySerializable
).- Parameters:
stroke
- the stroke object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
IOException
- if there is an I/O error.
-
readComposite
public static Composite readComposite(ObjectInputStream stream) throws IOException, ClassNotFoundException Reads aComposite
object that has been serialised by thewriteComposite(Composite, ObjectOutputStream)
method.- Parameters:
stream
- the input stream (null
not permitted).- Returns:
- The composite object (possibly
null
). - Throws:
IOException
- if there is an I/O problem.ClassNotFoundException
- if there is a problem loading a class.
-
writeComposite
public static void writeComposite(Composite composite, ObjectOutputStream stream) throws IOException Serialises aComposite
object.- Parameters:
composite
- the composite object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
IOException
- if there is an I/O error.
-
readShape
Reads aShape
object that has been serialised by thewriteShape(Shape, ObjectOutputStream)
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.
-
writeShape
Serialises aShape
object.- Parameters:
shape
- the shape object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
IOException
- if there is an I/O error.
-
readPoint2D
Reads aPoint2D
object that has been serialised by thewritePoint2D(Point2D, ObjectOutputStream)
method.- Parameters:
stream
- the input stream (null
not permitted).- Returns:
- The point object (possibly
null
). - Throws:
IOException
- if there is an I/O problem.
-
writePoint2D
Serialises aPoint2D
object.- Parameters:
p
- the point object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
IOException
- if there is an I/O error.
-
readAttributedString
public static AttributedString readAttributedString(ObjectInputStream stream) throws IOException, ClassNotFoundException Reads aAttributedString
object that has been serialised by thewriteAttributedString(AttributedString, ObjectOutputStream)
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.
-
writeAttributedString
public static void writeAttributedString(AttributedString as, ObjectOutputStream stream) throws IOException Serialises anAttributedString
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.
-