|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.openharbor.beck.map.DefaultMapper
Maps between Java and XML in a flexible, configurable way. This class is not thread-safe.
Nested Class Summary |
Nested classes inherited from class com.openharbor.beck.map.MapFromXML |
MapFromXML.Aware, MapFromXML.Source |
Nested classes inherited from class com.openharbor.beck.map.MapToXML |
MapToXML.Source |
Field Summary | |
protected Marshaller |
arrayMarshaller
|
protected static java.util.Map |
CLASS_TO_PROPERTY_TO_SETTER
Maps the Class of an unmarshalled object to Setters for properties of that class. |
protected java.util.Map |
class2property2setter
Maps the Class of an unmarshalled object to Setters for properties of that class. |
protected Marshaller |
collectionMarshaller
|
protected java.util.Map |
configurationMemo
Maps a Selector s to the result of getMapperSource().get(s). |
protected Marshaller |
dateMarshaller
|
protected Marshaller |
defaultMarshaller
|
protected Configuration.Selector |
globalSelector
|
protected Marshaller |
listMarshaller
|
protected org.apache.commons.logging.Log |
log
|
protected Marshaller |
mapMarshaller
|
protected Configuration.MarshalSelector |
marshalSelector
|
protected Marshaller |
primitiveMarshaller
|
protected java.util.Map |
primitiveUnmarshallers
A map from a Class that has no members or properties to a Unmarshaller for that class. |
protected static XMLName |
PROPERTIES
|
protected java.util.Map |
singletons
Maps the result of getMapperSource().get X to the result of newInstance(X). |
protected Marshaller |
stringMarshaller
|
protected java.util.Map |
unmarshallerClass2Pool
Maps the Class of a Unmarshaller to a Stack of unused instances of that class. |
protected Configuration.UnmarshalSelector |
unmarshalSelector
|
Constructor Summary | |
protected |
DefaultMapper(Configuration configuration)
Most applications should call newInstance instead of this constructor. |
Method Summary | |
protected Getter[] |
add(java.lang.Class sourceClass,
Getter[] x,
java.util.Set y)
|
protected void |
addDefault(XMLName key,
java.lang.Class componentClass)
|
protected XMLThing |
addType(XMLThing result,
XMLWriter writer)
Determine the result's type, if possible. |
protected Unmarshaller |
allocateUnmarshaller(java.lang.Class unmarshallerClass)
|
protected void |
configure(java.lang.Object object)
|
protected void |
configureUnmarshaller(Unmarshaller unmarshaller,
java.lang.Class objectClass,
XMLContext context)
This method must be thread-safe, because it's inherited into Configuration.MAP_FROM_XML which is required to be thread-safe. |
protected java.util.Map |
findConfiguredSetters(java.lang.Class objectClass)
Find setters for configured supplemental properties of the given Class. |
protected static java.util.Map |
findDefaultSetters(java.lang.Class parentClass)
Find the default setters for properties of the given Class. |
protected static void |
findNonPublicSetterFields(java.lang.Class parentClass,
java.util.Map result)
|
protected static void |
findNonPublicSetterMethods(java.lang.Class parentClass,
java.util.Map result)
|
protected static void |
findNonPublicSetters(java.lang.Class parentClass,
java.util.Map result)
|
protected static void |
findPublicSetterFields(java.lang.Class parentClass,
java.util.Map result)
|
protected static void |
findPublicSetterMethods(java.lang.Class parentClass,
java.util.Map result)
|
protected static void |
findPublicSetters(java.lang.Class parentClass,
java.util.Map result)
|
Configuration |
getConfiguration()
|
protected java.lang.Object |
getConfigurationValue(Configuration.Selector selector)
|
protected Setter |
getConfiguredSetter(java.lang.Class parentClass,
java.lang.String propertyName)
Get the configured setter (if any) for the given property of the given Class. |
protected Setter |
getConfiguredSetter(Unmarshaller parent,
XMLThing source,
Unmarshaller child)
Get the configured setter (if any) for unmarshalling from the given XML source. |
protected Unmarshaller |
getConfiguredUnmarshaller(Unmarshaller parent,
XMLThing source,
java.lang.Class objectClass)
|
protected Setter |
getDefaultSetter(java.lang.Class parentClass,
java.lang.String propertyName)
Get the default setter (if any) for the given property of the given Class. |
protected Getter |
getGetter(java.lang.Class parentClass,
java.lang.Class sourceClass,
java.lang.String propertyName)
|
Getter |
getGetter(java.lang.Object parent,
java.lang.Object source)
|
Identifier |
getIdentifier(java.lang.Object parent,
Getter getter)
Choose the XML representation of repeated references to an object. |
Identifier |
getIdentifier(Unmarshaller parent,
XMLThing source,
java.lang.Class objectClass)
|
protected java.util.List |
getList(java.util.Map map,
java.lang.Object key)
|
protected java.util.Map |
getMap(java.util.Map map,
java.lang.Object key)
|
Marshaller |
getMarshaller(java.lang.Object parent,
XMLThing parentElement,
Getter getter)
Choose the Marshaller object for a given source Java object. |
protected Namer |
getNamer(java.lang.Object source)
|
java.lang.Class |
getObjectClass(Unmarshaller parent,
XMLThing source)
Choose the Java class for an XML attribute or element. |
protected XMLName |
getParentElement(XMLWriter writer)
|
java.lang.String |
getPrefix(java.lang.String namespace)
|
Prefixer |
getPrefixer()
This method must be thread-safe, because it's inherited into Configuration.MAP_FROM_XML which is required to be thread-safe. |
protected Getter[] |
getProperties(java.lang.Class sourceClass)
|
Getter[] |
getProperties(java.lang.Object parent,
Getter getter,
java.lang.Object source)
Find the properties of a given Java object that can be mapped to XML. |
java.lang.String |
getPropertyName(Unmarshaller parent,
XMLThing source)
Choose the JavaBean property name for an XML attribute or element. |
protected Configuration.UnmarshalSelector |
getSelector(Unmarshaller parent,
XMLThing source,
Unmarshaller child)
Set the fields of this.unmarshalSelector to describe the given situation. |
Setter |
getSetter(Unmarshaller parent,
XMLThing source,
Unmarshaller child)
Choose the algorithm for creating a reference from a parent object to a child object. |
protected XMLName |
getSignificantPart(XMLThing source)
Ignore XML data that don't affect mapping. |
protected java.lang.Object |
getSingleton(Configuration.Selector selector)
|
protected java.lang.Class |
getSourceClass(java.lang.Object parent,
Getter getter,
java.lang.Object source)
|
java.lang.String |
getText(java.lang.Object parent,
Marshaller marshaller,
XMLWriter writer)
Choose the Java property to be copied to XML text. |
java.lang.String |
getText(Unmarshaller parent)
Choose the Java property to be copied from XML text. |
Unmarshaller |
getUnmarshaller(Unmarshaller parent,
XMLThing source,
XMLContext context)
Engage an unmarshaller for the given XML source. |
XMLThing |
getXML(java.lang.Object parent,
Getter getter,
Marshaller marshaller,
XMLWriter writer)
Choose the XML element or attribute name for a Java object. |
SAXContentHandler |
newContentHandler()
This method must be thread-safe, because it's inherited into Configuration.MAP_FROM_XML which is required to be thread-safe. |
org.xml.sax.ErrorHandler |
newErrorHandler()
|
protected java.lang.Object |
newInstance(Configuration.Selector selector)
|
static DefaultMapper |
newInstance(Configuration configuration)
|
protected java.lang.Object |
newInstance(java.util.Map chosen)
|
java.lang.Object |
newObject(Unmarshaller child)
Instantiate an object for the given unmarshaller. |
XMLReceiver |
newReceiver(XMLThing source)
|
void |
putUnmarshaller(Unmarshaller unmarshaller)
Disengage an Unmarshaller from its XML source. |
void |
recycle(Unmarshaller unmarshaller)
Make a Unmarshaller available for serial re-use. |
protected Getter[] |
subtract(java.lang.Class sourceClass,
Getter[] x,
java.util.Set y)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final org.apache.commons.logging.Log log
protected final Configuration.Selector globalSelector
protected final Configuration.MarshalSelector marshalSelector
protected final Configuration.UnmarshalSelector unmarshalSelector
protected java.util.Map configurationMemo
protected java.util.Map singletons
protected Marshaller primitiveMarshaller
protected Marshaller stringMarshaller
protected Marshaller dateMarshaller
protected Marshaller arrayMarshaller
protected Marshaller mapMarshaller
protected Marshaller listMarshaller
protected Marshaller collectionMarshaller
protected Marshaller defaultMarshaller
protected static final XMLName PROPERTIES
protected java.util.Map primitiveUnmarshallers
protected java.util.Map unmarshallerClass2Pool
protected static final java.util.Map CLASS_TO_PROPERTY_TO_SETTER
protected java.util.Map class2property2setter
Constructor Detail |
protected DefaultMapper(Configuration configuration)
newInstance
instead of this constructor.
configuration
- must not be modified after passing it to this constructor.
The implementation of this class presumes that the result of
configuration.get is entirely a function of its parameters
(and memoizes it to improve performance).Method Detail |
public static DefaultMapper newInstance(Configuration configuration) throws java.lang.Exception
configuration
- must not be modified after passing it to this constructor.
The implementation of this class presumes that the result of
configuration.get
is entirely a function of its parameters
(and memoizes it to improve performance).
java.lang.Exception
public Configuration getConfiguration()
protected java.lang.Object getConfigurationValue(Configuration.Selector selector)
protected void addDefault(XMLName key, java.lang.Class componentClass)
protected Namer getNamer(java.lang.Object source)
public Prefixer getPrefixer()
Configuration.MAP_FROM_XML
which is required to be thread-safe.
getPrefixer
in interface MapFromXML
public SAXContentHandler newContentHandler()
Configuration.MAP_FROM_XML
which is required to be thread-safe.
newContentHandler
in interface MapFromXML
public org.xml.sax.ErrorHandler newErrorHandler()
newErrorHandler
in interface MapFromXML
public XMLReceiver newReceiver(XMLThing source)
newReceiver
in interface MapFromXML
public Identifier getIdentifier(java.lang.Object parent, Getter getter)
MapToXML
getIdentifier
in interface MapToXML
getter
- to be mapped to XMLparent
- contains source. null if source is the root object.
public java.lang.String getPrefix(java.lang.String namespace)
getPrefix
in interface Prefixer
protected XMLName getParentElement(XMLWriter writer)
public XMLThing getXML(java.lang.Object parent, Getter getter, Marshaller marshaller, XMLWriter writer) throws java.lang.Exception
MapToXML
getXML
in interface MapToXML
getter
- to be mapped to XMLparent
- contains source
java.lang.Exception
public java.lang.String getText(Unmarshaller parent)
MapFromXML
getText
in interface MapFromXML
public java.lang.String getText(java.lang.Object parent, Marshaller marshaller, XMLWriter writer)
MapToXML
getText
in interface MapToXML
protected XMLThing addType(XMLThing result, XMLWriter writer)
public java.lang.Class getObjectClass(Unmarshaller parent, XMLThing source)
MapFromXML
getObjectClass
in interface MapFromXML
source
- to be mapped from XMLparent
- mapped from the element that contains source
public java.lang.String getPropertyName(Unmarshaller parent, XMLThing source)
MapFromXML
getPropertyName
in interface MapFromXML
source
- to be mapped from XMLparent
- mapped from the element that contains source
public Setter getSetter(Unmarshaller parent, XMLThing source, Unmarshaller child)
MapFromXML
getSetter
in interface MapFromXML
source
- to be mapped to childchild
- may be null, e.g. when choosing a child class for instantiation.protected Setter getConfiguredSetter(Unmarshaller parent, XMLThing source, Unmarshaller child)
protected Setter getDefaultSetter(java.lang.Class parentClass, java.lang.String propertyName)
protected Setter getConfiguredSetter(java.lang.Class parentClass, java.lang.String propertyName)
protected static java.util.Map findDefaultSetters(java.lang.Class parentClass)
protected static void findPublicSetters(java.lang.Class parentClass, java.util.Map result)
protected static void findPublicSetterMethods(java.lang.Class parentClass, java.util.Map result)
protected static void findPublicSetterFields(java.lang.Class parentClass, java.util.Map result)
protected static void findNonPublicSetters(java.lang.Class parentClass, java.util.Map result)
protected static void findNonPublicSetterMethods(java.lang.Class parentClass, java.util.Map result)
protected static void findNonPublicSetterFields(java.lang.Class parentClass, java.util.Map result)
protected java.util.Map findConfiguredSetters(java.lang.Class objectClass)
public java.lang.Object newObject(Unmarshaller child) throws java.lang.Exception
MapFromXML
newObject
in interface MapFromXML
java.lang.Exception
public Getter[] getProperties(java.lang.Object parent, Getter getter, java.lang.Object source)
MapToXML
getProperties
in interface MapToXML
source
- to be mapped to XMLparent
- contains source. null if source is the root object.
protected Getter[] subtract(java.lang.Class sourceClass, Getter[] x, java.util.Set y)
protected Getter[] add(java.lang.Class sourceClass, Getter[] x, java.util.Set y)
protected Getter[] getProperties(java.lang.Class sourceClass)
protected Getter getGetter(java.lang.Class parentClass, java.lang.Class sourceClass, java.lang.String propertyName)
public Getter getGetter(java.lang.Object parent, java.lang.Object source)
protected java.lang.Class getSourceClass(java.lang.Object parent, Getter getter, java.lang.Object source)
public Marshaller getMarshaller(java.lang.Object parent, XMLThing parentElement, Getter getter)
MapToXML
getMarshaller
in interface MapToXML
getter
- to be mapped to XMLparent
- contains source. null if source is the root object.
public Unmarshaller getUnmarshaller(Unmarshaller parent, XMLThing source, XMLContext context)
MapFromXML
MapFromXML.putUnmarshaller(com.openharbor.beck.unmarshal.Unmarshaller)
after it has processed the XML source.
getUnmarshaller
in interface MapFromXML
source
- to be mapped to Javaparent
- mapped from the element that contains source. null if source is the root element.
protected Unmarshaller getConfiguredUnmarshaller(Unmarshaller parent, XMLThing source, java.lang.Class objectClass)
protected void configure(java.lang.Object object)
protected void configureUnmarshaller(Unmarshaller unmarshaller, java.lang.Class objectClass, XMLContext context)
Configuration.MAP_FROM_XML
which is required to be thread-safe.
public void putUnmarshaller(Unmarshaller unmarshaller) throws java.lang.Exception
MapFromXML
putUnmarshaller
in interface MapFromXML
java.lang.Exception
public Identifier getIdentifier(Unmarshaller parent, XMLThing source, java.lang.Class objectClass)
getIdentifier
in interface MapFromXML
public void recycle(Unmarshaller unmarshaller) throws java.lang.Exception
MapFromXML
recycle
in interface MapFromXML
java.lang.Exception
protected Unmarshaller allocateUnmarshaller(java.lang.Class unmarshallerClass)
protected java.util.List getList(java.util.Map map, java.lang.Object key)
protected java.util.Map getMap(java.util.Map map, java.lang.Object key)
protected java.lang.Object getSingleton(Configuration.Selector selector)
protected java.lang.Object newInstance(Configuration.Selector selector)
protected java.lang.Object newInstance(java.util.Map chosen)
protected Configuration.UnmarshalSelector getSelector(Unmarshaller parent, XMLThing source, Unmarshaller child)
protected XMLName getSignificantPart(XMLThing source)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |