jhplot.io
Class Serialized

java.lang.Object
  extended by jhplot.io.Serialized

public class Serialized
extends Object

Methods used for serialization. Includes write (read) for the standard serialization. Objects can be compressed on-fly using GZip. Also, one can use XML format for serialization (writeXML(), readXML()). XML serialization is based on XSream and not compressed. Files can be read from URL.


Constructor Summary
Serialized()
           
 
Method Summary
static Object fromXML(String xml)
          Get object to XML using XSream package
static Object read(File file, boolean compressed)
          Read an object from a serialized file
static Object read(String name)
          Read an object from a serialized file.
static Object read(URL url, boolean compressed)
          Read an object from an URL
static Object readXML(String name)
          Read an object from a serialized XML file (should be written using writeXML() method).
static String toXML(Object ob)
          Convert object to XML using XSream package
static int write(Object o, String name)
          Write an object to a serialized file.
static int write(Object o, String name, boolean compressed)
          Write an object to a serialized file.
static int writeXML(Object o, String name)
          Write an object to a serialized XML file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Serialized

public Serialized()
Method Detail

write

public static int write(Object o,
                        String name,
                        boolean compressed)
Write an object to a serialized file. Use the method read() to read it back.

Parameters:
o - object to serialize into a file
name - serialized file name for output.
compression - set true if file should be compressed.
Returns:
zero if no errors

write

public static int write(Object o,
                        String name)
Write an object to a serialized file. Use the method read() to read it back. File will be compressed.

Parameters:
o - object to serialize into a file
name - serialized file name for output.
Returns:
zero if no errors

writeXML

public static int writeXML(Object o,
                           String name)
Write an object to a serialized XML file. Use the method readXML() to get it back.

Parameters:
o - object to serialize into a file
name - serialized file name for the output.
Returns:
zero if no errors

read

public static Object read(File file,
                          boolean compressed)
Read an object from a serialized file

Parameters:
file - serialized file for input.
compressed - set true if file is compressed.
Returns:
object

read

public static Object read(URL url,
                          boolean compressed)
Read an object from an URL

Parameters:
name - serialized file name for input from URL
compressed - set true if file is compressed.
Returns:
object

read

public static Object read(String name)
Read an object from a serialized file. File is assumed to be compressed, i.e when it was saved using write(obj,name) method.

Parameters:
name - serialized file name for input.
Returns:
object

readXML

public static Object readXML(String name)
Read an object from a serialized XML file (should be written using writeXML() method).

Parameters:
name - serialized XML file name for the input.
Returns:
object

toXML

public static String toXML(Object ob)
Convert object to XML using XSream package

Parameters:
ob -
Returns:
XML string

fromXML

public static Object fromXML(String xml)
Get object to XML using XSream package

Parameters:
xml - XML string
Returns:
object


jHepWork 3.1 ©