Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventHandler.java
38890 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.bind;2627/**28* A basic event handler interface for validation errors.29*30* <p>31* If an application needs to implement customized event handling, it must32* implement this interface and then register it with either the33* {@link Unmarshaller#setEventHandler(ValidationEventHandler) Unmarshaller},34* the {@link Validator#setEventHandler(ValidationEventHandler) Validator}, or35* the {@link Marshaller#setEventHandler(ValidationEventHandler) Marshaller}.36* The JAXB Provider will then report validation errors and warnings encountered37* during the unmarshal, marshal, and validate operations to these event38* handlers.39*40* <p>41* If the <tt>handleEvent</tt> method throws an unchecked runtime exception,42* the JAXB Provider must treat that as if the method returned false, effectively43* terminating whatever operation was in progress at the time (unmarshal,44* validate, or marshal).45*46* <p>47* Modifying the Java content tree within your event handler is undefined48* by the specification and may result in unexpected behaviour.49*50* <p>51* Failing to return false from the <tt>handleEvent</tt> method after52* encountering a fatal error is undefined by the specification and may result53* in unexpected behavior.54*55* <p>56* <b>Default Event Handler</b>57* <blockquote>58* See: <a href="Validator.html#defaulthandler">Validator javadocs</a>59* </blockquote>60*61* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>62* @see Unmarshaller63* @see Validator64* @see Marshaller65* @see ValidationEvent66* @see javax.xml.bind.util.ValidationEventCollector67* @since JAXB1.068*/69public interface ValidationEventHandler {70/**71* Receive notification of a validation warning or error.72*73* The ValidationEvent will have a74* {@link ValidationEventLocator ValidationEventLocator} embedded in it that75* indicates where the error or warning occurred.76*77* <p>78* If an unchecked runtime exception is thrown from this method, the JAXB79* provider will treat it as if the method returned false and interrupt80* the current unmarshal, validate, or marshal operation.81*82* @param event the encapsulated validation event information. It is a83* provider error if this parameter is null.84* @return true if the JAXB Provider should attempt to continue the current85* unmarshal, validate, or marshal operation after handling this86* warning/error, false if the provider should terminate the current87* operation with the appropriate <tt>UnmarshalException</tt>,88* <tt>ValidationException</tt>, or <tt>MarshalException</tt>.89* @throws IllegalArgumentException if the event object is null.90*/91public boolean handleEvent( ValidationEvent event );9293}949596