Package org.jfree.chart.util
Class SerialUtils
- java.lang.Object
-
- org.jfree.chart.util.SerialUtils
-
public class SerialUtils extends java.lang.Object
A class containing useful utility methods relating to serialization.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SerialUtils()
Private constructor prevents object creation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isSerializable(java.lang.Class c)
Returnstrue
if a class implementsSerializable
andfalse
otherwise.static java.text.AttributedString
readAttributedString(java.io.ObjectInputStream stream)
Reads aAttributedString
object that has been serialised by thewriteAttributedString(AttributedString, ObjectOutputStream)
method.static java.awt.Composite
readComposite(java.io.ObjectInputStream stream)
Reads aComposite
object that has been serialised by thewriteComposite(Composite, ObjectOutputStream)
method.static java.awt.Paint
readPaint(java.io.ObjectInputStream stream)
Reads aPaint
object that has been serialised by thewritePaint(Paint, ObjectOutputStream)
method.static java.awt.geom.Point2D
readPoint2D(java.io.ObjectInputStream stream)
Reads aPoint2D
object that has been serialised by thewritePoint2D(Point2D, ObjectOutputStream)
method.static java.awt.Shape
readShape(java.io.ObjectInputStream stream)
Reads aShape
object that has been serialised by thewriteShape(Shape, ObjectOutputStream)
method.static java.awt.Stroke
readStroke(java.io.ObjectInputStream stream)
Reads aStroke
object that has been serialised by thewriteStroke(Stroke, ObjectOutputStream)
method.static void
writeAttributedString(java.text.AttributedString as, java.io.ObjectOutputStream stream)
Serialises anAttributedString
object.static void
writeComposite(java.awt.Composite composite, java.io.ObjectOutputStream stream)
Serialises aComposite
object.static void
writePaint(java.awt.Paint paint, java.io.ObjectOutputStream stream)
Serialises aPaint
object.static void
writePoint2D(java.awt.geom.Point2D p, java.io.ObjectOutputStream stream)
Serialises aPoint2D
object.static void
writeShape(java.awt.Shape shape, java.io.ObjectOutputStream stream)
Serialises aShape
object.static void
writeStroke(java.awt.Stroke stroke, java.io.ObjectOutputStream stream)
Serialises aStroke
object.
-
-
-
Method Detail
-
isSerializable
public static boolean isSerializable(java.lang.Class c)
Returnstrue
if a class implementsSerializable
andfalse
otherwise.- Parameters:
c
- the class.- Returns:
- A boolean.
-
readPaint
public static java.awt.Paint readPaint(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
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:
java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.
-
writePaint
public static void writePaint(java.awt.Paint paint, java.io.ObjectOutputStream stream) throws java.io.IOException
Serialises aPaint
object.- Parameters:
paint
- the paint object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
java.io.IOException
- if there is an I/O error.
-
readStroke
public static java.awt.Stroke readStroke(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.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:
java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.
-
writeStroke
public static void writeStroke(java.awt.Stroke stroke, java.io.ObjectOutputStream stream) throws java.io.IOException
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:
java.io.IOException
- if there is an I/O error.
-
readComposite
public static java.awt.Composite readComposite(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.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:
java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.
-
writeComposite
public static void writeComposite(java.awt.Composite composite, java.io.ObjectOutputStream stream) throws java.io.IOException
Serialises aComposite
object.- Parameters:
composite
- the composite object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
java.io.IOException
- if there is an I/O error.
-
readShape
public static java.awt.Shape readShape(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
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:
java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.
-
writeShape
public static void writeShape(java.awt.Shape shape, java.io.ObjectOutputStream stream) throws java.io.IOException
Serialises aShape
object.- Parameters:
shape
- the shape object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
java.io.IOException
- if there is an I/O error.
-
readPoint2D
public static java.awt.geom.Point2D readPoint2D(java.io.ObjectInputStream stream) throws java.io.IOException
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:
java.io.IOException
- if there is an I/O problem.
-
writePoint2D
public static void writePoint2D(java.awt.geom.Point2D p, java.io.ObjectOutputStream stream) throws java.io.IOException
Serialises aPoint2D
object.- Parameters:
p
- the point object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
java.io.IOException
- if there is an I/O error.
-
readAttributedString
public static java.text.AttributedString readAttributedString(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.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:
java.io.IOException
- if there is an I/O problem.java.lang.ClassNotFoundException
- if there is a problem loading a class.
-
writeAttributedString
public static void writeAttributedString(java.text.AttributedString as, java.io.ObjectOutputStream stream) throws java.io.IOException
Serialises anAttributedString
object.- Parameters:
as
- the attributed string object (null
permitted).stream
- the output stream (null
not permitted).- Throws:
java.io.IOException
- if there is an I/O error.
-
-