org.jaffa.tools.patternmetaengine
Class JAXBHelper

java.lang.Object
  extended byorg.jaffa.tools.patternmetaengine.JAXBHelper

public class JAXBHelper
extends Object

This contains functions that augment the capability of the JAXB Marshalling framework

Author:
PaulE

Constructor Summary
JAXBHelper()
           
 
Method Summary
static void marshalWithDocType(javax.xml.bind.Marshaller m, javax.xml.bind.Element source, OutputStream out, String rootNode, String publicId, String systemId)
          This does the same job as javax.xml.bind.Marshaller.marshal(object, OutputStream) except it allows a DOCTYPE to be included in the output, so the XML can be validated using a DTD with a regular SAX parser.
static void showErrors(org.apache.log4j.Logger log, javax.xml.bind.util.ValidationEventCollector vec)
          Write a JAXB Validation Error Out to the Logger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAXBHelper

public JAXBHelper()
Method Detail

marshalWithDocType

public static void marshalWithDocType(javax.xml.bind.Marshaller m,
                                      javax.xml.bind.Element source,
                                      OutputStream out,
                                      String rootNode,
                                      String publicId,
                                      String systemId)
                               throws javax.xml.bind.JAXBException
This does the same job as javax.xml.bind.Marshaller.marshal(object, OutputStream) except it allows a DOCTYPE to be included in the output, so the XML can be validated using a DTD with a regular SAX parser. It also overrides the JAB generated declaration, as the DOCTYPE reference no longer makes the XML standalone!. The encoding is also set to UTF-8, the same as the JAXB default. Future enchanments could be 1) Support SYSTEM doctypes, this is only doing PUBLIC right now 2) Allow the encoding scheme to be passed in 3) Infer the root node from the XML, and remove it as an input parameter

Parameters:
m - Marshaller to use
source - Source Element to be Marshalled
out - OutputStream to write XML to
rootNode - Name of the root tag in the XML for the DOCTYPE declaration
publicId - Public Id for the DOCTYPE declaration
systemId - System Id for the DOCTYPE declaration
Throws:
javax.xml.bind.JAXBException - Thrown if a Marshalling error occurs

showErrors

public static void showErrors(org.apache.log4j.Logger log,
                              javax.xml.bind.util.ValidationEventCollector vec)
Write a JAXB Validation Error Out to the Logger

Parameters:
log - Logger to output errors to
vec - Validation Event Collection generated by JAXB


Copyright © 2002-2004 JAFFA Project.