Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 8420 invoked from network); 21 Aug 2002 23:52:09 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 21 Aug 2002 23:52:09 -0000 Received: (qmail 14887 invoked by uid 97); 21 Aug 2002 23:52:42 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 14871 invoked by uid 97); 21 Aug 2002 23:52:41 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 14860 invoked by uid 97); 21 Aug 2002 23:52:41 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 21 Aug 2002 23:52:02 -0000 Message-ID: <20020821235202.69294.qmail@icarus.apache.org> From: dlr@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/exception NestableDelegate.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N dlr 2002/08/21 16:52:02 Modified: lang/src/java/org/apache/commons/lang/exception NestableDelegate.java Log: Moved the implementations of getThrowableCount(), getThrowables(), indexOfThrowable(Class), and indexOfThrowable(Class, int) methods to ExceptionUtils, as suggested by Stephen Colebourne . Revision Changes Path 1.5 +4 -45 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.4 retrieving revision 1.5 diff -u -u -r1.4 -r1.5 --- NestableDelegate.java 21 Aug 2002 07:31:54 -0000 1.4 +++ NestableDelegate.java 21 Aug 2002 23:52:02 -0000 1.5 @@ -217,16 +217,7 @@ */ int getThrowableCount() // package { - // Count the number of throwables - int count = 1; - String msg = null; - Throwable t = ExceptionUtils.getCause(this.cause); - while (t != null) - { - ++count; - t = ExceptionUtils.getCause(t); - } - return count; + return ExceptionUtils.getThrowableCount(this.cause); } /** @@ -238,21 +229,7 @@ */ Throwable[] getThrowables() // package { - int count = this.getThrowableCount(); - // Allocate an array to hold the messages - Throwable[] throwables = new Throwable[count]; - count = 0; - if(cause != null) - { - throwables[count++] = this.cause; - Throwable t = ExceptionUtils.getCause(this.cause); - while(t != null) - { - throwables[count++] = t; - t = ExceptionUtils.getCause(t); - } - } - return throwables; + return ExceptionUtils.getThrowables(this.cause); } /** @@ -272,25 +249,7 @@ */ int indexOfThrowable(Class type, int fromIndex) // package { - if(fromIndex < 0) - { - throw new IndexOutOfBoundsException("Throwable index out of range: " - + fromIndex); - } - Throwable throwables[] = this.getThrowables(); - if(fromIndex >= throwables.length) - { - throw new IndexOutOfBoundsException("Throwable index out of range: " - + fromIndex); - } - for(int i = fromIndex; i < throwables.length; i++) - { - if(throwables[i].getClass().equals(type)) - { - return i; - } - } - return -1; + return ExceptionUtils.indexOfThrowable(this.cause, type, fromIndex); } /** -- To unsubscribe, e-mail: For additional commands, e-mail: