com.ijchart.xychart.util
Class SerialUtil

java.lang.Object
  extended by com.ijchart.xychart.util.SerialUtil

public abstract class SerialUtil
extends java.lang.Object

Title: IJChart

Description: a chart library for the Java(tm) platform.

A class containing useful utility methods relating to serialization

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.

Constructor Summary
SerialUtil()
           
 
Method Summary
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.util.Hashtable readHashtablePaint(java.io.ObjectInputStream stream)
           Reads a hashtable of (Object, Paint) elements from a stream
static java.util.Hashtable readHashtableStroke(java.io.ObjectInputStream stream)
           Reads a hashtable of (Object, Stroke) elements from a stream
static java.awt.Image readImage(java.io.ObjectInputStream stream)
           Reads a Image object that has been serialised by the writeImage(ObjectOutputStream,Image) method
static java.awt.Paint readPaint(java.io.ObjectInputStream stream)
           Reads a Paint object that has been serialised by the writePaint(ObjectOutputStream,Paint) method
static java.util.Map readPaintMap(java.io.ObjectInputStream in)
           Reads a Map of (Object, Paint) elements from a stream.
static java.awt.geom.Point2D readPoint2D(java.io.ObjectInputStream stream)
           Reads a Point2D object that has been serialised by the writePoint2D(ObjectOutputStream,Point2D) method
static java.awt.Shape readShape(java.io.ObjectInputStream stream)
           Reads a Shape object that has been serialised by the writeShape(ObjectOutputStream,Shape) method
static java.awt.Stroke readStroke(java.io.ObjectInputStream stream)
           Reads a Stroke object that has been serialised by the writeStroke(ObjectOutputStream,Stroke) method
static void writeAttributedString(java.text.AttributedString as, java.io.ObjectOutputStream stream)
           Serialises an AttributedString object
static void writeHashtablePaint(java.io.ObjectOutputStream stream, java.util.Hashtable paints)
           Write paint objects of a hashtable.
static void writeHashtableStroke(java.io.ObjectOutputStream stream, java.util.Hashtable strokes)
           Write stroke objects of a hashtable.
static void writeImage(java.io.ObjectOutputStream stream, java.awt.Image image)
           Serialises a Image object.
static void writePaint(java.io.ObjectOutputStream stream, java.awt.Paint paint)
           Serialises a Paint object.
static void writePaintMap(java.io.ObjectOutputStream out, java.util.Map map)
           Writes a map of (Comparable, Paint) elements to a stream.
static void writePoint2D(java.io.ObjectOutputStream stream, java.awt.geom.Point2D point)
           Serialises a Point2D object
static void writeShape(java.io.ObjectOutputStream stream, java.awt.Shape shape)
           Serialises a Shape object
static void writeStroke(java.io.ObjectOutputStream stream, java.awt.Stroke stroke)
           Serialises a Stroke object.This code handles the BasicStroke class which is the only Stroke implementation provided by the JDK (and isn't directly Serializable).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialUtil

public SerialUtil()
Method Detail

isSerializable

public static boolean isSerializable(java.lang.Class c)
Returns true if a class implements Serializable and false 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 a Paint object that has been serialised by the writePaint(ObjectOutputStream,Paint) method

Parameters:
stream - ObjectOutputStream 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.io.ObjectOutputStream stream,
                              java.awt.Paint paint)
                       throws java.io.IOException
Serialises a Paint object.

Parameters:
stream - ObjectOutputStream the output stream (null not permitted).
paint - the paint object (null 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 a Stroke object that has been serialised by the writeStroke(ObjectOutputStream,Stroke) method

Parameters:
stream - ObjectOutputStream the input stream (null not permitted).
Returns:
Stroke 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.io.ObjectOutputStream stream,
                               java.awt.Stroke stroke)
                        throws java.io.IOException
Serialises a Stroke object.This code handles the BasicStroke class which is the only Stroke implementation provided by the JDK (and isn't directly Serializable).

Parameters:
stream - ObjectOutputStream the output stream (null not permitted).
stroke - the stroke object (null 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 a Shape object that has been serialised by the writeShape(ObjectOutputStream,Shape) method

Parameters:
stream - ObjectOutputStream 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.io.ObjectOutputStream stream,
                              java.awt.Shape shape)
                       throws java.io.IOException
Serialises a Shape object

Parameters:
stream - ObjectOutputStream the output stream (null not permitted).
shape - the shape object (null 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 a Point2D object that has been serialised by the writePoint2D(ObjectOutputStream,Point2D) method

Parameters:
stream - ObjectOutputStream 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.io.ObjectOutputStream stream,
                                java.awt.geom.Point2D point)
                         throws java.io.IOException
Serialises a Point2D object

Parameters:
stream - ObjectOutputStream output stream (null not permitted).
point - the point object (null 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 a AttributedString object that has been serialised by the writeAttributedString(AttributedString,ObjectOutputStream) method

Parameters:
stream - ObjectOutputStream 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 an AttributedString object

Parameters:
as - the attributed string object (null permitted).
stream - ObjectOutputStream the output stream (null not permitted).
Throws:
java.io.IOException - if there is an I/O error.

readPaintMap

public static java.util.Map readPaintMap(java.io.ObjectInputStream in)
                                  throws java.io.IOException,
                                         java.lang.ClassNotFoundException
Reads a Map of (Object, Paint) elements from a stream.

Parameters:
in - The input stream.
Returns:
The map.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writePaintMap

public static void writePaintMap(java.io.ObjectOutputStream out,
                                 java.util.Map map)
                          throws java.io.IOException
Writes a map of (Comparable, Paint) elements to a stream.

Parameters:
out - The output stream.
map - The map (null permitted).
Throws:
java.io.IOException

writeHashtablePaint

public static void writeHashtablePaint(java.io.ObjectOutputStream stream,
                                       java.util.Hashtable paints)
                                throws java.io.IOException
Write paint objects of a hashtable.

Parameters:
stream - ObjectOutputStream
paints - Hashtable The hashtable (null permitted).
Throws:
java.io.IOException

readHashtablePaint

public static java.util.Hashtable readHashtablePaint(java.io.ObjectInputStream stream)
                                              throws java.io.IOException,
                                                     java.lang.ClassNotFoundException
Reads a hashtable of (Object, Paint) elements from a stream

Parameters:
stream - ObjectInputStream
Returns:
Hashtable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeHashtableStroke

public static void writeHashtableStroke(java.io.ObjectOutputStream stream,
                                        java.util.Hashtable strokes)
                                 throws java.io.IOException
Write stroke objects of a hashtable.

Parameters:
stream - ObjectOutputStream
strokes - Hashtable
Throws:
java.io.IOException

readHashtableStroke

public static java.util.Hashtable readHashtableStroke(java.io.ObjectInputStream stream)
                                               throws java.io.IOException,
                                                      java.lang.ClassNotFoundException
Reads a hashtable of (Object, Stroke) elements from a stream

Parameters:
stream - ObjectInputStream
Returns:
Hashtable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeImage

public static void writeImage(java.io.ObjectOutputStream stream,
                              java.awt.Image image)
                       throws java.io.IOException
Serialises a Image object.

Parameters:
stream - ObjectOutputStream the output stream (null not permitted).
image - Image the image object (null permitted).
Throws:
java.io.IOException - if there is an I/O error.

readImage

public static java.awt.Image readImage(java.io.ObjectInputStream stream)
                                throws java.io.IOException,
                                       java.lang.ClassNotFoundException
Reads a Image object that has been serialised by the writeImage(ObjectOutputStream,Image) method

Parameters:
stream - ObjectOutputStream the input stream (null not permitted).
Returns:
The image 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.