commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/exception NestableDelegate.java
Date Wed, 21 Aug 2002 23:52:02 GMT
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
  <scolebourne@btopenworld.com>.
  
  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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message