mirror of
https://github.com/apache/commons-math.git
synced 2025-02-07 18:49:40 +00:00
remove pre Java 1.4 emulation stuff as we now need at least Java 5
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@710166 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e143e9097d
commit
89b21145fb
@ -67,11 +67,6 @@ public class MathException extends Exception {
|
|||||||
*/
|
*/
|
||||||
private final Object[] arguments;
|
private final Object[] arguments;
|
||||||
|
|
||||||
/**
|
|
||||||
* Root cause of the exception
|
|
||||||
*/
|
|
||||||
private final Throwable rootCause;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a string to a given locale.
|
* Translate a string to a given locale.
|
||||||
* @param s string to translate
|
* @param s string to translate
|
||||||
@ -110,10 +105,7 @@ public class MathException extends Exception {
|
|||||||
* @return a message string
|
* @return a message string
|
||||||
*/
|
*/
|
||||||
private static String buildMessage(String pattern, Object[] arguments, Locale locale) {
|
private static String buildMessage(String pattern, Object[] arguments, Locale locale) {
|
||||||
// do it the hard way, for Java 1.3. compatibility
|
return new MessageFormat(translate(pattern, locale), locale).format(arguments);
|
||||||
MessageFormat mf = new MessageFormat(translate(pattern, locale));
|
|
||||||
mf.setLocale(locale);
|
|
||||||
return mf.format(arguments);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,7 +116,6 @@ public class MathException extends Exception {
|
|||||||
super();
|
super();
|
||||||
this.pattern = null;
|
this.pattern = null;
|
||||||
this.arguments = new Object[0];
|
this.arguments = new Object[0];
|
||||||
this.rootCause = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,7 +129,6 @@ public class MathException extends Exception {
|
|||||||
super(buildMessage(pattern, arguments, Locale.US));
|
super(buildMessage(pattern, arguments, Locale.US));
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.arguments = (Object[]) arguments.clone();
|
this.arguments = (Object[]) arguments.clone();
|
||||||
this.rootCause = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,10 +139,9 @@ public class MathException extends Exception {
|
|||||||
* to be thrown.
|
* to be thrown.
|
||||||
*/
|
*/
|
||||||
public MathException(Throwable rootCause) {
|
public MathException(Throwable rootCause) {
|
||||||
super((rootCause == null ? null : rootCause.getMessage()));
|
super(rootCause);
|
||||||
this.pattern = getMessage();
|
this.pattern = getMessage();
|
||||||
this.arguments = new Object[0];
|
this.arguments = new Object[0];
|
||||||
this.rootCause = rootCause;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,10 +155,9 @@ public class MathException extends Exception {
|
|||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public MathException(String pattern, Object[] arguments, Throwable rootCause) {
|
public MathException(String pattern, Object[] arguments, Throwable rootCause) {
|
||||||
super(buildMessage(pattern, arguments, Locale.US));
|
super(buildMessage(pattern, arguments, Locale.US), rootCause);
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.arguments = (Object[]) arguments.clone();
|
this.arguments = (Object[]) arguments.clone();
|
||||||
this.rootCause = rootCause;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the pattern used to build the message of this throwable.
|
/** Gets the pattern used to build the message of this throwable.
|
||||||
@ -201,15 +189,11 @@ public class MathException extends Exception {
|
|||||||
return (pattern == null) ? null : buildMessage(pattern, arguments, locale);
|
return (pattern == null) ? null : buildMessage(pattern, arguments, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** {@inheritDoc} */
|
||||||
* Gets the cause of this throwable.
|
public String getLocalizedMessage() {
|
||||||
*
|
return getMessage(Locale.getDefault());
|
||||||
* @return the cause of this throwable, or <code>null</code>
|
|
||||||
*/
|
|
||||||
public Throwable getCause() {
|
|
||||||
return rootCause;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the stack trace of this exception to the standard error stream.
|
* Prints the stack trace of this exception to the standard error stream.
|
||||||
*/
|
*/
|
||||||
@ -231,19 +215,4 @@ public class MathException extends Exception {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints the stack trace of this exception to the specified writer.
|
|
||||||
*
|
|
||||||
* @param out the <code>PrintWriter</code> to use for output
|
|
||||||
*/
|
|
||||||
public void printStackTrace(PrintWriter out) {
|
|
||||||
synchronized (out) {
|
|
||||||
super.printStackTrace(out);
|
|
||||||
if (rootCause != null && JDK_SUPPORTS_NESTED == false) {
|
|
||||||
out.print("Caused by: ");
|
|
||||||
rootCause.printStackTrace(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user