scolebourne 2002/12/22 16:15:19
Modified: lang/src/java/org/apache/commons/lang/exception
NestableError.java Nestable.java
NestableDelegate.java NestableException.java
NestableRuntimeException.java
Log:
Add since tags
Formatting
Revision Changes Path
1.4 +28 -48
jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableError.java
Index: NestableError.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableError.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NestableError.java 29 Sep 2002 08:20:52 -0000 1.3
+++ NestableError.java 23 Dec 2002 00:15:19 -0000 1.4
@@ -1,5 +1,3 @@
-package org.apache.commons.lang.exception;
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -53,6 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+package org.apache.commons.lang.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -63,9 +62,10 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @see org.apache.commons.lang.exception.NestableException
* @since 1.0
+ * @version $Id$
*/
-public class NestableError extends Error implements Nestable
-{
+public class NestableError extends Error implements Nestable {
+
/**
* The helper instance which contains much of the code which we
* delegate to.
@@ -82,8 +82,7 @@
* Constructs a new <code>NestableError</code> without specified
* detail message.
*/
- public NestableError()
- {
+ public NestableError() {
super();
}
@@ -93,8 +92,7 @@
*
* @param msg The error message.
*/
- public NestableError(String msg)
- {
+ public NestableError(String msg) {
super(msg);
}
@@ -105,8 +103,7 @@
* @param cause the exception or error that caused this exception to be
* thrown
*/
- public NestableError(Throwable cause)
- {
+ public NestableError(Throwable cause) {
super();
this.cause = cause;
}
@@ -119,81 +116,64 @@
* @param cause the exception or error that caused this exception to be
* thrown
*/
- public NestableError(String msg, Throwable cause)
- {
+ public NestableError(String msg, Throwable cause) {
super(msg);
this.cause = cause;
}
- public Throwable getCause()
- {
+ public Throwable getCause() {
return cause;
}
- public String getMessage()
- {
+ public String getMessage() {
return delegate.getMessage(super.getMessage());
}
- public String getMessage(int index)
- {
- if (index == 0)
- {
+ public String getMessage(int index) {
+ if (index == 0) {
return super.getMessage();
- }
- else
- {
+ } else {
return delegate.getMessage(index);
}
}
-
- public String[] getMessages()
- {
+
+ public String[] getMessages() {
return delegate.getMessages();
}
-
- public Throwable getThrowable(int index)
- {
+
+ public Throwable getThrowable(int index) {
return delegate.getThrowable(index);
}
-
- public int getThrowableCount()
- {
+
+ public int getThrowableCount() {
return delegate.getThrowableCount();
}
-
- public Throwable[] getThrowables()
- {
+
+ public Throwable[] getThrowables() {
return delegate.getThrowables();
}
-
- public int indexOfThrowable(Class type)
- {
+
+ public int indexOfThrowable(Class type) {
return delegate.indexOfThrowable(type, 0);
}
- public int indexOfThrowable(Class type, int fromIndex)
- {
+ public int indexOfThrowable(Class type, int fromIndex) {
return delegate.indexOfThrowable(type, fromIndex);
}
- public void printStackTrace()
- {
+ public void printStackTrace() {
delegate.printStackTrace();
}
- public void printStackTrace(PrintStream out)
- {
+ public void printStackTrace(PrintStream out) {
delegate.printStackTrace(out);
}
- public void printStackTrace(PrintWriter out)
- {
+ public void printStackTrace(PrintWriter out) {
delegate.printStackTrace(out);
}
- public final void printPartialStackTrace(PrintWriter out)
- {
+ public final void printPartialStackTrace(PrintWriter out) {
super.printStackTrace(out);
}
}
1.5 +7 -7
jakarta-commons/lang/src/java/org/apache/commons/lang/exception/Nestable.java
Index: Nestable.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/exception/Nestable.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Nestable.java 12 Sep 2002 01:20:25 -0000 1.4
+++ Nestable.java 23 Dec 2002 00:15:19 -0000 1.5
@@ -1,5 +1,3 @@
-package org.apache.commons.lang.exception;
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -53,6 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+package org.apache.commons.lang.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -65,10 +64,11 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Kasper Nielsen</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Steven Caswell</a>
+ * @since 1.0
* @version $Id$
*/
-public interface Nestable
-{
+public interface Nestable {
+
/**
* Returns the reference to the exception or error that caused the
* exception implementing the <code>Nestable</code> to be thrown.
@@ -129,7 +129,7 @@
* @return the throwable count
*/
public int getThrowableCount();
-
+
/**
* Returns this <code>Nestable</code> and any nested <code>Throwable</code>s
* in an array of <code>Throwable</code>s, one element for each
@@ -166,7 +166,7 @@
* chain
*/
public int indexOfThrowable(Class type, int fromIndex);
-
+
/**
* Prints the stack trace of this exception to the specified print
* writer. Includes inforamation from the exception--if
1.11 +46 -81
jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableDelegate.java
Index: NestableDelegate.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableDelegate.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- NestableDelegate.java 9 Oct 2002 05:29:52 -0000 1.10
+++ NestableDelegate.java 23 Dec 2002 00:15:19 -0000 1.11
@@ -1,5 +1,3 @@
-package org.apache.commons.lang.exception;
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -53,6 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+package org.apache.commons.lang.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -64,17 +63,17 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Kasper Nielsen</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Steven Caswell</a>
* @author Sean C. Sullivan
+ * @since 1.0
* @version $Id$
*/
-public class NestableDelegate
- implements java.io.Serializable
-{
+public class NestableDelegate implements java.io.Serializable {
+
/**
* Constructor error message.
*/
private transient static final String MUST_BE_THROWABLE =
"The Nestable implementation passed to the NestableDelegate(Nestable) "
- + "constructor must extend java.lang.Throwable";
+ + "constructor must extend java.lang.Throwable";
/**
* Holds the reference to the exception or error that we're
@@ -90,14 +89,10 @@
* @param nestable the Nestable implementation (<i>must</i> extend
* {@link java.lang.Throwable})
*/
- NestableDelegate(Nestable nestable) // package
- {
- if (nestable instanceof Throwable)
- {
+ NestableDelegate(Nestable nestable) {
+ if (nestable instanceof Throwable) {
this.nestable = (Throwable) nestable;
- }
- else
- {
+ } else {
throw new IllegalArgumentException(MUST_BE_THROWABLE);
}
}
@@ -114,19 +109,15 @@
* negative or not less than the count of <code>Throwable</code>s in the
* chain
*/
- String getMessage(int index)
- {
+ String getMessage(int index) {
Throwable t = this.getThrowable(index);
- if(Nestable.class.isInstance(t))
- {
+ if (Nestable.class.isInstance(t)) {
return ((Nestable) t).getMessage(0);
- }
- else
- {
+ } else {
return t.getMessage();
}
}
-
+
/**
* Returns the full message contained by the <code>Nestable</code>
* and any nested <code>Throwable</code>s.
@@ -139,22 +130,17 @@
* @return The concatenated message for this and all nested
* <code>Throwable</code>s
*/
- String getMessage(String baseMsg) // package
- {
+ String getMessage(String baseMsg) {
StringBuffer msg = new StringBuffer();
- if (baseMsg != null)
- {
+ if (baseMsg != null) {
msg.append(baseMsg);
}
Throwable nestedCause = ExceptionUtils.getCause(this.nestable);
- if (nestedCause != null)
- {
+ if (nestedCause != null) {
String causeMsg = nestedCause.getMessage();
- if (causeMsg != null)
- {
- if (baseMsg != null)
- {
+ if (causeMsg != null) {
+ if (baseMsg != null) {
msg.append(": ");
}
msg.append(causeMsg);
@@ -174,15 +160,14 @@
*
* @return the error messages
*/
- String[] getMessages() // package
- {
+ String[] getMessages() {
Throwable[] throwables = this.getThrowables();
String[] msgs = new String[throwables.length];
- for(int i = 0; i < throwables.length; i++)
- {
- msgs[i] = (Nestable.class.isInstance(throwables[i]) ?
- ((Nestable) throwables[i]).getMessage(0) :
- throwables[i].getMessage());
+ for (int i = 0; i < throwables.length; i++) {
+ msgs[i] =
+ (Nestable.class.isInstance(throwables[i])
+ ? ((Nestable) throwables[i]).getMessage(0)
+ : throwables[i].getMessage());
}
return msgs;
}
@@ -198,27 +183,24 @@
* negative or not less than the count of <code>Throwable</code>s in the
* chain
*/
- Throwable getThrowable(int index)
- {
- if(index == 0)
- {
+ Throwable getThrowable(int index) {
+ if (index == 0) {
return this.nestable;
}
Throwable[] throwables = this.getThrowables();
return throwables[index];
}
-
+
/**
* Returns the number of <code>Throwable</code>s contained in the
* <code>Nestable</code> contained by this delegate.
*
* @return the throwable count
*/
- int getThrowableCount() // package
- {
+ int getThrowableCount() {
return ExceptionUtils.getThrowableCount(this.nestable);
}
-
+
/**
* Returns this delegate's <code>Nestable</code> and any nested
* <code>Throwable</code>s in an array of <code>Throwable</code>s, one
@@ -226,8 +208,7 @@
*
* @return the <code>Throwable</code>s
*/
- Throwable[] getThrowables() // package
- {
+ Throwable[] getThrowables() {
return ExceptionUtils.getThrowables(this.nestable);
}
@@ -246,17 +227,15 @@
* is negative or not less than the count of <code>Throwable</code>s in the
* chain
*/
- int indexOfThrowable(Class type, int fromIndex) // package
- {
+ int indexOfThrowable(Class type, int fromIndex) {
return ExceptionUtils.indexOfThrowable(this.nestable, type, fromIndex);
}
-
+
/**
* Prints the stack trace of this exception the the standar error
* stream.
*/
- public void printStackTrace()
- {
+ public void printStackTrace() {
printStackTrace(System.err);
}
@@ -267,10 +246,8 @@
* @param out <code>PrintStream</code> to use for output.
* @see #printStackTrace(PrintWriter)
*/
- public void printStackTrace(PrintStream out)
- {
- synchronized (out)
- {
+ public void printStackTrace(PrintStream out) {
+ synchronized (out) {
PrintWriter pw = new PrintWriter(out, false);
printStackTrace(pw);
// Flush the PrintWriter before it's GC'ed.
@@ -284,24 +261,17 @@
*
* @param out <code>PrintWriter</code> to use for output.
*/
- public void printStackTrace(PrintWriter out)
- {
- synchronized (out)
- {
+ public void printStackTrace(PrintWriter out) {
+ synchronized (out) {
String[] st = getStackFrames(this.nestable);
Throwable nestedCause = ExceptionUtils.getCause(this.nestable);
- if (nestedCause != null)
- {
- if (nestedCause instanceof Nestable)
- {
+ if (nestedCause != null) {
+ if (nestedCause instanceof Nestable) {
// Recurse until a non-Nestable is encountered.
- ((Nestable) nestedCause).printStackTrace(out);
- }
- else
- {
+ ((Nestable) nestedCause).printStackTrace(out);
+ } else {
String[] nst = getStackFrames(nestedCause);
- for (int i = 0; i < nst.length; i++)
- {
+ for (int i = 0; i < nst.length; i++) {
out.println(nst[i]);
}
}
@@ -309,8 +279,7 @@
}
// Output desired frames from stack trace.
- for (int i = 0; i < st.length; i++)
- {
+ for (int i = 0; i < st.length; i++) {
out.println(st[i]);
}
}
@@ -324,18 +293,14 @@
* @param t The <code>Throwable</code>.
* @return An array of strings describing each stack frame.
*/
- private String[] getStackFrames(Throwable t)
- {
+ private String[] getStackFrames(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
// Avoid infinite loop between decompose() and printStackTrace().
- if (t instanceof Nestable)
- {
+ if (t instanceof Nestable) {
((Nestable) t).printPartialStackTrace(pw);
- }
- else
- {
+ } else {
t.printStackTrace(pw);
}
return ExceptionUtils.getStackFrames(sw.getBuffer().toString());
1.6 +30 -50
jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableException.java
Index: NestableException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableException.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NestableException.java 29 Sep 2002 08:20:52 -0000 1.5
+++ NestableException.java 23 Dec 2002 00:15:19 -0000 1.6
@@ -1,5 +1,3 @@
-package org.apache.commons.lang.exception;
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -53,6 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+package org.apache.commons.lang.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -120,10 +119,11 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Kasper Nielsen</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Steven Caswell</a>
+ * @since 1.0
* @version $Id$
*/
-public class NestableException extends Exception implements Nestable
-{
+public class NestableException extends Exception implements Nestable {
+
/**
* The helper instance which contains much of the code which we
* delegate to.
@@ -140,8 +140,7 @@
* Constructs a new <code>NestableException</code> without specified
* detail message.
*/
- public NestableException()
- {
+ public NestableException() {
super();
}
@@ -151,8 +150,7 @@
*
* @param msg The error message.
*/
- public NestableException(String msg)
- {
+ public NestableException(String msg) {
super(msg);
}
@@ -163,8 +161,7 @@
* @param cause the exception or error that caused this exception to be
* thrown
*/
- public NestableException(Throwable cause)
- {
+ public NestableException(Throwable cause) {
super();
this.cause = cause;
}
@@ -177,82 +174,65 @@
* @param cause the exception or error that caused this exception to be
* thrown
*/
- public NestableException(String msg, Throwable cause)
- {
+ public NestableException(String msg, Throwable cause) {
super(msg);
this.cause = cause;
}
- public Throwable getCause()
- {
+ public Throwable getCause() {
return cause;
}
- public String getMessage()
- {
+ public String getMessage() {
return delegate.getMessage(super.getMessage());
}
- public String getMessage(int index)
- {
- if (index == 0)
- {
+ public String getMessage(int index) {
+ if (index == 0) {
return super.getMessage();
- }
- else
- {
+ } else {
return delegate.getMessage(index);
}
}
-
- public String[] getMessages()
- {
+
+ public String[] getMessages() {
return delegate.getMessages();
}
-
- public Throwable getThrowable(int index)
- {
+
+ public Throwable getThrowable(int index) {
return delegate.getThrowable(index);
}
-
- public int getThrowableCount()
- {
+
+ public int getThrowableCount() {
return delegate.getThrowableCount();
}
-
- public Throwable[] getThrowables()
- {
+
+ public Throwable[] getThrowables() {
return delegate.getThrowables();
}
-
- public int indexOfThrowable(Class type)
- {
+
+ public int indexOfThrowable(Class type) {
return delegate.indexOfThrowable(type, 0);
}
- public int indexOfThrowable(Class type, int fromIndex)
- {
+ public int indexOfThrowable(Class type, int fromIndex) {
return delegate.indexOfThrowable(type, fromIndex);
}
- public void printStackTrace()
- {
+ public void printStackTrace() {
delegate.printStackTrace();
}
- public void printStackTrace(PrintStream out)
- {
+ public void printStackTrace(PrintStream out) {
delegate.printStackTrace(out);
}
- public void printStackTrace(PrintWriter out)
- {
+ public void printStackTrace(PrintWriter out) {
delegate.printStackTrace(out);
}
- public final void printPartialStackTrace(PrintWriter out)
- {
+ public final void printPartialStackTrace(PrintWriter out) {
super.printStackTrace(out);
}
-
+
}
1.6 +31 -52
jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableRuntimeException.java
Index: NestableRuntimeException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/exception/NestableRuntimeException.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NestableRuntimeException.java 29 Sep 2002 08:20:52 -0000 1.5
+++ NestableRuntimeException.java 23 Dec 2002 00:15:19 -0000 1.6
@@ -1,5 +1,3 @@
-package org.apache.commons.lang.exception;
-
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -53,6 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+package org.apache.commons.lang.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -66,11 +65,11 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Kasper Nielsen</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Steven Caswell</a>
+ * @since 1.0
* @version $Id$
*/
-public class NestableRuntimeException extends RuntimeException
- implements Nestable
-{
+public class NestableRuntimeException extends RuntimeException implements Nestable {
+
/**
* The helper instance which contains much of the code which we
* delegate to.
@@ -87,8 +86,7 @@
* Constructs a new <code>NestableRuntimeException</code> without specified
* detail message.
*/
- public NestableRuntimeException()
- {
+ public NestableRuntimeException() {
super();
}
@@ -98,8 +96,7 @@
*
* @param msg the error message
*/
- public NestableRuntimeException(String msg)
- {
+ public NestableRuntimeException(String msg) {
super(msg);
}
@@ -110,8 +107,7 @@
* @param cause the exception or error that caused this exception to be
* thrown
*/
- public NestableRuntimeException(Throwable cause)
- {
+ public NestableRuntimeException(Throwable cause) {
super();
this.cause = cause;
}
@@ -124,82 +120,65 @@
* @param cause the exception or error that caused this exception to be
* thrown
*/
- public NestableRuntimeException(String msg, Throwable cause)
- {
+ public NestableRuntimeException(String msg, Throwable cause) {
super(msg);
this.cause = cause;
}
- public Throwable getCause()
- {
+ public Throwable getCause() {
return cause;
}
- public String getMessage()
- {
+ public String getMessage() {
return delegate.getMessage(super.getMessage());
}
- public String getMessage(int index)
- {
- if (index == 0)
- {
+ public String getMessage(int index) {
+ if (index == 0) {
return super.getMessage();
- }
- else
- {
+ } else {
return delegate.getMessage(index);
}
}
-
- public String[] getMessages()
- {
+
+ public String[] getMessages() {
return delegate.getMessages();
}
-
- public Throwable getThrowable(int index)
- {
+
+ public Throwable getThrowable(int index) {
return delegate.getThrowable(index);
}
-
- public int getThrowableCount()
- {
+
+ public int getThrowableCount() {
return delegate.getThrowableCount();
}
-
- public Throwable[] getThrowables()
- {
+
+ public Throwable[] getThrowables() {
return delegate.getThrowables();
}
-
- public int indexOfThrowable(Class type)
- {
+
+ public int indexOfThrowable(Class type) {
return delegate.indexOfThrowable(type, 0);
}
- public int indexOfThrowable(Class type, int fromIndex)
- {
+ public int indexOfThrowable(Class type, int fromIndex) {
return delegate.indexOfThrowable(type, fromIndex);
}
-
- public void printStackTrace()
- {
+
+ public void printStackTrace() {
delegate.printStackTrace();
}
- public void printStackTrace(PrintStream out)
- {
+ public void printStackTrace(PrintStream out) {
delegate.printStackTrace(out);
}
- public void printStackTrace(PrintWriter out)
- {
+ public void printStackTrace(PrintWriter out) {
delegate.printStackTrace(out);
}
- public final void printPartialStackTrace(PrintWriter out)
- {
+ public final void printPartialStackTrace(PrintWriter out) {
super.printStackTrace(out);
}
-
+
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>