edu.princeton.toy.lang
Class TDefaultExceptionHandler

java.lang.Object
  extended by edu.princeton.toy.lang.TDefaultExceptionHandler
All Implemented Interfaces:
TExceptionHandler

public class TDefaultExceptionHandler
extends Object
implements TExceptionHandler

TDefaultExceptionHandler is the simplest mutable implementation of TExceptionHandler.


Field Summary
 
Fields inherited from interface edu.princeton.toy.lang.TExceptionHandler
PROMISCUOUS_EXCEPTION_HANDLER, PRUDISH_EXCEPTION_HANDLER
 
Constructor Summary
TDefaultExceptionHandler()
          Instantiates a new TDefaultExceptionHandler in an exceptionless state.
 
Method Summary
 boolean getWillThrow(int index)
          Gets wheter or not the handler should throw a raised exception of the specified type.
 boolean getWillThrow(TExceptionType type)
          Gets wheter or not the handler should throw a raised exception of the specified type.
 void raise(TExceptionType type)
          Throws a TException with the specified type iff the specified exception was not set to be ignored.
 void setWillThrow(int index, boolean willThrow)
          Sets wheter or not the handler should throw a raised exception of the specified type.
 void setWillThrow(TExceptionType type, boolean willThrow)
          Sets wheter or not the handler should throw a raised exception of the specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TDefaultExceptionHandler

public TDefaultExceptionHandler()
Instantiates a new TDefaultExceptionHandler in an exceptionless state.

Method Detail

raise

public void raise(TExceptionType type)
           throws TException
Throws a TException with the specified type iff the specified exception was not set to be ignored. The Virtual Machine should raise all exceptional conditions and let the handler decide wheter or not that exception should be propagated through the rest of the machine.

Specified by:
raise in interface TExceptionHandler
Parameters:
type - The type of exceptional condition that was raised in the Virtual Machine.
Throws:
TException

getWillThrow

public boolean getWillThrow(int index)
Gets wheter or not the handler should throw a raised exception of the specified type.

Specified by:
getWillThrow in interface TExceptionHandler
Parameters:
index - The index of type (in the TExceptionType.TYPES array) in question. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
True iff the handler will throw exceptions of this type.
See Also:
TExceptionType.TYPES

getWillThrow

public boolean getWillThrow(TExceptionType type)
Gets wheter or not the handler should throw a raised exception of the specified type.

Specified by:
getWillThrow in interface TExceptionHandler
Parameters:
index - The type in question. A null value will result in a NullPointerException.
Returns:
True iff the handler will throw exceptions of this type.
See Also:
TExceptionType.TYPES

setWillThrow

public void setWillThrow(TExceptionType type,
                         boolean willThrow)
Sets wheter or not the handler should throw a raised exception of the specified type.

Parameters:
index - The type in question. A null value will result in a NullPointerException.
willThrow - Wheter or not the handler should throw exceptions of this type.
See Also:
TExceptionType.TYPES

setWillThrow

public void setWillThrow(int index,
                         boolean willThrow)
Sets wheter or not the handler should throw a raised exception of the specified type.

Parameters:
index - The index of type (in the TExceptionType.TYPES array) in question. An invalid value will result in an ArrayIndexOutOfBoundsException.
willThrow - Wheter or not the handler should throw exceptions of this type.
See Also:
TExceptionType.TYPES