org.apache.commons.math
Class MathException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.apache.commons.math.MathException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CardanEulerSingularityException, ConvergenceException, CostException, DerivativeException, DimensionMismatchException, DuplicateSampleAbscissaException, EstimationException, FunctionEvaluationException, IntegratorException, MathConfigurationException, NotARotationMatrixException, NotPositiveDefiniteMatrixException

public class MathException
extends java.lang.Exception

Base class for commons-math checked exceptions.

Supports nesting, emulating JDK 1.4 behavior if necessary.

Adapted from org.apache.commons.collections.FunctorException.

Version:
$Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
See Also:
Serialized Form

Field Summary
private  java.lang.Object[] arguments
          Arguments used to build the message.
private static java.util.ResourceBundle cachedResources
          Cache for resources bundle.
private static boolean JDK_SUPPORTS_NESTED
          Does JDK support nested exceptions?
private  java.lang.String pattern
          Pattern used to build the message.
private  java.lang.Throwable rootCause
          Root cause of the exception
private static long serialVersionUID
          Serializable version identifier
 
Constructor Summary
MathException()
          Constructs a new MathException with no detail message.
MathException(java.lang.String msg)
          Deprecated. as of 1.2, replaced by MathException(String, Object[])
MathException(java.lang.String pattern, java.lang.Object[] arguments)
          Constructs a new MathException with specified formatted detail message.
MathException(java.lang.String pattern, java.lang.Object[] arguments, java.lang.Throwable rootCause)
          Constructs a new MathException with specified formatted detail message and nested Throwable root cause.
MathException(java.lang.String msg, java.lang.Throwable rootCause)
          Deprecated. as of 1.2, replaced by MathException(String, Object[], Throwable)
MathException(java.lang.Throwable rootCause)
          Constructs a new MathException with specified nested Throwable root cause.
 
Method Summary
private static java.lang.String buildMessage(java.lang.String pattern, java.lang.Object[] arguments, java.util.Locale locale)
          Builds a message string by from a pattern and its arguments.
 java.lang.Object[] getArguments()
          Gets the arguments used to build the message of this throwable.
 java.lang.Throwable getCause()
          Gets the cause of this throwable.
 java.lang.String getMessage(java.util.Locale locale)
          Gets the message in a specified locale.
 java.lang.String getPattern()
          Gets the pattern used to build the message of this throwable.
 void printStackTrace()
          Prints the stack trace of this exception to the standard error stream.
 void printStackTrace(java.io.PrintStream out)
          Prints the stack trace of this exception to the specified stream.
 void printStackTrace(java.io.PrintWriter out)
          Prints the stack trace of this exception to the specified writer.
private static java.lang.String translate(java.lang.String s, java.util.Locale locale)
          Translate a string to a given locale.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, initCause, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serializable version identifier

See Also:
Constant Field Values

JDK_SUPPORTS_NESTED

private static final boolean JDK_SUPPORTS_NESTED
Does JDK support nested exceptions?


cachedResources

private static java.util.ResourceBundle cachedResources
Cache for resources bundle.


pattern

private final java.lang.String pattern
Pattern used to build the message.


arguments

private final java.lang.Object[] arguments
Arguments used to build the message.


rootCause

private final java.lang.Throwable rootCause
Root cause of the exception

Constructor Detail

MathException

public MathException()
Constructs a new MathException with no detail message.


MathException

public MathException(java.lang.String msg)
Deprecated. as of 1.2, replaced by MathException(String, Object[])

Constructs a new MathException with specified detail message.

Parameters:
msg - the error message.

MathException

public MathException(java.lang.String pattern,
                     java.lang.Object[] arguments)
Constructs a new MathException with specified formatted detail message. Message formatting is delegated to MessageFormat.

Parameters:
pattern - format specifier
arguments - format arguments

MathException

public MathException(java.lang.Throwable rootCause)
Constructs a new MathException with specified nested Throwable root cause.

Parameters:
rootCause - the exception or error that caused this exception to be thrown.

MathException

public MathException(java.lang.String msg,
                     java.lang.Throwable rootCause)
Deprecated. as of 1.2, replaced by MathException(String, Object[], Throwable)

Constructs a new MathException with specified detail message and nested Throwable root cause.

Parameters:
msg - the error message.
rootCause - the exception or error that caused this exception to be thrown.

MathException

public MathException(java.lang.String pattern,
                     java.lang.Object[] arguments,
                     java.lang.Throwable rootCause)
Constructs a new MathException with specified formatted detail message and nested Throwable root cause. Message formatting is delegated to MessageFormat.

Parameters:
pattern - format specifier
arguments - format arguments
rootCause - the exception or error that caused this exception to be thrown.
Since:
1.2
Method Detail

translate

private static java.lang.String translate(java.lang.String s,
                                          java.util.Locale locale)
Translate a string to a given locale.

Parameters:
s - string to translate
locale - locale into which to translate the string
Returns:
translated string or original string for unsupported locales or unknown strings

buildMessage

private static java.lang.String buildMessage(java.lang.String pattern,
                                             java.lang.Object[] arguments,
                                             java.util.Locale locale)
Builds a message string by from a pattern and its arguments.

Parameters:
pattern - format specifier
arguments - format arguments
locale - Locale in which the message should be translated
Returns:
a message string

getPattern

public java.lang.String getPattern()
Gets the pattern used to build the message of this throwable.

Returns:
the pattern used to build the message of this throwable
Since:
1.2

getArguments

public java.lang.Object[] getArguments()
Gets the arguments used to build the message of this throwable.

Returns:
the arguments used to build the message of this throwable
Since:
1.2

getMessage

public java.lang.String getMessage(java.util.Locale locale)
Gets the message in a specified locale.

Parameters:
locale - Locale in which the message should be translated
Returns:
localized message
Since:
1.2

getCause

public java.lang.Throwable getCause()
Gets the cause of this throwable.

Overrides:
getCause in class java.lang.Throwable
Returns:
the cause of this throwable, or null

printStackTrace

public void printStackTrace()
Prints the stack trace of this exception to the standard error stream.

Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(java.io.PrintStream out)
Prints the stack trace of this exception to the specified stream.

Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
out - the PrintStream to use for output

printStackTrace

public void printStackTrace(java.io.PrintWriter out)
Prints the stack trace of this exception to the specified writer.

Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
out - the PrintWriter to use for output