avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/util StringUtil.java
Date Wed, 18 Apr 2001 13:02:44 GMT
donaldp     01/04/18 06:02:44

  Modified:    src/java/org/apache/avalon/util StringUtil.java
  Log:
  Remove exception related methods
  
  Revision  Changes    Path
  1.2       +5 -108    jakarta-avalon/src/java/org/apache/avalon/util/StringUtil.java
  
  Index: StringUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/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/24 03:59:37	1.1
  +++ StringUtil.java	2001/04/18 13:02:43	1.2
  @@ -7,17 +7,11 @@
    */
   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>
    */
  @@ -29,7 +23,7 @@
       private StringUtil()
       {
       }
  -    
  +
       /**
        * Replace substrings of one string with another string and return altered string.
        *
  @@ -43,11 +37,11 @@
                                              final String newString )
       {
           final StringBuffer sb = new StringBuffer();
  -        
  +
           int end = original.indexOf( oldString );
           int start = 0;
           final int stringSize = oldString.length();
  -        
  +
           while( end != -1 )
           {
               sb.append( original.substring( start, end ) );
  @@ -55,107 +49,10 @@
               start = end + stringSize;
               end = original.indexOf( oldString, start );
           }
  -        
  +
           end = original.length();
           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 ] );
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message