ValidationEventHandler (Java EE 5 SDK)

Java

Java EE 5 SDK

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


javax.xml.bind Interface ValidationEventHandler

所有已知实现子孙类:
DefaultValidationEventHandler, ValidationEventCollector

public interface ValidationEventHandler

A basic event handler interface for validation errors.

If an application needs to implement customized event handling, it must implement this interface and then register it with either the Unmarshaller, the Validator, or the Marshaller. The JAXB Provider will then report validation errors and warnings encountered during the unmarshal, marshal, and validate operations to these event handlers.

If the handleEvent method throws an unchecked runtime exception, the JAXB Provider must treat that as if the method returned false, effectively terminating whatever operation was in progress at the time (unmarshal, validate, or marshal).

Modifying the Java content tree within your event handler is undefined by the specification and may result in unexpected behaviour.

Failing to return false from the handleEvent method after encountering a fatal error is undefined by the specification and may result in unexpected behavior.

Default Event Handler

See: Validator javadocs

从以下版本开始:
JAXB1.0
版本:
$Revision: 1.1 $
作者:
  • Ryan Shoemaker, Sun Microsystems, Inc.
  • Kohsuke Kawaguchi, Sun Microsystems, Inc.
  • Joe Fialli, Sun Microsystems, Inc.
另请参见:
Unmarshaller, Validator, Marshaller, ValidationEvent, ValidationEventCollector

方法摘要
 boolean handleEvent(ValidationEvent event)
          Receive notification of a validation warning or error.
 

方法详细信息

handleEvent

boolean handleEvent(ValidationEvent event)
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.

参数:
event - the encapsulated validation event information. It is a provider error if this parameter is null.
返回:
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.
抛出异常:
IllegalArgumentException - if the event object is null.

Java EE 5 SDK

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


提交错误或意见

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