com.lifecde.jxm
Class Unmarshaller

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

public class Unmarshaller
extends java.lang.Object

Default Unmarshaller. Translates one element to a Java Object.

Author:
Brian King (brian.king@lifecde.com)

Field Summary
protected  XMLToClassMap defaultMap
          default XML to class mapping
protected  java.lang.String[] defaultPackages
          default Java packages
protected static Log log
           
protected  java.util.Map maps
          XML to Class Maps
protected  JavaNaming namePolicy
          name translation policy
protected  Unmarshallers registry
          registry of unmarshallers
 
Constructor Summary
Unmarshaller()
           
 
Method Summary
 void add(java.lang.Object parent, java.lang.String currName, java.lang.Object curr)
          Add the current object to its parent.
 void characters(java.lang.Object obj, char[] ch, int start, int length)
          Add character data to translated object
protected  java.lang.Object convert(java.lang.Class type, java.lang.String value)
          Convert value to the specified type.
 void end(java.lang.Object obj)
          The XML parse of this element is done.
protected  java.lang.reflect.Method findMethod(java.lang.Class c, java.lang.String methodName)
          Find the method without knowing the parameters.
 java.lang.String[] getDefaultPackages()
          Get default packages.
protected  XMLToClassMap getMap(java.lang.String name)
          Get the to class XML mapping for the given element.
 java.lang.Object getObject(java.lang.String id)
          Get an object from the object cache.
protected  java.util.Collection makeCollection(java.lang.Class c)
          Make a Collection corresponding to the given class.
 java.lang.Object newObject(java.lang.String name)
          create a new Object whose class corresponds to the given xml element name.
 void putObject(java.lang.String id, java.lang.Object obj)
          Add an object to the object cache.
 java.lang.Object read(java.lang.String name, org.xml.sax.Attributes attrs)
          Translate element into Object.
 void readAttributes(java.lang.Object obj, org.xml.sax.Attributes attrs, XMLToClassMap map)
          set attributes into translated object
 void setDefaultPackages(java.lang.String[] packageNames)
          Set default packages to search for classes to instantiate.
 void setMaps(java.util.Map maps)
          Set XML to Class maps.
 void setRegistry(Unmarshallers registry)
           
 
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 XMLToClassMap defaultMap
default XML to class mapping


maps

protected java.util.Map maps
XML to Class Maps


namePolicy

protected JavaNaming namePolicy
name translation policy


defaultPackages

protected java.lang.String[] defaultPackages
default Java packages


registry

protected Unmarshallers registry
registry of unmarshallers

Constructor Detail

Unmarshaller

public Unmarshaller()
Method Detail

setRegistry

public void setRegistry(Unmarshallers registry)

setDefaultPackages

public void setDefaultPackages(java.lang.String[] packageNames)
Set default packages to search for classes to instantiate.


getDefaultPackages

public java.lang.String[] getDefaultPackages()
Get default packages.


setMaps

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


getObject

public java.lang.Object getObject(java.lang.String id)
Get an object from the object cache.


putObject

public void putObject(java.lang.String id,
                      java.lang.Object obj)
Add an object to the object cache.


newObject

public java.lang.Object newObject(java.lang.String name)
                           throws TranslationException
create a new Object whose class corresponds to the given xml element name.

TranslationException

read

public java.lang.Object read(java.lang.String name,
                             org.xml.sax.Attributes attrs)
                      throws TranslationException
Translate element into Object.

TranslationException

readAttributes

public void readAttributes(java.lang.Object obj,
                           org.xml.sax.Attributes attrs,
                           XMLToClassMap map)
                    throws TranslationException
set attributes into translated object

TranslationException

characters

public void characters(java.lang.Object obj,
                       char[] ch,
                       int start,
                       int length)
                throws TranslationException
Add character data to translated object

TranslationException

add

public void add(java.lang.Object parent,
                java.lang.String currName,
                java.lang.Object curr)
Add the current object to its parent.


end

public void end(java.lang.Object obj)
         throws TranslationException
The XML parse of this element is done. This might be a place to act on the accumulated text content.

TranslationException

convert

protected java.lang.Object convert(java.lang.Class type,
                                   java.lang.String value)
                            throws TranslationException
Convert value to the specified type. Returns null iftype is unrecognized.

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.


makeCollection

protected java.util.Collection makeCollection(java.lang.Class c)
                                       throws java.lang.InstantiationException,
                                              java.lang.IllegalAccessException
Make a Collection corresponding to the given class. Since many subclasses of Collection are abstract or interfaces, here we select an implementation.

java.lang.InstantiationException
java.lang.IllegalAccessException

getMap

protected XMLToClassMap getMap(java.lang.String name)
Get the to class XML mapping for the given element.