public class SimpleAdapterDocument extends AbstractAdapterNode implements Document
SimpleAdapterDocument adapted a Java object and presents it as
a Document. This class represents the Document container and uses
the AdapterFactory to produce a child adapter for the wrapped object.
The adapter produced must be of an Element type or an exception is thrown.
Note: in theory we could base this on AbstractAdapterElement and then allow
the wrapped object to be a more general Node type. We would just use
ourselves as the root element. However I don't think this is an issue as
people expect Documents to wrap Elements.
Lazily construct the root element adapter from the value object.
if (rootElement != null)
return rootElement;
Node node = getAdapterFactory().adaptNode(
this, getPropertyName(), getPropertyValue());
if (node instanceof Element)
rootElement = (Element) node;
else
throw new StrutsException(
"Document adapter expected to wrap an Element type. Node is not an element:" + node);
return rootElement;