|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.xml.bind Interface ValidationEventHandler
- All Known Implementing Classes:
- DefaultValidationEventHandler, ValidationEventCollector
public interface ValidationEventHandler
用来验证错误的基本事件处理程序接口。
如果应用程序需要实现自定义事件处理,那么它必须实现此接口,然后向 Unmarshaller
、Validator
或 Marshaller
注册。JAXB 提供者随后将向这些事件处理程序报告在执行解组、编组和验证操作期间遇到的验证错误和警告。
如果 handleEvent 方法抛出未经检查的运行时异常,则 JAXB 提供者必须像该方法返回 false 那样作出相应对待,有效地终止当时正在运行的任何操作(解组、验证或编组)。
在事件处理程序中修改 Java 内容树不是规范中定义的行为,并且可能导致不可预料的行为。
遇到致命错误后未能从 handleEvent 方法返回 false 也不是一种规范中定义的行为,并且可能导致不可预料的行为。
默认事件处理程序
请参阅:Validator javadocs
version |
| |
since | JAXB1.0 | |
See also | javax.xml.bind.Unmarshaller, javax.xml.bind.Validator, javax.xml.bind.Marshaller, javax.xml.bind.ValidationEvent, javax.xml.bind.util.ValidationEventCollector |
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
- Since:
- JAXB1.0
- Version:
- $Revision: 1.1 $
- Author:
- Ryan Shoemaker, Sun Microsystems, Inc.
- Kohsuke Kawaguchi, Sun Microsystems, Inc.
- Joe Fialli, Sun Microsystems, Inc.
- See Also:
Unmarshaller
,Validator
,Marshaller
,ValidationEvent
,ValidationEventCollector
Method Summary | |
---|---|
boolean |
handleEvent(ValidationEvent event)
Receive notification of a validation warning or error. |
Method Detail |
---|
public boolean
handleEvent(ValidationEvent event)
接收验证警告或错误的通知。ValidationEvent 将 ValidationEventLocator
嵌入通知中,以指示发生错误或警告的位置。
如果从此方法抛出未经检查的运行时异常,则 JAXB 提供者会像该方法返回 false 那样作出相应对待,并中断当前的解组、验证和编组操作。
event | 封装的验证事件信息。如果为 null,则该信息是一个提供者错误。 |
return | 如果 JAXB 提供者应该在处理此警告/错误之后尝试继续执行当前的解组、验证或编组操作,则返回 true;如果提供者应该使用适当的 UnmarshalException、ValidationException 或 MarshalException 终止当前操作,则返回 false。 |
Throws | IllegalArgumentException: 如果事件对象为 null。 |
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.
- 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.
- Throws:
IllegalArgumentException
- if the event object is null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!