org.jembi.sdmxhd.util
Class XMLBuilder

java.lang.Object
  extended by org.jembi.sdmxhd.util.XMLBuilder

public class XMLBuilder
extends java.lang.Object

This class allow Java Bean object that conform to the following specification to be written to XML. It uses reflection to look at the class of the object to be written to XML and find what field are XML attributes and what are XML elements. It uses this information to then write the java bean to XML. Complex object contained within the java bean have their own toXML() methods called to write them to XML.

The bean must be annotated as follow for then to be written to XML:

Author:
Ryan Crichton

Constructor Summary
XMLBuilder()
           
 
Method Summary
static void writeBeanToXML(XMLWritable bean, javax.xml.stream.XMLStreamWriter xmlWriter)
          Writes the specified object to XML
static void writeBeanToXML(XMLWritable bean, javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace)
          Writes the specified object to XML
static void writeBeanToXML(XMLWritable bean, javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace, java.lang.String name)
          Writes the specified object to XML
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLBuilder

public XMLBuilder()
Method Detail

writeBeanToXML

public static void writeBeanToXML(XMLWritable bean,
                                  javax.xml.stream.XMLStreamWriter xmlWriter)
                           throws javax.xml.stream.XMLStreamException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.IllegalAccessException
Writes the specified object to XML

Parameters:
bean - the object to be written
xmlWriter - the xmlWriter to write the XML to.
Throws:
javax.xml.stream.XMLStreamException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

writeBeanToXML

public static void writeBeanToXML(XMLWritable bean,
                                  javax.xml.stream.XMLStreamWriter xmlWriter,
                                  java.lang.String namespace)
                           throws javax.xml.stream.XMLStreamException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.IllegalAccessException
Writes the specified object to XML

Parameters:
bean - the object to be written
xmlWriter - the xmlWriter to write the XML to.
Throws:
javax.xml.stream.XMLStreamException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException

writeBeanToXML

public static void writeBeanToXML(XMLWritable bean,
                                  javax.xml.stream.XMLStreamWriter xmlWriter,
                                  java.lang.String namespace,
                                  java.lang.String name)
                           throws javax.xml.stream.XMLStreamException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.IllegalAccessException
Writes the specified object to XML

Parameters:
bean - the object to be written
xmlWriter - the xmlWriter to write the XML to.
Throws:
javax.xml.stream.XMLStreamException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException