Unmarshaller.Listener (Java EE 5)

Java EE API


javax.xml.bind Class Unmarshaller.Listener

java.lang.Object
  extended by javax.xml.bind.Unmarshaller.Listener
Enclosing interface:
Unmarshaller

public abstract static class Unmarshaller.Listener
extends Object

Contained within: Unmarshaller

Unmarshaller 注册此类的一个实现的实例,以便外部侦听解组事件。

此类可以在将 XML 数据解组到 JAXB 映射类中时启用对 JAXB 映射类实例的预处理和后处理。在将 XML 内容解组到 JAXBElement 实例或表示复杂类型定义的 JAXB 映射类中时,将调用事件回调。解组到表示简单类型定义的 Java 数据类型的实例时,不需要调用事件回调。

外部侦听器是用于定义解组事件回调的两个不同机制之一。请参阅 Unmarshal Event Callbacks 获得对这方面的概括。

(@link #setListener(Listener)} (@link #getListener()}

英文文档:

Register an instance of an implementation of this class with Unmarshaller to externally listen for unmarshal events.

This class enables pre and post processing of an instance of a JAXB mapped class as XML data is unmarshalled into it. The event callbacks are called when unmarshalling XML content into a JAXBElement instance or a JAXB mapped class that represents a complex type definition. The event callbacks are not called when unmarshalling to an instance of a Java datatype that represents a simple type definition.

External listener is one of two different mechanisms for defining unmarshal event callbacks. See Unmarshal Event Callbacks for an overview.

(@link #setListener(Listener)} (@link #getListener()}

Since:
JAXB2.0

Constructor Summary
 
Method Summary
 void
 void
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public Unmarshaller.Listener()
英文文档:

Unmarshaller.Listener

public Unmarshaller.Listener()
Method Detail

public void beforeUnmarshal(Object target, Object parent)

在解组到 target 之前调用的回调方法。

在创建 target 之后且在开始解组此对象之前立即调用此方法。注意,如果 target 的类定义了自己的 beforeUnmarshal 方法,则在调用此方法之前调用特定于类的回调方法。

target 解组之前的 JAXB 映射类的非 null 实例。
parent 将最终引用 target 的 JAXB 映射类的实例。当 target 是根元素时,该参数为 null

英文文档:

beforeUnmarshal

public void beforeUnmarshal(Object target,
                            Object parent)

Callback method invoked before unmarshalling into target.

This method is invoked immediately after target was created and before the unmarshalling of this object begins. Note that if the class of target defines its own beforeUnmarshal method, the class specific callback method is invoked before this method is invoked.

Parameters:
target - non-null instance of JAXB mapped class prior to unmarshalling into it.
parent - instance of JAXB mapped class that will eventually reference target. null when target is root element.

public void afterUnmarshal(Object target, Object parent)

将 XML 数据解组到 target 之后调用的回调方法。

在将所有属性(IDREF 除外)解组到 target 之后、但在将 target 设置为其 parent 对象之前调用此方法。注意,如果 target 的类定义了自己的 afterUnmarshal 方法,则在调用此方法之前调用特定于类的回调方法。

target 解组之前的 JAXB 映射类的非 null 实例。
parent 将引用 target 的 JAXB 映射类的实例。当 target 是根元素时,该参数为 null

英文文档:

afterUnmarshal

public void afterUnmarshal(Object target,
                           Object parent)

Callback method invoked after unmarshalling XML data into target.

This method is invoked after all the properties (except IDREF) are unmarshalled into target, but before target is set into its parent object. Note that if the class of target defines its own afterUnmarshal method, the class specific callback method is invoked before this method is invoked.

Parameters:
target - non-null instance of JAXB mapped class prior to unmarshalling into it.
parent - instance of JAXB mapped class that will reference target. null when target is root element.


Submit a bug or feature

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

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

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