Package org.jfree.xml.writer
Class RootXmlWriteHandler
- java.lang.Object
-
- org.jfree.xml.writer.RootXmlWriteHandler
-
public abstract class RootXmlWriteHandler extends java.lang.Object
A root handler for writing objects to XML format.
-
-
Constructor Summary
Constructors Constructor Description RootXmlWriteHandler()
Creates a new RootXmlWrite handler with the default mappings enabled.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addManualMapping(java.lang.Class classToWrite, java.lang.Class handler)
Adds a new manual mapping to this handler.protected void
addMultiplexMapping(java.lang.Class baseClass, java.lang.String typeAttr, MultiplexMappingEntry[] mdef)
Adds a multiplex mapping.protected abstract ObjectFactory
getFactoryLoader()
Returns the object factory.protected XmlWriteHandler
getMapping(java.lang.Class classToWrite)
Tries to find the mapping for the given class.protected XmlWriteHandler
loadHandlerClass(java.lang.String className)
Loads the given class, and ignores all exceptions which may occur during the loading.void
write(java.lang.String tagName, java.lang.Object object, java.lang.Class baseClass, XMLWriter writer)
Writes the given object with the specified tagname.
-
-
-
Constructor Detail
-
RootXmlWriteHandler
public RootXmlWriteHandler()
Creates a new RootXmlWrite handler with the default mappings enabled.
-
-
Method Detail
-
getFactoryLoader
protected abstract ObjectFactory getFactoryLoader()
Returns the object factory.- Returns:
- the object factory.
-
addManualMapping
protected void addManualMapping(java.lang.Class classToWrite, java.lang.Class handler)
Adds a new manual mapping to this handler. This method provides support for the manual mapping. The manual mapping will become active before the multiplexers were queried. This facility could be used to override the model definition.- Parameters:
classToWrite
- the class, which should be handledhandler
- the write handler implementation for that class.
-
addMultiplexMapping
protected void addMultiplexMapping(java.lang.Class baseClass, java.lang.String typeAttr, MultiplexMappingEntry[] mdef)
Adds a multiplex mapping.- Parameters:
baseClass
- the base class.typeAttr
- the type attribute.mdef
- the mapping entries.
-
getMapping
protected XmlWriteHandler getMapping(java.lang.Class classToWrite) throws XMLWriterException
Tries to find the mapping for the given class. This will first check the manual mapping and then try to use the object factory to resolve the class parameter into a write handler.- Parameters:
classToWrite
- the class for which to find a handler.- Returns:
- the write handler, never null.
- Throws:
XMLWriterException
- if no handler could be found for the given class.
-
write
public void write(java.lang.String tagName, java.lang.Object object, java.lang.Class baseClass, XMLWriter writer) throws java.io.IOException, XMLWriterException
Writes the given object with the specified tagname. This method will do nothing, if the given object is null.- Parameters:
tagName
- the tagname for the xml-element containing the object definition. The tagname must not be null.object
- the object which should be written.baseClass
- the base class.writer
- the xml writer used to write the content, never null.- Throws:
java.io.IOException
- if an IOException occures.XMLWriterException
- if an object model related error occures during the writing.
-
loadHandlerClass
protected XmlWriteHandler loadHandlerClass(java.lang.String className) throws XMLWriterException
Loads the given class, and ignores all exceptions which may occur during the loading. If the class was invalid, null is returned instead.- Parameters:
className
- the name of the class to be loaded.- Returns:
- the class or null.
- Throws:
XMLWriterException
- if there is a writer exception.
-
-