Add since tags

Formatting


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2002-12-23 00:15:19 +00:00
parent 725fd755a1
commit 010e0a3f2e
5 changed files with 142 additions and 238 deletions

View File

@ -1,5 +1,3 @@
package org.apache.commons.lang.exception;
/* ====================================================================
* The Apache Software License, Version 1.1
*
@ -53,6 +51,7 @@ package org.apache.commons.lang.exception;
* 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 @@ import java.io.PrintWriter;
* @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
* @author <a href="mailto:knielsen@apache.org">Kasper Nielsen</a>
* @author <a href="mailto:steven@caswell.name">Steven Caswell</a>
* @version $Id: Nestable.java,v 1.4 2002/09/12 01:20:25 stevencaswell Exp $
* @since 1.0
* @version $Id: Nestable.java,v 1.5 2002/12/23 00:15:19 scolebourne Exp $
*/
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.

View File

@ -1,5 +1,3 @@
package org.apache.commons.lang.exception;
/* ====================================================================
* The Apache Software License, Version 1.1
*
@ -53,6 +51,7 @@ package org.apache.commons.lang.exception;
* 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,11 +63,11 @@ import java.io.StringWriter;
* @author <a href="mailto:knielsen@apache.org">Kasper Nielsen</a>
* @author <a href="mailto:steven@caswell.name">Steven Caswell</a>
* @author Sean C. Sullivan
* @version $Id: NestableDelegate.java,v 1.10 2002/10/09 05:29:52 sullis Exp $
* @since 1.0
* @version $Id: NestableDelegate.java,v 1.11 2002/12/23 00:15:19 scolebourne Exp $
*/
public class NestableDelegate
implements java.io.Serializable
{
public class NestableDelegate implements java.io.Serializable {
/**
* Constructor error message.
*/
@ -90,14 +89,10 @@ public class NestableDelegate
* @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,15 +109,11 @@ public class NestableDelegate
* 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();
}
}
@ -139,22 +130,17 @@ public class NestableDelegate
* @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 @@ public class NestableDelegate
*
* @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,10 +183,8 @@ public class NestableDelegate
* 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();
@ -214,8 +197,7 @@ public class NestableDelegate
*
* @return the throwable count
*/
int getThrowableCount() // package
{
int getThrowableCount() {
return ExceptionUtils.getThrowableCount(this.nestable);
}
@ -226,8 +208,7 @@ public class NestableDelegate
*
* @return the <code>Throwable</code>s
*/
Throwable[] getThrowables() // package
{
Throwable[] getThrowables() {
return ExceptionUtils.getThrowables(this.nestable);
}
@ -246,8 +227,7 @@ public class NestableDelegate
* 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);
}
@ -255,8 +235,7 @@ public class NestableDelegate
* 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 @@ public class NestableDelegate
* @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 @@ public class NestableDelegate
*
* @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
{
} 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 @@ public class NestableDelegate
}
// 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 @@ public class NestableDelegate
* @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());

View File

@ -1,5 +1,3 @@
package org.apache.commons.lang.exception;
/* ====================================================================
* The Apache Software License, Version 1.1
*
@ -53,6 +51,7 @@ package org.apache.commons.lang.exception;
* 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 @@ import java.io.PrintWriter;
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
* @see org.apache.commons.lang.exception.NestableException
* @since 1.0
* @version $Id: NestableError.java,v 1.4 2002/12/23 00:15:19 scolebourne Exp $
*/
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 @@ public class NestableError extends Error implements Nestable
* Constructs a new <code>NestableError</code> without specified
* detail message.
*/
public NestableError()
{
public NestableError() {
super();
}
@ -93,8 +92,7 @@ public class NestableError extends Error implements Nestable
*
* @param msg The error message.
*/
public NestableError(String msg)
{
public NestableError(String msg) {
super(msg);
}
@ -105,8 +103,7 @@ public class NestableError extends Error implements Nestable
* @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 @@ public class NestableError extends Error implements Nestable
* @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);
}
}

View File

@ -1,5 +1,3 @@
package org.apache.commons.lang.exception;
/* ====================================================================
* The Apache Software License, Version 1.1
*
@ -53,6 +51,7 @@ package org.apache.commons.lang.exception;
* 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 @@ import java.io.PrintWriter;
* @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
* @author <a href="mailto:knielsen@apache.org">Kasper Nielsen</a>
* @author <a href="mailto:steven@caswell.name">Steven Caswell</a>
* @version $Id: NestableException.java,v 1.5 2002/09/29 08:20:52 bayard Exp $
* @since 1.0
* @version $Id: NestableException.java,v 1.6 2002/12/23 00:15:19 scolebourne Exp $
*/
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 @@ public class NestableException extends Exception implements Nestable
* Constructs a new <code>NestableException</code> without specified
* detail message.
*/
public NestableException()
{
public NestableException() {
super();
}
@ -151,8 +150,7 @@ public class NestableException extends Exception implements Nestable
*
* @param msg The error message.
*/
public NestableException(String msg)
{
public NestableException(String msg) {
super(msg);
}
@ -163,8 +161,7 @@ public class NestableException extends Exception implements Nestable
* @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,81 +174,64 @@ public class NestableException extends Exception implements Nestable
* @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);
}

View File

@ -1,5 +1,3 @@
package org.apache.commons.lang.exception;
/* ====================================================================
* The Apache Software License, Version 1.1
*
@ -53,6 +51,7 @@ package org.apache.commons.lang.exception;
* 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 @@ import java.io.PrintWriter;
* @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
* @author <a href="mailto:knielsen@apache.org">Kasper Nielsen</a>
* @author <a href="mailto:steven@caswell.name">Steven Caswell</a>
* @version $Id: NestableRuntimeException.java,v 1.5 2002/09/29 08:20:52 bayard Exp $
* @since 1.0
* @version $Id: NestableRuntimeException.java,v 1.6 2002/12/23 00:15:19 scolebourne Exp $
*/
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 @@ public class NestableRuntimeException extends RuntimeException
* Constructs a new <code>NestableRuntimeException</code> without specified
* detail message.
*/
public NestableRuntimeException()
{
public NestableRuntimeException() {
super();
}
@ -98,8 +96,7 @@ public class NestableRuntimeException extends RuntimeException
*
* @param msg the error message
*/
public NestableRuntimeException(String msg)
{
public NestableRuntimeException(String msg) {
super(msg);
}
@ -110,8 +107,7 @@ public class NestableRuntimeException extends RuntimeException
* @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,81 +120,64 @@ public class NestableRuntimeException extends RuntimeException
* @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);
}