com.lifecde.jxm
Class Marshaller

java.lang.Object
  |
  +--com.lifecde.jxm.Marshaller

public class Marshaller
extends java.lang.Object

Translates from a Java object to XML.

Author:
Brian King

Field Summary
protected  ClassToXMLMap defaultMap
          default class descriptor
protected static Log log
           
protected  java.util.Map maps
          XML to Class Maps
protected  XMLNaming namePolicy
          name translation policy
protected  Marshallers registry
           
 
Constructor Summary
Marshaller()
           
 
Method Summary
protected  java.lang.reflect.Method findMethod(java.lang.Class c, java.lang.String methodName)
          Find the method without knowing the parameters.
protected  ClassToXMLMap getMap(java.lang.Class c)
          Get the class to XML mapping for the given class.
 void setMaps(java.util.Map maps)
          Set Class to XML maps.
 void setRegistry(Marshallers registry)
           
 void write(java.lang.Object obj, XMLWriter out)
          Write XML element for Java Object.
 void writeAttributes(java.lang.Object obj, ClassToXMLMap map, XMLWriter out)
          Write Object attributes.
protected  void writeCollection(java.lang.String name, java.lang.Object obj, XMLWriter out)
          Write Object as a Collection.
 void writeContent(java.lang.Object obj, ClassToXMLMap map, XMLWriter out)
          Write Object contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Log log

defaultMap

protected ClassToXMLMap defaultMap
default class descriptor


maps

protected java.util.Map maps
XML to Class Maps


namePolicy

protected XMLNaming namePolicy
name translation policy


registry

protected Marshallers registry
Constructor Detail

Marshaller

public Marshaller()
Method Detail

setMaps

public void setMaps(java.util.Map maps)
Set Class to XML maps.


setRegistry

public void setRegistry(Marshallers registry)

write

public void write(java.lang.Object obj,
                  XMLWriter out)
           throws java.io.IOException,
                  TranslationException
Write XML element for Java Object.

java.io.IOException
TranslationException

writeAttributes

public void writeAttributes(java.lang.Object obj,
                            ClassToXMLMap map,
                            XMLWriter out)
                     throws java.io.IOException,
                            TranslationException
Write Object attributes.

java.io.IOException
TranslationException

writeContent

public void writeContent(java.lang.Object obj,
                         ClassToXMLMap map,
                         XMLWriter out)
                  throws java.io.IOException,
                         TranslationException
Write Object contents.

java.io.IOException
TranslationException

getMap

protected ClassToXMLMap getMap(java.lang.Class c)
Get the class to XML mapping for the given class.


writeCollection

protected void writeCollection(java.lang.String name,
                               java.lang.Object obj,
                               XMLWriter out)
                        throws java.io.IOException,
                               TranslationException
Write Object as a Collection. The object must be a sub-class of java.util.Collection, or an array.

Parameters:
name - The collection name for XML element.
obj - the Object to treat as a Collection
out - the XMLWriter
java.io.IOException
TranslationException

findMethod

protected java.lang.reflect.Method findMethod(java.lang.Class c,
                                              java.lang.String methodName)
Find the method without knowing the parameters. If there are more than one method with the same name, returns the first one found.