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
-
DEFAULT_BEHAVIOR
- Default behavior is to throw an exception.
-
DEFAULT_STREAM
- The default error stream is
System.err
.
-
EXCEPTION
- Throws an exception.
-
SILENT
- Ignore the error completely.
-
WARNING
- Generates a warning message to the specified print stream.
-
getAction(short, short)
- Returns the action for a certain exception and operation type.
-
getStream()
- Returns the current error stream.
-
handleError(MoneyException)
- Handles the money exception depending on the actions specified.
-
initialize()
- Initializes this handler to the default behavior which is to throw an
exception for all errors.
-
setAction(short, short, short)
- Sets the action to be taken for a certain error type during a certain operation.
-
setActionByOperation(short, short)
- Sets the action to be taken for a certain operation.
-
setActionByType(short, short)
- Sets the action to be taken for a certain error type.
-
setActions(short)
- Sets the action to be taken for all error types and operations.
-
setStream(PrintStream)
- Sets the error stream.
SILENT
public static final short SILENT
- Ignore the error completely.
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
EXCEPTION
public static final short EXCEPTION
- Throws an exception.
DEFAULT_BEHAVIOR
public static final short DEFAULT_BEHAVIOR
- Default behavior is to throw an exception.
- See Also:
- EXCEPTION
DEFAULT_STREAM
public static PrintStream DEFAULT_STREAM
- The default error stream is
System.err
.
- See Also:
- setStream
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
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
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
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
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
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
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
getStream
public static PrintStream getStream()
- Returns the current error stream.
- Returns:
- the stream
- See Also:
- DEFAULT_STREAM
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