DomHandler (Java EE 5)

Java EE API


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

All Known Implementing Classes:
W3CDomHandler

public interface DomHandler<ElementT,ResultT extends Result>

Implemented by: W3CDomHandler

在元素(及其子代)与 DOM(或类似对象)表示形式之间相互转换。

此接口的实现将与 XmlAnyElement 注释一起使用,将 XML 的元素映射到信息集(如 W3C DOM)的表示形式。

实现隐藏 XML 的一部分与这些类 DOM 表示形式之间相互转换的方式,并允许 JAXB 提供者处理任意这样的库。

此接口将由库编写器实现,并由 JAXB 提供者使用。这些方法都不应该从应用程序调用。

英文文档:

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.

Since:
JAXB2.0
Author:
Kohsuke Kawaguchi

Method Summary
 ResultT
 ElementT
 Source
 

Method Detail

public javax.xml.transform.Result createUnmarshaller(ValidationEventHandler errorHandler)
当 JAXB 提供者需要将文档的一部分解组为信息集表示形式时,首先要调用此方法创建一个 Result 对象。

然后 JAXB 提供者将 XML 的一部分发送到给定的结果中。这一部分 XML 总是可以形成整个 XML 文档(该文档以某个元素为根)的子树。

errorHandler 如果在调用此方法和调用 #getElement(Result) 之间发生任何错误,则必须向此处理程序报告。 调用者必须提供一个非 null 错误处理程序。 从此方法创建的 Result 对象可以保存对此错误处理程序的引用。
return 如果操作失败,则返回 null。必须向错误处理程序报告错误。

英文文档:

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.

Parameters:
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.
Returns:
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.

Parameters:
rt - The Result object created by createUnmarshaller(ValidationEventHandler).
Returns:
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.

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


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!