Top Description Fields Constructors Methods
org.eclipse.persistence.oxm

public Class XMLBinder

extends Object
Class Inheritance
Imports
javax.xml.transform.dom.DOMResult, .DOMSource, javax.xml.validation.Schema, .Validator, org.eclipse.persistence.exceptions.XMLMarshalException, org.eclipse.persistence.internal.oxm.Root, .XMLObjectBuilder, org.eclipse.persistence.internal.oxm.documentpreservation.XMLBinderPolicy, org.eclipse.persistence.internal.oxm.record.DOMReader, .SAXUnmarshaller, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.oxm.documentpreservation.DocumentPreservationPolicy, org.eclipse.persistence.oxm.record.DOMRecord, org.eclipse.persistence.platform.xml.XMLTransformer, org.w3c.dom.Document, .Element, .Node, org.xml.sax.ErrorHandler

PUBLIC:

Purpose:Provide a runtime public interface for preserving unmapped content from an XML Document.

Responsibilities:

The XML Binder is a runtime class that allows an association to be maintained between the original XML Document and the Java Objects built from the Document. It allows unmapped content (such as comments, processing instructions or other unmapped elements and attributes) to be preserved. The XMLBinder is created through an XMLContext.

Author
mmacivor
See Also
org.eclipse.persistence.oxm.XMLContext

Field Summary

Modifier and TypeField and Description
pack-priv XMLContext
pack-priv DocumentPreservationPolicy
pack-priv XMLMarshaller
pack-priv DOMReader
pack-priv SAXUnmarshaller
pack-priv XMLUnmarshaller

Constructor Summary

AccessConstructor and Description
public
public
XMLBinder(XMLContext context, XMLMarshaller marshaller, XMLUnmarshaller unmarshaller)

Method Summary

Modifier and TypeMethod and Description
private XMLRoot

Returns:

an XMLRoot instance encapsulating the given object
buildXMLRootFromObject
(Object obj)

Create an XMLRoot instance.

public DocumentPreservationPolicy

Returns:

an instance of DocumentPreservationPolicy
getDocumentPreservationPolicy
()

Gets this XMLBinder's document preservation policy.

public ErrorHandler
public XMLMarshaller
public Object

Returns:

the Java Object associated with this node. If no object is associated then returns null
getObject
(Node node)

Gets the Java Object associated with the provided XML Node.

public Schema
public Node

Returns:

an XML Node used to construct the given object. Null if no node exists for this object.
getXMLNode
(Object object)

Gets the XML Node associated with the provided object.

private void
public void
marshal(Object obj, Node node)

public void
public void
public void
setSchema(Schema aSchema)

public Object

Returns:

The root object unmarshalled from the provided node.
unmarshal
(Node node)

This method will unmarshal the provided node into mapped java objects.

public XMLRoot
unmarshal(Node node, Class<?> javaClass)

public void
updateObject(Node node)

Updates the object associated with the provided node to reflect any changed made to that node.

public void
updateXML(Object obj)

This method will update the cached XML node for the provided object.

public void
updateXML(Object obj, Node associatedNode)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
pack-priv XMLContext context
documentPreservationPolicyback to summary
pack-priv DocumentPreservationPolicy documentPreservationPolicy
marshallerback to summary
pack-priv XMLMarshaller marshaller
readerback to summary
pack-priv DOMReader reader
saxUnmarshallerback to summary
pack-priv SAXUnmarshaller saxUnmarshaller
unmarshallerback to summary
pack-priv XMLUnmarshaller unmarshaller

Constructor Detail

XMLBinderback to summary
public XMLBinder(XMLContext context)
XMLBinderback to summary
public XMLBinder(XMLContext context, XMLMarshaller marshaller, XMLUnmarshaller unmarshaller)

Method Detail

buildXMLRootFromObjectback to summary
private XMLRoot buildXMLRootFromObject(Object obj)

Create an XMLRoot instance. If the object is an instance of XMLRoot it will simply be returned. Otherwise, we will create a new XMLRoot using the object's descriptor default root element - any prefixes will be resolved - and the given object

Returns:XMLRoot

an XMLRoot instance encapsulating the given object

getDocumentPreservationPolicyback to summary
public DocumentPreservationPolicy getDocumentPreservationPolicy()

Gets this XMLBinder's document preservation policy.

Returns:DocumentPreservationPolicy

an instance of DocumentPreservationPolicy

See Also
org.eclipse.persistence.oxm.documentpreservation.DocumentPreservationPolicy
getErrorHandlerback to summary
public ErrorHandler getErrorHandler()
getMarshallerback to summary
public XMLMarshaller getMarshaller()
getObjectback to summary
public Object getObject(Node node)

Gets the Java Object associated with the provided XML Node.

Returns:Object

the Java Object associated with this node. If no object is associated then returns null

getSchemaback to summary
public Schema getSchema()
getXMLNodeback to summary
public Node getXMLNode(Object object)

Gets the XML Node associated with the provided object.

Returns:Node

an XML Node used to construct the given object. Null if no node exists for this object.

initializeback to summary
private void initialize()
marshalback to summary
public void marshal(Object obj, Node node)
setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler errorHandler)
setMarshallerback to summary
public void setMarshaller(XMLMarshaller marshaller)
setSchemaback to summary
public void setSchema(Schema aSchema)
unmarshalback to summary
public Object unmarshal(Node node)

This method will unmarshal the provided node into mapped java objects. The original node will be cached rather than thrown away.

Returns:Object

The root object unmarshalled from the provided node.

unmarshalback to summary
public XMLRoot unmarshal(Node node, Class<?> javaClass)
updateObjectback to summary
public void updateObject(Node node)

Updates the object associated with the provided node to reflect any changed made to that node. If this Binder has no object associated with the given node, then no operation is performed.

updateXMLback to summary
public void updateXML(Object obj)

This method will update the cached XML node for the provided object. If no node exists for this object, then no operation is performed.

updateXMLback to summary
public void updateXML(Object obj, Node associatedNode)
validateNodeback to summary
private void validateNode(Node node)