cdx.scorebot.util.io
Class XStreamWrapper

java.lang.Object
  extended by cdx.scorebot.util.io.XStreamWrapper

public final class XStreamWrapper
extends java.lang.Object

This class instantiates an XStream and aliases all known USNA ScoreBot classes so they have a reasonable tag in the XML files.

Author:
David Underhill

Field Summary
static com.thoughtworks.xstream.XStream xml
          XStream object used to read/write xml
 
Method Summary
static java.lang.Object fromXML(java.io.File file)
          reads (deserializes) an object from an XML file
static java.lang.Object fromXML(java.lang.String fn)
          reads (deserializes) an object from an XML file
static void toXML(java.io.File file, java.lang.Object o)
          writes (serializes) an object in XML form to a file
static java.lang.String toXML(java.lang.Object o)
          writes (serializes) an object in XML form to a string
static void toXML(java.lang.String fn, java.lang.Object o)
          writes (serializes) an object in XML form to a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xml

public static final com.thoughtworks.xstream.XStream xml
XStream object used to read/write xml

Method Detail

fromXML

public static java.lang.Object fromXML(java.lang.String fn)
                                throws com.thoughtworks.xstream.core.BaseException,
                                       java.io.FileNotFoundException
reads (deserializes) an object from an XML file

Parameters:
fn - the filename to read the XML from
Returns:
the object parsed from the XML file
Throws:
com.thoughtworks.xstream.core.BaseException - if the object cannot be deserialized
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

fromXML

public static java.lang.Object fromXML(java.io.File file)
                                throws com.thoughtworks.xstream.core.BaseException,
                                       java.io.FileNotFoundException
reads (deserializes) an object from an XML file

Parameters:
file - the file to read the XML from
Returns:
the object parsed from the XML file
Throws:
com.thoughtworks.xstream.core.BaseException - if the object cannot be deserialized
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

toXML

public static void toXML(java.lang.String fn,
                         java.lang.Object o)
                  throws com.thoughtworks.xstream.core.BaseException,
                         java.io.FileNotFoundException
writes (serializes) an object in XML form to a file

Parameters:
fn - the filename to write the XML to
o - the object to create the XML for
Throws:
com.thoughtworks.xstream.core.BaseException - if the object cannot be deserialized
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

toXML

public static void toXML(java.io.File file,
                         java.lang.Object o)
                  throws com.thoughtworks.xstream.core.BaseException,
                         java.io.FileNotFoundException
writes (serializes) an object in XML form to a file

Parameters:
file - the object to create the XML for
o - the object to create the XML for
Throws:
com.thoughtworks.xstream.core.BaseException - if the object cannot be deserialized
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

toXML

public static java.lang.String toXML(java.lang.Object o)
                              throws com.thoughtworks.xstream.core.BaseException
writes (serializes) an object in XML form to a string

Parameters:
o - the object to create the XML for
Throws:
com.thoughtworks.xstream.core.BaseException - if the object cannot be deserialized