You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/11/03 22:28:35 UTC

svn commit: r710166 - /commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java

Author: luc
Date: Mon Nov  3 13:28:35 2008
New Revision: 710166

URL: http://svn.apache.org/viewvc?rev=710166&view=rev
Log:
remove pre Java 1.4 emulation stuff as we now need at least Java 5

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java?rev=710166&r1=710165&r2=710166&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java Mon Nov  3 13:28:35 2008
@@ -68,11 +68,6 @@
     private final Object[] arguments;
 
     /**
-     * Root cause of the exception
-     */
-    private final Throwable rootCause;
-    
-    /**
      * Translate a string to a given locale.
      * @param s string to translate
      * @param locale locale into which to translate the string
@@ -110,10 +105,7 @@
      * @return a message string
      */
     private static String buildMessage(String pattern, Object[] arguments, Locale locale) {
-        // do it the hard way, for Java 1.3. compatibility
-        MessageFormat mf = new MessageFormat(translate(pattern, locale));
-        mf.setLocale(locale);
-        return mf.format(arguments);        
+        return new MessageFormat(translate(pattern, locale), locale).format(arguments);        
     }
 
     /**
@@ -124,7 +116,6 @@
         super();
         this.pattern   = null;
         this.arguments = new Object[0];
-        this.rootCause = null;
     }
     
     /**
@@ -138,7 +129,6 @@
       super(buildMessage(pattern, arguments, Locale.US));
       this.pattern   = pattern;
       this.arguments = (Object[]) arguments.clone();
-      this.rootCause = null;
     }
 
     /**
@@ -149,10 +139,9 @@
      *                   to be thrown.
      */
     public MathException(Throwable rootCause) {
-        super((rootCause == null ? null : rootCause.getMessage()));
+        super(rootCause);
         this.pattern   = getMessage();
         this.arguments = new Object[0];
-        this.rootCause = rootCause;
     }
     
     /**
@@ -166,10 +155,9 @@
      * @since 1.2
      */
     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.arguments = (Object[]) arguments.clone();
-      this.rootCause = rootCause;
     }
 
     /** Gets the pattern used to build the message of this throwable.
@@ -201,15 +189,11 @@
         return (pattern == null) ? null : buildMessage(pattern, arguments, locale);
     }
 
-    /**
-     * Gets the cause of this throwable.
-     * 
-     * @return  the cause of this throwable, or <code>null</code>
-     */
-    public Throwable getCause() {
-        return rootCause;
+    /** {@inheritDoc} */
+    public String getLocalizedMessage() {
+        return getMessage(Locale.getDefault());
     }
-    
+
     /**
      * Prints the stack trace of this exception to the standard error stream.
      */
@@ -231,19 +215,4 @@
         }
     }
     
-    /**
-     * 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);
-            }
-        }
-    }
-
 }