DomHandler (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.xml.bind.annotation Interface DomHandler<ElementT,ResultT extends Result>

所有已知实现子孙类:
W3CDomHandler

public interface DomHandler<ElementT,ResultT extends Result>

Converts an element (and its descendants) from/to DOM (or similar) representation.

Implementations of this interface will be used in conjunction with XmlAnyElement annotation to map an element of XML into a representation of infoset such as W3C DOM.

Implementations hide how a portion of XML is converted into/from such DOM-like representation, allowing JAXB providers to work with arbitrary such library.

This interface is intended to be implemented by library writers and consumed by JAXB providers. None of those methods are intended to be called from applications.

从以下版本开始:
JAXB2.0
作者:
Kohsuke Kawaguchi

方法摘要
 ResultT createUnmarshaller(ValidationEventHandler errorHandler)
          When a JAXB provider needs to unmarshal a part of a document into an infoset representation, it first calls this method to create a Result object.
 ElementT getElement(ResultT rt)
          Once the portion is sent to the Result.
 Source marshal(ElementT n, ValidationEventHandler errorHandler)
          This method is called when a JAXB provider needs to marshal an element to XML.
 

方法详细信息

createUnmarshaller

ResultT createUnmarshaller(ValidationEventHandler errorHandler)
When a JAXB provider needs to unmarshal a part of a document into an infoset representation, it first calls this method to create a Result object.

A JAXB provider will then send a portion of the XML into the given result. Such a portion always form a subtree of the whole XML document rooted at an element.

参数:
errorHandler - if any error happens between the invocation of this method and the invocation of getElement(Result), they must be reported to this handler. The caller must provide a non-null error handler. The Result object created from this method may hold a reference to this error handler.
返回:
null if the operation fails. The error must have been reported to the error handler.

getElement

ElementT getElement(ResultT rt)
Once the portion is sent to the Result. This method is called by a JAXB provider to obtain the unmarshalled element representation.

Multiple invocations of this method may return different objects. This method can be invoked only when the whole sub-tree are fed to the Result object.

参数:
rt - The Result object created by createUnmarshaller(ValidationEventHandler).
返回:
null if the operation fails. The error must have been reported to the error handler.

marshal

Source marshal(ElementT n,
               ValidationEventHandler errorHandler)
This method is called when a JAXB provider needs to marshal an element to XML.

If non-null, the returned Source must contain a whole document rooted at one element, which will then be weaved into a bigger document that the JAXB provider is marshalling.

参数:
errorHandler - Receives any errors happened during the process of converting an element into a Source. The caller must provide a non-null error handler.
返回:
null if there was an error. The error should have been reported to the handler.

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.