ptolemy.vergil
Class VergilErrorHandler

java.lang.Object
  extended byptolemy.vergil.VergilErrorHandler
All Implemented Interfaces:
ErrorHandler

public class VergilErrorHandler
extends java.lang.Object
implements ErrorHandler

This error handler attempts to replace any failed MoML elements with generic versions so that the parsing of the MoML can continue. The generic versions, where appropriate, have icons that indicate failure.

Since:
Ptolemy II 2.0
Version:
$Id: VergilErrorHandler.java,v 1.23 2004/04/13 03:49:30 cxh Exp $
Author:
Edward A. Lee
Accepted Rating:
Red (reviewmoderator)
Proposed Rating:
Red (eal)

Field Summary
 
Fields inherited from interface ptolemy.moml.ErrorHandler
CANCEL, CONTINUE, RETHROW
 
Constructor Summary
VergilErrorHandler()
           
 
Method Summary
 void enableErrorSkipping(boolean enable)
          Enable or disable skipping of errors.
 int handleError(java.lang.String element, NamedObj context, java.lang.Throwable exception)
          Handle an error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VergilErrorHandler

public VergilErrorHandler()
Method Detail

enableErrorSkipping

public void enableErrorSkipping(boolean enable)
Enable or disable skipping of errors. If this method is called with a true argument, then do not report subsequent errors when handleError() is called, and instead return CONTINUE. If it is called with a false argument, then report all subsequent errors.

This method is intended to be used when an operation may trigger a large number of errors, and the user interface wishes to offer the user the option of ignoring them. This method should be called with a true argument before the operation begins, and then called with a false argument after the operation ends.

Specified by:
enableErrorSkipping in interface ErrorHandler
Parameters:
enable - True to enable skipping, false to disable.

handleError

public int handleError(java.lang.String element,
                       NamedObj context,
                       java.lang.Throwable exception)
Handle an error.

Specified by:
handleError in interface ErrorHandler
Parameters:
element - The XML element that triggered the error.
context - The container object for the element.
exception - The exception that was thrown.
Returns:
CONTINUE to skip this element, CANCEL to abort processing of the XML, IGNORE to continue to process the XML as if nothing had happened, or RETHROW to request that the exception be rethrown.