Package org.jfree.io
Class SerialUtilities
- java.lang.Object
-
- org.jfree.io.SerialUtilities
-
public class SerialUtilities extends java.lang.Object
A class containing useful utility methods relating to serialization.- Author:
- David Gilbert
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisSerializable(java.lang.Class c)Returnstrueif a class implementsSerializableandfalseotherwise.static java.text.AttributedStringreadAttributedString(java.io.ObjectInputStream stream)Reads aAttributedStringobject that has been serialised by thewriteAttributedString(AttributedString, ObjectOutputStream)method.static java.awt.CompositereadComposite(java.io.ObjectInputStream stream)Reads aCompositeobject that has been serialised by thewriteComposite(Composite, ObjectOutputStream)method.static java.awt.PaintreadPaint(java.io.ObjectInputStream stream)Reads aPaintobject that has been serialised by thewritePaint(Paint, ObjectOutputStream)method.static java.awt.geom.Point2DreadPoint2D(java.io.ObjectInputStream stream)Reads aPoint2Dobject that has been serialised by thewritePoint2D(Point2D, ObjectOutputStream)method.static java.awt.ShapereadShape(java.io.ObjectInputStream stream)Reads aShapeobject that has been serialised by thewriteShape(Shape, ObjectOutputStream)method.static java.awt.StrokereadStroke(java.io.ObjectInputStream stream)Reads aStrokeobject that has been serialised by thewriteStroke(Stroke, ObjectOutputStream)method.static voidwriteAttributedString(java.text.AttributedString as, java.io.ObjectOutputStream stream)Serialises anAttributedStringobject.static voidwriteComposite(java.awt.Composite composite, java.io.ObjectOutputStream stream)Serialises aCompositeobject.static voidwritePaint(java.awt.Paint paint, java.io.ObjectOutputStream stream)Serialises aPaintobject.static voidwritePoint2D(java.awt.geom.Point2D p, java.io.ObjectOutputStream stream)Serialises aPoint2Dobject.static voidwriteShape(java.awt.Shape shape, java.io.ObjectOutputStream stream)Serialises aShapeobject.static voidwriteStroke(java.awt.Stroke stroke, java.io.ObjectOutputStream stream)Serialises aStrokeobject.
-
-
-
Method Detail
-
isSerializable
public static boolean isSerializable(java.lang.Class c)
Returnstrueif a class implementsSerializableandfalseotherwise.- 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 aPaintobject that has been serialised by thewritePaint(Paint, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 aPaintobject.- Parameters:
paint- the paint object (nullpermitted).stream- the output stream (nullnot 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 aStrokeobject that has been serialised by thewriteStroke(Stroke, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 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:
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 aCompositeobject that has been serialised by thewriteComposite(Composite, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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.- Since:
- 1.0.17
-
writeComposite
public static void writeComposite(java.awt.Composite composite, java.io.ObjectOutputStream stream) throws java.io.IOException
Serialises aCompositeobject.- Parameters:
composite- the composite object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
java.io.IOException- if there is an I/O error.- Since:
- 1.0.17
-
readShape
public static java.awt.Shape readShape(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
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:
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 aShapeobject.- Parameters:
shape- the shape object (nullpermitted).stream- the output stream (nullnot 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 aPoint2Dobject that has been serialised by thewritePoint2D(Point2D, ObjectOutputStream)method.- Parameters:
stream- the input stream (nullnot 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 aPoint2Dobject.- Parameters:
p- the point object (nullpermitted).stream- the output stream (nullnot 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 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:
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 anAttributedStringobject.- Parameters:
as- the attributed string object (nullpermitted).stream- the output stream (nullnot permitted).- Throws:
java.io.IOException- if there is an I/O error.
-
-