public class JAXBModifier
extends java.lang.Object
XMLWriter. Modifications must be provided by JAXBObjectModifier objects, which are called prior to writing
 the XML fragment they are registered for.SAXModifier| Constructor and Description | 
|---|
| JAXBModifier(java.lang.String contextPath)Creates a new JAXBModifier for the given JAXB context path. | 
| JAXBModifier(java.lang.String contextPath,
            java.lang.ClassLoader classloader)Creates a new JAXBModifier for the given JAXB context path, using the
 given  ClassLoader. | 
| JAXBModifier(java.lang.String contextPath,
            java.lang.ClassLoader classloader,
            OutputFormat outputFormat)Creates a new JAXBModifier for the given JAXB context path, using the
 specified  ClassLoader. | 
| JAXBModifier(java.lang.String contextPath,
            OutputFormat outputFormat)Creates a new JAXBModifier for the given JAXB context path. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addObjectModifier(java.lang.String path,
                 JAXBObjectModifier mod)Adds the  JAXBObjectModifierto be called when the specified xml
 path is encounted while parsing the source. | 
| boolean | isPruneElements()Returns true when the modified  Documentis not kept in
 memory. | 
| protected Element | marshal(javax.xml.bind.Element element)Marshals the given  Elementin to its DOM4J
 counterpart. | 
| Document | modify(java.io.File source)Parses the specified  Filewith SAX | 
| Document | modify(java.io.File source,
      java.nio.charset.Charset charset)Parses the specified  Filewith SAX, using the givenCharset. | 
| Document | modify(org.xml.sax.InputSource source)Parses the specified  InputSourcewith SAX. | 
| Document | modify(java.io.InputStream source)Parses the specified  InputStreamwith SAX. | 
| Document | modify(java.io.InputStream source,
      java.lang.String systemId)Parses the specified  InputStreamwith SAX. | 
| Document | modify(java.io.Reader r)Parses the specified  Readerwith SAX. | 
| Document | modify(java.io.Reader source,
      java.lang.String systemId)Parses the specified  Readerwith SAX. | 
| Document | modify(java.lang.String url)Parses the the given URL or filename. | 
| Document | modify(java.net.URL source)Parses the the given URL. | 
| void | removeObjectModifier(java.lang.String path)Removes the  JAXBObjectModifierfrom the event based processor,
 for the specified element path. | 
| void | resetObjectModifiers()Removes all registered  JAXBObjectModifierinstances from the
 event based processor. | 
| void | setOutput(java.io.File file)Sets the Output to write the (modified) xml document to. | 
| void | setOutput(java.io.OutputStream outputStream)Sets the Output to write the (modified) xml document to. | 
| void | setOutput(java.io.Writer writer)Sets the Output to write the (modified) xml document to. | 
| void | setPruneElements(boolean pruneElements)Define whether the modified  Documentmust only be
 written to the output and pruned from the DOM4J tree. | 
| protected javax.xml.bind.Element | unmarshal(Element element)Unmarshalls the specified DOM4J  Elementinto aElement | 
public JAXBModifier(java.lang.String contextPath)
contextPath - JAXB context path to be usedJAXBContextpublic JAXBModifier(java.lang.String contextPath,
                    java.lang.ClassLoader classloader)
ClassLoader. This is the Java package where JAXB
 can find the generated XML classes. This package MUST contain
 jaxb.properties!contextPath - JAXB context path to be usedclassloader - the classloader to useJAXBContextpublic JAXBModifier(java.lang.String contextPath,
                    OutputFormat outputFormat)
OutputFormatwill be used while writing the XML
 stream.contextPath - JAXB context path to be usedoutputFormat - the DOM4J OutputFormatto be usedJAXBContextpublic JAXBModifier(java.lang.String contextPath,
                    java.lang.ClassLoader classloader,
                    OutputFormat outputFormat)
ClassLoader. The specified OutputFormat will be used while writing the XML stream.contextPath - JAXB context path to be usedclassloader - the class loader to be used to load JAXBoutputFormat - the DOM4J OutputFormatto be usedJAXBContextpublic Document modify(java.io.File source) throws DocumentException, java.io.IOException
Filewith SAXsource - the file to parseDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(java.io.File source, java.nio.charset.Charset charset) throws DocumentException, java.io.IOException
Filewith SAX, using the given
 Charset.source - the file to parsecharset - the character set to useDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(org.xml.sax.InputSource source) throws DocumentException, java.io.IOException
InputSourcewith SAX.source - the input source to parseDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(java.io.InputStream source) throws DocumentException, java.io.IOException
InputStreamwith SAX.source - the inputstream to parseDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(java.io.InputStream source, java.lang.String systemId) throws DocumentException, java.io.IOException
InputStreamwith SAX.source - the inputstream to parsesystemId - the URI of the given inputstreamDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(java.io.Reader r) throws DocumentException, java.io.IOException
Readerwith SAX.r - the reader to use for parsingDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(java.io.Reader source, java.lang.String systemId) throws DocumentException, java.io.IOException
Readerwith SAX.source - the reader to parsesystemId - the URI of the given readerDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(java.lang.String url) throws DocumentException, java.io.IOException
url - the URL or filename to parseDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic Document modify(java.net.URL source) throws DocumentException, java.io.IOException
source - the URL to parseDocumentException - when an error occurs while parsingjava.io.IOException - when an error occurs while writing to the XMLWriterpublic void setOutput(java.io.File file)
               throws java.io.IOException
file - the Fileto write tojava.io.IOException - when the file cannot be found or when the outputformatpublic void setOutput(java.io.OutputStream outputStream)
               throws java.io.IOException
outputStream - the OutputStreamto write tojava.io.IOException - when an error occurspublic void setOutput(java.io.Writer writer)
               throws java.io.IOException
writer - the Writerto write tojava.io.IOException - when an error occurspublic void addObjectModifier(java.lang.String path,
                              JAXBObjectModifier mod)
JAXBObjectModifierto be called when the specified xml
 path is encounted while parsing the source.path - the element path to listen formod - the modifier to registerpublic void removeObjectModifier(java.lang.String path)
JAXBObjectModifierfrom the event based processor,
 for the specified element path.path - the xml path to remove the modifier forpublic void resetObjectModifiers()
JAXBObjectModifierinstances from the
 event based processor.public boolean isPruneElements()
Documentis not kept in
 memory.public void setPruneElements(boolean pruneElements)
Documentmust only be
 written to the output and pruned from the DOM4J tree.pruneElements - When true, elements will not be kept in memoryprotected Element marshal(javax.xml.bind.Element element) throws javax.xml.bind.JAXBException
Elementin to its DOM4J
 counterpart.element - JAXB Element to be marshalledElementjavax.xml.bind.JAXBException - when an error occursprotected javax.xml.bind.Element unmarshal(Element element) throws javax.xml.bind.JAXBException
Elementinto a Elementelement - the DOM4J element to unmarshalljavax.xml.bind.JAXBException - when an error occurs