All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.roguewave.money.currency.v1_0.DefaultErrorHandler

java.lang.Object
   |
   +----com.roguewave.money.currency.v1_0.DefaultErrorHandler

public class DefaultErrorHandler
extends Object
implements ErrorHandler
The DefaultErrorHandler class implements the flexible ErrorHandler interface. It provides a simple mechanism to handle errors in three ways: silently, with a warning or with an exception. In addition, one can choose which operations should be handled in which fashion.

For example, if a user wanted all imprecise exceptions during division to illicit a warning:

 ((DefaultErrorHandler)MoneyException.getErrorHandler()).setAction(MoneyException.PRECISION_EXCEEDED, MoneyException.DIVISION, DefaultErrorHandler.WARNING);
 

Author:
Trevor Misfeldt
See Also:
ErrorHandler, MoneyException, PrecisionExceededException, InvalidExchangeException, MismatchedCurrenciesException

Variable Index

 o DEFAULT_BEHAVIOR
Default behavior is to throw an exception.
 o DEFAULT_STREAM
The default error stream is System.err.
 o EXCEPTION
Throws an exception.
 o SILENT
Ignore the error completely.
 o WARNING
Generates a warning message to the specified print stream.

Method Index

 o getAction(short, short)
Returns the action for a certain exception and operation type.
 o getStream()
Returns the current error stream.
 o handleError(MoneyException)
Handles the money exception depending on the actions specified.
 o initialize()
Initializes this handler to the default behavior which is to throw an exception for all errors.
 o setAction(short, short, short)
Sets the action to be taken for a certain error type during a certain operation.
 o setActionByOperation(short, short)
Sets the action to be taken for a certain operation.
 o setActionByType(short, short)
Sets the action to be taken for a certain error type.
 o setActions(short)
Sets the action to be taken for all error types and operations.
 o setStream(PrintStream)
Sets the error stream.

Variables

 o SILENT
 public static final short SILENT
Ignore the error completely.

 o WARNING
 public static final short WARNING
Generates a warning message to the specified print stream. Note: The stream is not flushed or closed after a message is written.

See Also:
DEFAULT_STREAM, setStream
 o EXCEPTION
 public static final short EXCEPTION
Throws an exception.

 o DEFAULT_BEHAVIOR
 public static final short DEFAULT_BEHAVIOR
Default behavior is to throw an exception.

See Also:
EXCEPTION
 o DEFAULT_STREAM
 public static PrintStream DEFAULT_STREAM
The default error stream is System.err.

See Also:
setStream

Methods

 o handleError
 public void handleError(MoneyException exception)
Handles the money exception depending on the actions specified.

Parameters:
exception - error which warrants a decision as to the appropriate action
See Also:
MoneyException
 o initialize
 public static void initialize()
Initializes this handler to the default behavior which is to throw an exception for all errors.

See Also:
DEFAULT_BEHAVIOR
 o setActions
 public static void setActions(short action)
Sets the action to be taken for all error types and operations.

Parameters:
action - the desired behavior
See Also:
SILENT, WARNING, EXCEPTION
 o setActionByType
 public static void setActionByType(short exception,
                                    short action)
Sets the action to be taken for a certain error type.

Parameters:
exception - the error type
action - the desired behavior
See Also:
PRECISION_EXCEEDED, INVALID_EXCHANGE, MISMATCHED_CURRENCIES, SILENT, WARNING, EXCEPTION
 o setActionByOperation
 public static void setActionByOperation(short operation,
                                         short action)
Sets the action to be taken for a certain operation.

Parameters:
operation - the operation type
action - the desired behavior
See Also:
EXCHANGE, ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION, COMPARISON, SILENT, WARNING, EXCEPTION
 o setAction
 public static void setAction(short exception,
                              short operation,
                              short action)
Sets the action to be taken for a certain error type during a certain operation.

Parameters:
exception - the error type
operation - the operation type
action - the desired behavior
See Also:
PRECISION_EXCEEDED, INVALID_EXCHANGE, MISMATCHED_CURRENCIES, EXCHANGE, ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION, COMPARISON, SILENT, WARNING, EXCEPTION
 o getAction
 public static short getAction(short exception,
                               short operation)
Returns the action for a certain exception and operation type.

Parameters:
exception - the error type
operation - the operation type
Returns:
the current behavior
See Also:
PRECISION_EXCEEDED, INVALID_EXCHANGE, MISMATCHED_CURRENCIES, EXCHANGE, ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION, COMPARISON, SILENT, WARNING, EXCEPTION
 o getStream
 public static PrintStream getStream()
Returns the current error stream.

Returns:
the stream
See Also:
DEFAULT_STREAM
 o setStream
 public static void setStream(PrintStream stream)
Sets the error stream.

Parameters:
stream - the desired error stream for warning messages
See Also:
DEFAULT_STREAM

All Packages  Class Hierarchy  This Package  Previous  Next  Index