removed forgotten pre-JDK 1.4 stuff
added protection against null pointer exceptions git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@712136 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91ec7946e9
commit
4a2d68685b
|
@ -35,24 +35,8 @@ import java.util.ResourceBundle;
|
||||||
*/
|
*/
|
||||||
public class MathException extends Exception {
|
public class MathException extends Exception {
|
||||||
|
|
||||||
/** Serializable version identifier */
|
/** Serializable version identifier. */
|
||||||
private static final long serialVersionUID = 1428666635974829194L;
|
private static final long serialVersionUID = 5924076008552401454L;
|
||||||
|
|
||||||
/**
|
|
||||||
* Does JDK support nested exceptions?
|
|
||||||
*/
|
|
||||||
private static final boolean JDK_SUPPORTS_NESTED;
|
|
||||||
|
|
||||||
static {
|
|
||||||
boolean flag = false;
|
|
||||||
try {
|
|
||||||
Throwable.class.getDeclaredMethod("getCause", new Class[0]);
|
|
||||||
flag = true;
|
|
||||||
} catch (NoSuchMethodException ex) {
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
JDK_SUPPORTS_NESTED = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Cache for resources bundle. */
|
/** Cache for resources bundle. */
|
||||||
private static ResourceBundle cachedResources = null;
|
private static ResourceBundle cachedResources = null;
|
||||||
|
@ -105,7 +89,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) {
|
||||||
return new MessageFormat(translate(pattern, locale), locale).format(arguments);
|
return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,7 +99,7 @@ public class MathException extends Exception {
|
||||||
public MathException() {
|
public MathException() {
|
||||||
super();
|
super();
|
||||||
this.pattern = null;
|
this.pattern = null;
|
||||||
this.arguments = new Object[0];
|
this.arguments = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +112,7 @@ public class MathException extends Exception {
|
||||||
public MathException(String pattern, Object[] arguments) {
|
public MathException(String pattern, Object[] arguments) {
|
||||||
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 = (arguments == null) ? new Object[0] : arguments.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,7 +141,7 @@ public class MathException extends Exception {
|
||||||
public MathException(String pattern, Object[] arguments, Throwable rootCause) {
|
public MathException(String pattern, Object[] arguments, Throwable rootCause) {
|
||||||
super(buildMessage(pattern, arguments, Locale.US), rootCause);
|
super(buildMessage(pattern, arguments, Locale.US), rootCause);
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.arguments = (Object[]) arguments.clone();
|
this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the pattern used to build the message of this throwable.
|
/** Gets the pattern used to build the message of this throwable.
|
||||||
|
@ -175,7 +159,7 @@ public class MathException extends Exception {
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public Object[] getArguments() {
|
public Object[] getArguments() {
|
||||||
return (Object[]) arguments.clone();
|
return arguments.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the message in a specified locale.
|
/** Gets the message in a specified locale.
|
||||||
|
@ -186,7 +170,7 @@ public class MathException extends Exception {
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public String getMessage(Locale locale) {
|
public String getMessage(Locale locale) {
|
||||||
return (pattern == null) ? null : buildMessage(pattern, arguments, locale);
|
return buildMessage(pattern, arguments, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
Loading…
Reference in New Issue