com.openharbor.beck.map
Interface MapFromXML

All Known Implementing Classes:
DefaultMapper

public interface MapFromXML

Maps from XML to Java.


Nested Class Summary
static interface MapFromXML.Aware
          Refers to a MapFromXML via a JavaBean-style property.
static interface MapFromXML.Source
          A source of MapFromXML objects.
 
Method Summary
 Identifier getIdentifier(Unmarshaller parent, XMLThing source, java.lang.Class objectClass)
           
 java.lang.Class getObjectClass(Unmarshaller parent, XMLThing source)
          Choose the Java class for an XML attribute or element.
 Prefixer getPrefixer()
          Choose a mapping from namespace URI to preferred XML prefix.
 java.lang.String getPropertyName(Unmarshaller parent, XMLThing source)
          Choose the JavaBean property name for an XML attribute or element.
 Setter getSetter(Unmarshaller parent, XMLThing source, Unmarshaller child)
          Choose the algorithm for creating a reference from a parent object to a child object.
 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.
 SAXContentHandler newContentHandler()
           
 org.xml.sax.ErrorHandler newErrorHandler()
           
 java.lang.Object newObject(Unmarshaller unmarshaller)
          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.
 

Method Detail

newContentHandler

public SAXContentHandler newContentHandler()

newErrorHandler

public org.xml.sax.ErrorHandler newErrorHandler()

newReceiver

public XMLReceiver newReceiver(XMLThing source)

getPrefixer

public Prefixer getPrefixer()
Choose a mapping from namespace URI to preferred XML prefix.

Returns:
the configured Prefixer, or null if none is configured.

getObjectClass

public java.lang.Class getObjectClass(Unmarshaller parent,
                                      XMLThing source)
Choose the Java class for an XML attribute or element.

Parameters:
source - to be mapped from XML
parent - mapped from the element that contains source
Returns:
the proposed class of the object to be mapped.

getPropertyName

public java.lang.String getPropertyName(Unmarshaller parent,
                                        XMLThing source)
Choose the JavaBean property name for an XML attribute or element.

Parameters:
source - to be mapped from XML
parent - mapped from the element that contains source
Returns:
the proposed name of the JavaBean property of the parent whose value is mapped from the source.

getText

public java.lang.String getText(Unmarshaller parent)
Choose the Java property to be copied from XML text.

Returns:
the property name, or null to indicate no such property is configured.

getSetter

public Setter getSetter(Unmarshaller parent,
                        XMLThing source,
                        Unmarshaller child)
Choose the algorithm for creating a reference from a parent object to a child object. For example, setting a field or property of the parent, to refer to the child.

Parameters:
source - to be mapped to child
child - may be null, e.g. when choosing a child class for instantiation.

newObject

public java.lang.Object newObject(Unmarshaller unmarshaller)
                           throws java.lang.Exception
Instantiate an object for the given unmarshaller. The returned object should be assignable to unmarshaller.getObjectClass().

Throws:
java.lang.Exception

getUnmarshaller

public Unmarshaller getUnmarshaller(Unmarshaller parent,
                                    XMLThing source,
                                    XMLContext context)
Engage an unmarshaller for the given XML source. For best performance, the returned unmarshaller should be passed to putUnmarshaller(com.openharbor.beck.unmarshal.Unmarshaller) after it has processed the XML source.

Parameters:
source - to be mapped to Java
parent - mapped from the element that contains source. null if source is the root element.
Returns:
the appropriate Unmarshaller for the object mapped from the given source, or null if no appropriate Unmarshaller is available.

putUnmarshaller

public void putUnmarshaller(Unmarshaller unmarshaller)
                     throws java.lang.Exception
Disengage an Unmarshaller from its XML source. The unmarshaller may subsequently recycle itself, but that's not the caller's concern.

Throws:
java.lang.Exception

recycle

public void recycle(Unmarshaller unmarshaller)
             throws java.lang.Exception
Make a Unmarshaller available for serial re-use. This enables a performance optimization: recycyling a Unmarshaller avoids the cost of constructing a new one. This method presumes that all unmarshallers of the same class are fungible. That is, getUnmarshaller may re-use the given unmarshaller instead of any new instance of unmarshaller.getClass().

Throws:
java.lang.Exception

getIdentifier

public Identifier getIdentifier(Unmarshaller parent,
                                XMLThing source,
                                java.lang.Class objectClass)