From 010e0a3f2e0f00e0eeb79e80f930f92aa0449832 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Mon, 23 Dec 2002 00:15:19 +0000 Subject: [PATCH] Add since tags Formatting git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137207 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/lang/exception/Nestable.java | 14 +- .../lang/exception/NestableDelegate.java | 127 +++++++----------- .../commons/lang/exception/NestableError.java | 76 ++++------- .../lang/exception/NestableException.java | 80 +++++------ .../exception/NestableRuntimeException.java | 83 +++++------- 5 files changed, 142 insertions(+), 238 deletions(-) diff --git a/src/java/org/apache/commons/lang/exception/Nestable.java b/src/java/org/apache/commons/lang/exception/Nestable.java index 06624fdb4..a076275f8 100644 --- a/src/java/org/apache/commons/lang/exception/Nestable.java +++ b/src/java/org/apache/commons/lang/exception/Nestable.java @@ -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 * . */ +package org.apache.commons.lang.exception; import java.io.PrintStream; import java.io.PrintWriter; @@ -65,10 +64,11 @@ import java.io.PrintWriter; * @author Daniel Rall * @author Kasper Nielsen * @author Steven Caswell - * @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 Nestable to be thrown. @@ -129,7 +129,7 @@ public interface Nestable * @return the throwable count */ public int getThrowableCount(); - + /** * Returns this Nestable and any nested Throwables * in an array of Throwables, one element for each @@ -166,7 +166,7 @@ public interface Nestable * 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 diff --git a/src/java/org/apache/commons/lang/exception/NestableDelegate.java b/src/java/org/apache/commons/lang/exception/NestableDelegate.java index ec4a6591b..ac7485bf6 100644 --- a/src/java/org/apache/commons/lang/exception/NestableDelegate.java +++ b/src/java/org/apache/commons/lang/exception/NestableDelegate.java @@ -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 * . */ +package org.apache.commons.lang.exception; import java.io.PrintStream; import java.io.PrintWriter; @@ -64,17 +63,17 @@ import java.io.StringWriter; * @author Kasper Nielsen * @author Steven Caswell * @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. */ 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 @@ public class NestableDelegate * @param nestable the Nestable implementation (must 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 @@ public class NestableDelegate * negative or not less than the count of Throwables 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 Nestable * and any nested Throwables. @@ -139,22 +130,17 @@ public class NestableDelegate * @return The concatenated message for this and all nested * Throwables */ - 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,27 +183,24 @@ public class NestableDelegate * negative or not less than the count of Throwables 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 Throwables contained in the * Nestable contained by this delegate. * * @return the throwable count */ - int getThrowableCount() // package - { + int getThrowableCount() { return ExceptionUtils.getThrowableCount(this.nestable); } - + /** * Returns this delegate's Nestable and any nested * Throwables in an array of Throwables, one @@ -226,8 +208,7 @@ public class NestableDelegate * * @return the Throwables */ - Throwable[] getThrowables() // package - { + Throwable[] getThrowables() { return ExceptionUtils.getThrowables(this.nestable); } @@ -246,17 +227,15 @@ public class NestableDelegate * is negative or not less than the count of Throwables 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 @@ public class NestableDelegate * @param out PrintStream 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 PrintWriter 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 @@ 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 Throwable. * @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()); diff --git a/src/java/org/apache/commons/lang/exception/NestableError.java b/src/java/org/apache/commons/lang/exception/NestableError.java index ca54af565..ef056ad7c 100644 --- a/src/java/org/apache/commons/lang/exception/NestableError.java +++ b/src/java/org/apache/commons/lang/exception/NestableError.java @@ -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 * . */ +package org.apache.commons.lang.exception; import java.io.PrintStream; import java.io.PrintWriter; @@ -63,9 +62,10 @@ import java.io.PrintWriter; * @author Daniel Rall * @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 NestableError 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); } } diff --git a/src/java/org/apache/commons/lang/exception/NestableException.java b/src/java/org/apache/commons/lang/exception/NestableException.java index f5ecf6289..de9532f99 100644 --- a/src/java/org/apache/commons/lang/exception/NestableException.java +++ b/src/java/org/apache/commons/lang/exception/NestableException.java @@ -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 * . */ +package org.apache.commons.lang.exception; import java.io.PrintStream; import java.io.PrintWriter; @@ -120,10 +119,11 @@ import java.io.PrintWriter; * @author Daniel Rall * @author Kasper Nielsen * @author Steven Caswell - * @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 NestableException 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,82 +174,65 @@ 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); } - + } diff --git a/src/java/org/apache/commons/lang/exception/NestableRuntimeException.java b/src/java/org/apache/commons/lang/exception/NestableRuntimeException.java index 3c4a98304..03959cc51 100644 --- a/src/java/org/apache/commons/lang/exception/NestableRuntimeException.java +++ b/src/java/org/apache/commons/lang/exception/NestableRuntimeException.java @@ -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 * . */ +package org.apache.commons.lang.exception; import java.io.PrintStream; import java.io.PrintWriter; @@ -66,11 +65,11 @@ import java.io.PrintWriter; * @author Daniel Rall * @author Kasper Nielsen * @author Steven Caswell - * @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 NestableRuntimeException 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,82 +120,65 @@ 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); } - + }