org.extex.main.tex
Class ErrorHandlerImpl

java.lang.Object
  extended by org.extex.main.tex.ErrorHandlerImpl
All Implemented Interfaces:
LogEnabled, ErrorHandler
Direct Known Subclasses:
ErrorHandlerTeXImpl

public class ErrorHandlerImpl
extends java.lang.Object
implements ErrorHandler, LogEnabled

This is a simple implementation of the error handler interacting with the user on the command line like TeX does.

The HelpingException is capable of carrying a name and two arguments for the error message. This class can be queried to provide additional help concerning the error at hand. See HelpingException for details.

Version:
$Revision: 6447 $
Author:
Gerd Neugebauer

Field Summary
protected static java.lang.String NL
          The constant NL contains the String with the newline character, since it is needed several times.
 
Constructor Summary
ErrorHandlerImpl()
          Creates a new object.
 
Method Summary
 void enableLogging(java.util.logging.Logger theLogger)
          Setter for the logger.
protected  void handleDebug()
          Special treatment of the debug case.
 boolean handleError(GeneralException exception, Token t, TokenSource source, Context context)
          This is the error handling callback.
protected  java.lang.String promptAndReadLine(java.lang.String prompt)
          Read a line of characters from the standard input stream after a prompt has been shown.
 void setEditHandler(EditHandler editHandler)
          Setter for the edit handler.
protected  void showErrorLine(java.util.logging.Logger logger, java.lang.String message, Locator locator)
          This method is invoked to present the current line causing the error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NL

protected static final java.lang.String NL
The constant NL contains the String with the newline character, since it is needed several times.

See Also:
Constant Field Values
Constructor Detail

ErrorHandlerImpl

public ErrorHandlerImpl()
Creates a new object.

Method Detail

enableLogging

public void enableLogging(java.util.logging.Logger theLogger)
Setter for the logger.

Specified by:
enableLogging in interface LogEnabled
Parameters:
theLogger - the logger to use
See Also:
LogEnabled.enableLogging( java.util.logging.Logger)

handleDebug

protected void handleDebug()
                    throws HelpingException
Special treatment of the debug case. This method is meant to be redefined to provide additional functionality.

Throws:
HelpingException - in case of EOF on terminal
See Also:
"TTP[1338]"

handleError

public boolean handleError(GeneralException exception,
                           Token t,
                           TokenSource source,
                           Context context)
                    throws HelpingException
This is the error handling callback.

Specified by:
handleError in interface ErrorHandler
Parameters:
exception - the exception which has led to the invocation
t - the token leading to the error
source - the token source
context - the processor context
Returns:
true iff the processing can continue
Throws:
HelpingException - in case of en error
See Also:
ErrorHandler.handleError(org.extex.core.exception.GeneralException, org.extex.scanner.type.token.Token, org.extex.interpreter.TokenSource, org.extex.interpreter.context.Context)

promptAndReadLine

protected java.lang.String promptAndReadLine(java.lang.String prompt)
                                      throws HelpingException
Read a line of characters from the standard input stream after a prompt has been shown. Leading spaces are ignored. At end of file an exception is thrown.

Parameters:
prompt - the prompt to display
Returns:
the line read or null to signal EOF
Throws:
HelpingException - in case of EOF on terminal

setEditHandler

public void setEditHandler(EditHandler editHandler)
Setter for the edit handler.

Specified by:
setEditHandler in interface ErrorHandler
Parameters:
editHandler - the new edit handler
See Also:
ErrorHandler.setEditHandler( org.extex.interpreter.EditHandler)

showErrorLine

protected void showErrorLine(java.util.logging.Logger logger,
                             java.lang.String message,
                             Locator locator)
This method is invoked to present the current line causing the error.

Parameters:
logger - the logger to use for output
message - the error message
locator - the locator for the error position