net.sf.daileon.xml
Class JaxbXmlHandler

java.lang.Object
  extended by net.sf.daileon.xml.JaxbXmlHandler
All Implemented Interfaces:
XmlHandler

public class JaxbXmlHandler
extends Object
implements XmlHandler

Represents the JAXB implementation of the XmlHandler interface.
The JaxbXmlHandler is responsible for reading the XML configuration file and retrieving an Object representation of it, as well as serializing the content of a given Object (which must be properly annotated with annotations of the JAXB 2.0 API) to a particular OutputStream.

Version:
1.0 01/01/2010
Author:
Beto
See Also:
The JAXB Project

Field Summary
private static String XSD_PATH
          The path to the XSD schema of the XML configuration file
 
Constructor Summary
JaxbXmlHandler()
          Class constructor.
 
Method Summary
 void beanToXml(Object bean, OutputStream destiny, String jaxbContext)
          Serializes the content of a given object to an OutputStream.
 Object xmlToBean(InputStream source, String jaxbContext)
          Retrieves the content of a given XML file as an Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSD_PATH

private static final String XSD_PATH
The path to the XSD schema of the XML configuration file

See Also:
Constant Field Values
Constructor Detail

JaxbXmlHandler

JaxbXmlHandler()
Class constructor.

Method Detail

beanToXml

public void beanToXml(Object bean,
                      OutputStream destiny,
                      String jaxbContext)
               throws XmlHandlerException
Serializes the content of a given object to an OutputStream.

Specified by:
beanToXml in interface XmlHandler
Parameters:
bean - The object to be serialized in form of XML file.
destiny - The destination (as OutputStream) of the XML file to be serialized.
jaxbContext - The context of the XML file. For instance, for the JaxbXmlHandler implementation, the context is the package where the objects that represent the XML structure are located.
Throws:
XmlHandlerException - If any problem occur when trying to serialize the object.

xmlToBean

public Object xmlToBean(InputStream source,
                        String jaxbContext)
                 throws XmlHandlerException
Retrieves the content of a given XML file as an Object.

Specified by:
xmlToBean in interface XmlHandler
Parameters:
source - The XML file to be read, as InputStream.
jaxbContext - The context of the XML file. For instance, for the JaxbXmlHandler implementation, the context is the package where the objects that represent the XML structure are located.
Returns:
The structure of the XML file as an Object.
Throws:
XmlHandlerException - If any problem occur when trying to read the XML file and transform it to an Object representation.