Package com.upokecenter.numbers
Class ETrapException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.ArithmeticException
-
- com.upokecenter.numbers.ETrapException
-
- All Implemented Interfaces:
java.io.Serializable
public final class ETrapException extends java.lang.ArithmeticExceptionException thrown for arithmetic trap errors. (The "E" stands for "extended", and has this prefix to group it with the other classes common to this library, particularly EDecimal, EFloat, and ERational.).This library may throw exceptions of this type in certain cases, notably when errors occur, and may supply messages to those exceptions (the message can be accessed through the
Messageproperty in.NET or thegetMessage()method in Java). These messages are intended to be read by humans to help diagnose the error (or other cause of the exception); they are not intended to be parsed by computer programs, and the exact text of the messages may change at any time between versions of this library.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ETrapException()Initializes a new instance of theETrapExceptionclass.ETrapException(int flags, int flag, EContext ctx, java.lang.Object result)Initializes a new instance of theETrapExceptionclass.ETrapException(int flag, EContext ctx, java.lang.Object result)Initializes a new instance of theETrapExceptionclass.ETrapException(java.lang.String message)Initializes a new instance of theETrapExceptionclass.ETrapException(java.lang.String message, java.lang.Throwable innerException)Initializes a new instance of theETrapExceptionclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EContextgetContext()Gets the arithmetic context used during the operation that triggered the trap.intgetError()Gets the flag that specifies the primary kind of error in one or more operations (EContext.FlagXXX).intgetErrors()Gets the flags that were signaled as the result of one or more operations.java.lang.ObjectgetResult()Gets the defined result of the operation that caused the trap.booleanHasError(int flag)Returns whether this trap exception specifies all the flags given.
-
-
-
Constructor Detail
-
ETrapException
public ETrapException()
Initializes a new instance of theETrapExceptionclass.
-
ETrapException
public ETrapException(java.lang.String message)
Initializes a new instance of theETrapExceptionclass.- Parameters:
message- The parametermessageis a text string.
-
ETrapException
public ETrapException(java.lang.String message, java.lang.Throwable innerException)Initializes a new instance of theETrapExceptionclass.- Parameters:
message- The parametermessageis a text string.innerException- The parameterinnerExceptionis an Exception object.
-
ETrapException
public ETrapException(int flag, EContext ctx, java.lang.Object result)Initializes a new instance of theETrapExceptionclass.- Parameters:
flag- The flag that specifies the kind of error from one or more operations (EContext.FlagXXX). This will only be one flag, such asFlagInexactor FlagSubnormal.ctx- The arithmetic context used during the operation that triggered the trap. Can be null.result- The defined result of the operation that caused the trap.
-
ETrapException
public ETrapException(int flags, int flag, EContext ctx, java.lang.Object result)Initializes a new instance of theETrapExceptionclass.- Parameters:
flags- Specifies the flags that were signaled as the result of one or more operations. This includes the flag specified in the "flag" parameter, but can include other flags. For instance, if "flag" isEContext.FlagInexact, this parameter might beEContext.FlagInexact | EContext.FlagRounded.flag- Specifies the flag that specifies the primary kind of error from one or more operations (EContext.FlagXXX). This will only be one flag, such asFlagInexactor FlagSubnormal.ctx- The arithmetic context used during the operation that triggered the trap. Can be null.result- The defined result of the operation that caused the trap.- Throws:
java.lang.IllegalArgumentException- The parameterflagsdoesn't include all the flags in theflagparameter.
-
-
Method Detail
-
getContext
public final EContext getContext()
Gets the arithmetic context used during the operation that triggered the trap. May be null.- Returns:
- The arithmetic context used during the operation that triggered the trap. May be null.
-
getResult
public final java.lang.Object getResult()
Gets the defined result of the operation that caused the trap.- Returns:
- The defined result of the operation that caused the trap.
-
getError
public final int getError()
Gets the flag that specifies the primary kind of error in one or more operations (EContext.FlagXXX). This will only be one flag, such asFlagInexactor FlagSubnormal.- Returns:
- The flag that specifies the primary kind of error in one or more operations.
-
getErrors
public final int getErrors()
Gets the flags that were signaled as the result of one or more operations. This includes the flag specified in the "flag" parameter, but can include other flags. For instance, if "flag" isEContext.FlagInexact, this parameter might beEContext.FlagInexact | EContext.FlagRounded.- Returns:
- The flags that specify the errors in one or more operations.
-
HasError
public boolean HasError(int flag)
Returns whether this trap exception specifies all the flags given. (Flags are signaled in a trap exception as the result of one or more operations involving arbitrary-precision numbers, such as multiplication of two EDecimals.).- Parameters:
flag- A combination of one or more flags, such asEContext.FlagInexact | EContext.FlagRounded.- Returns:
- True if this exception pertains to all of the flags given in
flag; otherwise, false.
-
-