ohair@286: /* mkos@397: * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@286: * ohair@286: * This code is free software; you can redistribute it and/or modify it ohair@286: * under the terms of the GNU General Public License version 2 only, as ohair@286: * published by the Free Software Foundation. Oracle designates this ohair@286: * particular file as subject to the "Classpath" exception as provided ohair@286: * by Oracle in the LICENSE file that accompanied this code. ohair@286: * ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@286: * version 2 for more details (a copy is included in the LICENSE file that ohair@286: * accompanied this code). ohair@286: * ohair@286: * You should have received a copy of the GNU General Public License version ohair@286: * 2 along with this work; if not, write to the Free Software Foundation, ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@286: * ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@286: * or visit www.oracle.com if you need additional information or have any ohair@286: * questions. ohair@286: */ ohair@286: ohair@286: package javax.xml.bind; ohair@286: ohair@286: /** ohair@286: * A basic event handler interface for validation errors. ohair@286: * ohair@286: *

ohair@286: * If an application needs to implement customized event handling, it must ohair@286: * implement this interface and then register it with either the ohair@286: * {@link Unmarshaller#setEventHandler(ValidationEventHandler) Unmarshaller}, ohair@286: * the {@link Validator#setEventHandler(ValidationEventHandler) Validator}, or ohair@286: * the {@link Marshaller#setEventHandler(ValidationEventHandler) Marshaller}. ohair@286: * The JAXB Provider will then report validation errors and warnings encountered ohair@286: * during the unmarshal, marshal, and validate operations to these event ohair@286: * handlers. ohair@286: * ohair@286: *

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

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

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

ohair@286: * Default Event Handler ohair@286: *

ohair@286: * See: Validator javadocs ohair@286: *
ohair@286: * ohair@286: * @author ohair@286: * @see Unmarshaller ohair@286: * @see Validator ohair@286: * @see Marshaller ohair@286: * @see ValidationEvent ohair@286: * @see javax.xml.bind.util.ValidationEventCollector ohair@286: * @since JAXB1.0 ohair@286: */ ohair@286: public interface ValidationEventHandler { ohair@286: /** ohair@286: * Receive notification of a validation warning or error. ohair@286: * ohair@286: * The ValidationEvent will have a ohair@286: * {@link ValidationEventLocator ValidationEventLocator} embedded in it that ohair@286: * indicates where the error or warning occurred. ohair@286: * ohair@286: *

ohair@286: * If an unchecked runtime exception is thrown from this method, the JAXB ohair@286: * provider will treat it as if the method returned false and interrupt ohair@286: * the current unmarshal, validate, or marshal operation. ohair@286: * ohair@286: * @param event the encapsulated validation event information. It is a ohair@286: * provider error if this parameter is null. ohair@286: * @return true if the JAXB Provider should attempt to continue the current ohair@286: * unmarshal, validate, or marshal operation after handling this ohair@286: * warning/error, false if the provider should terminate the current ohair@286: * operation with the appropriate UnmarshalException, ohair@286: * ValidationException, or MarshalException. ohair@286: * @throws IllegalArgumentException if the event object is null. ohair@286: */ ohair@286: public boolean handleEvent( ValidationEvent event ); ohair@286: ohair@286: }