001/* Handle a MoML Parsing Error 002 003 Copyright (c) 2000-2013 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028package ptolemy.moml; 029 030import ptolemy.kernel.util.NamedObj; 031 032/////////////////////////////////////////////////////////////////// 033//// ErrorHandler 034 035/** 036 Interface for error handlers for the MoMLParser class. 037 038 @see MoMLParser 039 @author Edward A. Lee 040 @version $Id$ 041 @since Ptolemy II 1.0 042 @Pt.ProposedRating Red (eal) 043 @Pt.AcceptedRating Red (reviewmoderator) 044 */ 045public interface ErrorHandler { 046 /////////////////////////////////////////////////////////////////// 047 //// public methods //// 048 049 /** Enable or disable skipping of errors. 050 * If this method is called with a true argument, then an implementation 051 * of this interface may ignore subsequent errors by returning 052 * CONTINUE in handleError() without reporting the error. 053 * If it is called with a false argument, then the implementation 054 * is expected to report all subsequent errors (but it is not 055 * required to do so). 056 * <p> 057 * This method is intended to be used when an operation may trigger 058 * a large number of errors, and the user interface wishes to offer 059 * the user the option of ignoring them. This method should be 060 * called with a true argument before the operation begins, and 061 * then called with a false argument after the operation ends. 062 * @param enable True to enable skipping, false to disable. 063 */ 064 public void enableErrorSkipping(boolean enable); 065 066 /** Handle an error. 067 * @param element The XML element that triggered the error. 068 * @param context The container object for the element. 069 * @param exception The exception that was thrown. 070 * @return CONTINUE to skip this element, CANCEL to abort processing 071 * of the XML, or RETHROW to request that the exception be rethrown. 072 */ 073 public int handleError(String element, NamedObj context, 074 Throwable exception); 075 076 /////////////////////////////////////////////////////////////////// 077 //// public members //// 078 079 /** Indicator to skip this element and continue parsing XML. */ 080 public static final int CONTINUE = 0; 081 082 /** Indicator to cancel parsing XML. */ 083 public static final int CANCEL = 1; 084 085 /** Indicator to request that the exception be rethrown. */ 086 public static final int RETHROW = 3; 087}