com.xerox.amazonws.common
Class JAXBuddy

java.lang.Object
  extended by com.xerox.amazonws.common.JAXBuddy

public class JAXBuddy
extends Object

This class implements some helpful methods to marshal and unmarshal xml.

Author:
D. Kavanagh, developer@dotech.com

Field Summary
static Hashtable<String,javax.xml.bind.JAXBContext> contextCache
           
 
Constructor Summary
JAXBuddy()
           
 
Method Summary
static void clearCache()
          This method will clear the internal cache we use to speed up these util functions.
static DocumentBuilder createDocumentBuilder()
           
static
<T> T
deserializeXMLStream(Class<T> c, InputStream is)
          A convenience method to turn XML in a stream into an object.
static
<T> InputStream
serializeXMLFile(Class<T> c, Object object)
          A convenience method to turn an object into a stream of XML.
static
<T> String
serializeXMLString(Class<T> c, Object object)
          A convenience method to turn an object into a string of XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contextCache

public static final Hashtable<String,javax.xml.bind.JAXBContext> contextCache
Constructor Detail

JAXBuddy

public JAXBuddy()
Method Detail

createDocumentBuilder

public static DocumentBuilder createDocumentBuilder()
                                             throws Exception
Throws:
Exception

serializeXMLFile

public static <T> InputStream serializeXMLFile(Class<T> c,
                                               Object object)
                                    throws javax.xml.bind.JAXBException,
                                           IOException
A convenience method to turn an object into a stream of XML.

Parameters:
c - the class you're serializing
object - the object you're serializing
Returns:
an input stream to read the XML from
Throws:
javax.xml.bind.JAXBException
IOException

serializeXMLString

public static <T> String serializeXMLString(Class<T> c,
                                            Object object)
                                 throws javax.xml.bind.JAXBException,
                                        IOException
A convenience method to turn an object into a string of XML.

Parameters:
c - the class you're serializing
object - the object you're serializing
Returns:
a string containing the XML
Throws:
javax.xml.bind.JAXBException
IOException

deserializeXMLStream

public static <T> T deserializeXMLStream(Class<T> c,
                                         InputStream is)
                              throws javax.xml.bind.JAXBException,
                                     IOException,
                                     SAXException
A convenience method to turn XML in a stream into an object.

Parameters:
c - the class you're deserializing
is - the stream to read the XMl from
Returns:
an object representing the data from the stream
Throws:
javax.xml.bind.JAXBException
IOException
SAXException

clearCache

public static void clearCache()
This method will clear the internal cache we use to speed up these util functions. Do we think anybody will need this method? no... Are we providing it to be nice to the anal retentive amongst us? yes.