You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by do...@apache.org on 2001/02/26 01:36:09 UTC

cvs commit: jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/util StringUtil.java

donaldp     01/02/25 16:36:09

  Modified:    proposal/4.0/src/java/org/apache/avalon/util StringUtil.java
  Log:
  Moved to aut Exception handling stuff.
  
  Revision  Changes    Path
  1.2       +0 -106    jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/util/StringUtil.java
  
  Index: StringUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/util/StringUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringUtil.java	2001/02/25 10:45:49	1.1
  +++ StringUtil.java	2001/02/26 00:36:09	1.2
  @@ -7,19 +7,10 @@
    */
   package org.apache.avalon.util;
   
  -import java.io.PrintWriter;
  -import java.io.StringWriter;
  -import java.util.ArrayList;
  -import java.util.StringTokenizer;
  -import org.apache.avalon.CascadingThrowable;
  -
   /**
    * This class provides basic facilities for manipulating strings.
  - *
  - * Some exception handling stuff thieved from Turbine...
    * 
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
  - * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
    */
   public final class StringUtil
   {
  @@ -60,102 +51,5 @@
           sb.append( original.substring( start, end ) );
           
           return sb.toString();
  -    }
  -    
  -    public static String printStackTrace( final Throwable throwable )
  -    {
  -        return printStackTrace( throwable, 0, true );
  -    }
  -    
  -    public static String printStackTrace( final Throwable throwable, 
  -                                          final boolean printCascading )
  -    {
  -        return printStackTrace( throwable, 0, printCascading );
  -    }
  -    
  -    public static String printStackTrace( final Throwable throwable, int depth )
  -    {
  -        final String[] lines = captureStackTrace( throwable );
  -
  -        if( 0 == depth || depth > lines.length ) depth = lines.length;
  -
  -        final StringBuffer sb = new StringBuffer();
  -
  -        for( int i = 0; i < depth; i++ )
  -        {
  -            sb.append( lines[ i ] );
  -            sb.append( '\n' );
  -        }
  -
  -        return sb.toString();
  -    }
  -
  -    public static String printStackTrace( Throwable throwable, 
  -                                          final int depth,
  -                                          final boolean printCascading )
  -    {
  -        final String result = printStackTrace( throwable, depth );
  -
  -        if( !printCascading || !(throwable instanceof CascadingThrowable) ) 
  -        {
  -            return result;
  -        }
  -        else
  -        {
  -            final StringBuffer sb = new StringBuffer();
  -            sb.append( result );
  -
  -            throwable = ((CascadingThrowable)throwable).getCause();
  -
  -            while( null != throwable )
  -            {
  -                sb.append( "rethrown from\n" );
  -                sb.append( printStackTrace( throwable, depth ) );
  -
  -                if( throwable instanceof CascadingThrowable )
  -                {
  -                    throwable = ((CascadingThrowable)throwable).getCause();
  -                }
  -                else
  -                {
  -                    throwable = null;
  -                }
  -            }
  -
  -            return sb.toString();
  -        }
  -    }
  -                                          
  -    /**
  -     * Captures the stack trace associated with this exception.
  -     *
  -     * @return an array of Strings describing stack frames.
  -     */ 
  -    public static String[] captureStackTrace( final Throwable throwable ) 
  -    {
  -        final StringWriter sw = new StringWriter();
  -        throwable.printStackTrace( new PrintWriter( sw, true ) );
  -        return splitString( sw.toString(), "\n" );
  -    }
  -                                                  
  -    /**
  -     * Splits the string on every token into an array of stack frames.
  -     * 
  -     * @param string the string
  -     * @param onToken the token
  -     * @return the resultant array
  -     */
  -    public static String[] splitString( final String string, final String onToken ) 
  -    {
  -        final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
  -        
  -        final ArrayList lines = new ArrayList();
  -        
  -        while( tokenizer.hasMoreTokens() ) 
  -        {
  -            lines.add( tokenizer.nextToken() );
  -        }
  -        
  -        return (String[])lines.toArray( new String[ 0 ] );
       }
   }