com.openharbor.beck.unmarshal
Class XPathUnmarshaller

java.lang.Object
  extended bycom.openharbor.beck.unmarshal.DefaultUnmarshaller
      extended bycom.openharbor.beck.unmarshal.XPathUnmarshaller
All Implemented Interfaces:
DocumentReferenceUnmarshaller, MapFromXML.Aware, Unmarshaller

public class XPathUnmarshaller
extends DefaultUnmarshaller
implements DocumentReferenceUnmarshaller

Maps an XPath cross-reference to a Java reference. A typical configuration using this class:

 <when element="XPath">
     <choose unmarshaller="XPathUnmarshaller"/>
 </when>
And a typical XML element from which to copy:
<XPath>/root/child[@name="Fred"]</XPath>


Field Summary
 
Fields inherited from class com.openharbor.beck.unmarshal.DefaultUnmarshaller
data, documentState, log
 
Fields inherited from interface com.openharbor.beck.unmarshal.DocumentReferenceUnmarshaller
UNRESOLVED
 
Constructor Summary
XPathUnmarshaller()
           
 
Method Summary
protected  void afterEndObject()
          Don't call this.addToParent (as the inherited method would).
protected  java.util.List getList(java.util.Map map, java.lang.Object key)
           
protected  OHXPath parseXPath(java.lang.String xPath)
           
protected  void reset()
          Release all resources, and subsequently behave as though newly constructed.
 void resolve(OHXPathProcessor resolver, java.lang.Object root)
          Either resolve this reference or conclude that it can't be resolved.
protected  void setValue(java.lang.StringBuffer data)
          Convert the text and store the resulting data into the object.
protected  void setXPath(OHXPath xPath)
           
 void startObject(java.util.Map documentState, Unmarshaller parent, XMLThing source)
          Begin mapping an object from an XML element or attribute.
 java.lang.String toString()
           
 
Methods inherited from class com.openharbor.beck.unmarshal.DefaultUnmarshaller
addChild, addToParent, addValue, disengage, disengaged, endElement, endObject, engage, getChildClass, getMap, getMapFromXML, getObject, getObjectClass, getParent, getSource, getSourceXPath, getXMLContext, getXName, getXPath, isEngaged, newObject, processAttributes, referToThis, rethrow, setMapFromXML, setObject, setObjectClass, setParentAndSource, setXMLContext, startElement, toString, trim
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.openharbor.beck.unmarshal.Unmarshaller
addChild, addValue, disengage, endObject, engage, getChildClass, getObject, getObjectClass, getParent, getSource, getSourceXPath, getXMLContext, setObject, setObjectClass, setXMLContext
 

Constructor Detail

XPathUnmarshaller

public XPathUnmarshaller()
Method Detail

reset

protected void reset()
Description copied from class: DefaultUnmarshaller
Release all resources, and subsequently behave as though newly constructed.

Overrides:
reset in class DefaultUnmarshaller

toString

public java.lang.String toString()

startObject

public void startObject(java.util.Map documentState,
                        Unmarshaller parent,
                        XMLThing source)
                 throws java.lang.Exception
Description copied from interface: Unmarshaller
Begin mapping an object from an XML element or attribute.

Specified by:
startObject in interface Unmarshaller
Overrides:
startObject in class DefaultUnmarshaller
Throws:
java.lang.Exception

afterEndObject

protected void afterEndObject()
Don't call this.addToParent (as the inherited method would).

Overrides:
afterEndObject in class DefaultUnmarshaller

setValue

protected void setValue(java.lang.StringBuffer data)
                 throws java.io.IOException,
                        OHXParseException
Description copied from class: DefaultUnmarshaller
Convert the text and store the resulting data into the object.

Overrides:
setValue in class DefaultUnmarshaller
Throws:
java.io.IOException
OHXParseException

parseXPath

protected OHXPath parseXPath(java.lang.String xPath)
                      throws java.io.IOException,
                             OHXParseException
Throws:
java.io.IOException
OHXParseException

setXPath

protected void setXPath(OHXPath xPath)

resolve

public void resolve(OHXPathProcessor resolver,
                    java.lang.Object root)
             throws java.lang.Exception
Description copied from interface: DocumentReferenceUnmarshaller
Either resolve this reference or conclude that it can't be resolved. If the reference is resolved, setObject(referent); otherwise setParent(null). The caller will subsequently pass this Unmarshaller to MapFromXML.recycle.

Specified by:
resolve in interface DocumentReferenceUnmarshaller
Parameters:
resolver - an XPath context with the same mapping etc. that were used to copy the root object from XML.
root - the object that was copied from the XML root element.
Throws:
java.lang.Exception - something went wrong

getList

protected java.util.List getList(java.util.Map map,
                                 java.lang.Object key)