ValidationEventCollector (Java EE 5)

Java EE API


javax.xml.bind.util Class ValidationEventCollector

java.lang.Object
  extended by javax.xml.bind.util.ValidationEventCollector
All Implemented Interfaces:
ValidationEventHandler

public class ValidationEventCollector
extends Object
implements ValidationEventHandler


收集所有事件的 ValidationEventHandler 实现。

要使用此类,则需要创建一个新实例并将其传递给 Validator、Unmarshaller 和 Marshaller 类的 setEventHandler 方法。完成对验证和解组的调用之后,调用 getEvents 方法来检索所有报告的错误和警告。

英文文档:

ValidationEventHandler implementation that collects all events.

To use this class, create a new instance and pass it to the setEventHandler method of the Validator, Unmarshaller, Marshaller class. After the call to validate or unmarshal completes, call the getEvents method to retrieve all the reported errors and warnings.

Since:
JAXB1.0
Version:
$Revision: 1.2 $
Author:
  • Kohsuke Kawaguchi, Sun Microsystems, Inc.
  • Ryan Shoemaker, Sun Microsystems, Inc.
  • Joe Fialli, Sun Microsystems, Inc.
See Also:
Validator, ValidationEventHandler, ValidationEvent, ValidationEventLocator

Constructor Summary
 
Method Summary
 ValidationEvent[]
 boolean
 boolean
 void
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public ValidationEventCollector()
英文文档:

ValidationEventCollector

public ValidationEventCollector()
Method Detail

public ValidationEvent[] getEvents()
返回一个 ValidationEvent 对象数组,这些对象包含所有收集的错误和警告的副本。
return 所有收集的错误和警告的副本;如果没有收集的错误和警告,则返回一个空数组
英文文档:

getEvents

public ValidationEvent[] getEvents()
Return an array of ValidationEvent objects containing a copy of each of the collected errors and warnings.

Returns:
a copy of all the collected errors and warnings or an empty array if there weren't any

public void reset()
清除所有收集的错误和警告。
英文文档:

reset

public void reset()
Clear all collected errors and warnings.


public boolean hasEvents()
如果此事件收集器至少包含一个 ValidationEvent,则返回 true。
return 如果此事件收集器至少包含一个 ValidationEvent,则返回 true,否则返回 false
英文文档:

hasEvents

public boolean hasEvents()
Returns true if this event collector contains at least one ValidationEvent.

Returns:
true if this event collector contains at least one ValidationEvent, false otherwise

public boolean handleEvent(ValidationEvent event)
英文文档:

handleEvent

public boolean handleEvent(ValidationEvent event)
Description copied from interface: ValidationEventHandler
Receive notification of a validation warning or error. The ValidationEvent will have a ValidationEventLocator embedded in it that indicates where the error or warning occurred.

If an unchecked runtime exception is thrown from this method, the JAXB provider will treat it as if the method returned false and interrupt the current unmarshal, validate, or marshal operation.

Specified by:
handleEvent in interface ValidationEventHandler
Parameters:
event - the encapsulated validation event information. It is a provider error if this parameter is null.
Returns:
true if the JAXB Provider should attempt to continue the current unmarshal, validate, or marshal operation after handling this warning/error, false if the provider should terminate the current operation with the appropriate UnmarshalException, ValidationException, or MarshalException.


Submit a bug or feature

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

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

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