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 booleanReturnstrueif a class implementsSerializableandfalseotherwise.static AttributedStringReads aAttributedStringobject that has been serialised by thewriteAttributedString(AttributedString, ObjectOutputStream)method.static CompositereadComposite(ObjectInputStream stream) Reads aCompositeobject that has been serialised by thewriteComposite(Composite, ObjectOutputStream)method.static PaintreadPaint(ObjectInputStream stream) Reads aPaintobject that has been serialised by thewritePaint(Paint, ObjectOutputStream)method.static Point2DreadPoint2D(ObjectInputStream stream) Reads aPoint2Dobject that has been serialised by thewritePoint2D(Point2D, ObjectOutputStream)method.static ShapereadShape(ObjectInputStream stream) Reads aShapeobject that has been serialised by thewriteShape(Shape, ObjectOutputStream)method.static StrokereadStroke(ObjectInputStream stream) Reads aStrokeobject that has been serialised by thewriteStroke(Stroke, ObjectOutputStream)method.static voidwriteAttributedString(AttributedString as, ObjectOutputStream stream) Serialises anAttributedStringobject.static voidwriteComposite(Composite composite, ObjectOutputStream stream) Serialises aCompositeobject.static voidwritePaint(Paint paint, ObjectOutputStream stream) Serialises aPaintobject.static voidwritePoint2D(Point2D p, ObjectOutputStream stream) Serialises aPoint2Dobject.static voidwriteShape(Shape shape, ObjectOutputStream stream) Serialises aShapeobject.static voidwriteStroke(Stroke stroke, ObjectOutputStream stream) Serialises aStrokeobject.
-
Method Details
-
isSerializable
Returnstrueif a class implementsSerializableandfalseotherwise.- Parameters:
c- the class.- Returns:
- A boolean.
-
readPaint
Reads aPaintobject that has been serialised by thewritePaint(Paint, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 aPaintobject.- Parameters:
paint- the paint object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.
-
readStroke
public static Stroke readStroke(ObjectInputStream stream) throws IOException, ClassNotFoundException Reads aStrokeobject that has been serialised by thewriteStroke(Stroke, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 aStrokeobject. This code handles theBasicStrokeclass which is the onlyStrokeimplementation provided by the JDK (and isn't directlySerializable).- Parameters:
stroke- the stroke object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.
-
readComposite
public static Composite readComposite(ObjectInputStream stream) throws IOException, ClassNotFoundException Reads aCompositeobject that has been serialised by thewriteComposite(Composite, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 aCompositeobject.- Parameters:
composite- the composite object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.
-
readShape
Reads aShapeobject that has been serialised by thewriteShape(Shape, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 aShapeobject.- Parameters:
shape- the shape object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.
-
readPoint2D
Reads aPoint2Dobject that has been serialised by thewritePoint2D(Point2D, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot permitted).- Returns:
- The point object (possibly
null). - Throws:
IOException- if there is an I/O problem.
-
writePoint2D
Serialises aPoint2Dobject.- Parameters:
p- the point object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.
-
readAttributedString
public static AttributedString readAttributedString(ObjectInputStream stream) throws IOException, ClassNotFoundException Reads aAttributedStringobject that has been serialised by thewriteAttributedString(AttributedString, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 anAttributedStringobject.- Parameters:
as- the attributed string object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
IOException- if there is an I/O error.
-