Coverage Report - org.kuali.rice.core.util.RiceDebugUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
RiceDebugUtils
0%
0/15
0%
0/18
10
 
 1  
 /*
 2  
  * Copyright 2007-2009 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.util;
 17  
 
 18  
 /**
 19  
  * This is a description of what this class does - jonathan don't forget to fill this in. 
 20  
  * 
 21  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 22  
  *
 23  
  */
 24  0
 public class RiceDebugUtils {
 25  
 
 26  
         public static StringBuffer getTruncatedStackTrace( boolean excludeCaller ) {
 27  
             // temporary throwable to be able to obtain a stack trace
 28  0
             Throwable t = new Throwable();
 29  0
             t.fillInStackTrace();
 30  0
             StringBuffer sb = new StringBuffer();
 31  
             // loop over the stack trace, only including kuali classes
 32  
             // and excluding certain prefixes that are on almost all traces
 33  
             // within a web application
 34  
             // TODO: add exclusion paths for JUnit base classes
 35  0
             boolean firstRecord = true;
 36  0
             for ( StackTraceElement ste : t.getStackTrace() ) {
 37  0
                     if ( ste.getClassName().startsWith( "org.kuali" ) 
 38  
                                     && !ste.getClassName().endsWith( "RiceDebugUtils" )
 39  
                                     && !ste.getClassName().endsWith( "DaoProxy" )
 40  
                                     && !ste.getClassName().startsWith( "org.kuali.rice.kns.web.filter" ) 
 41  
                                     && !ste.getMethodName().equals( "doFilter" )
 42  
                                     && !ste.getMethodName().equals( "doInTransaction" )
 43  
                                     ) {
 44  0
                         if ( excludeCaller && firstRecord ) {
 45  0
                                 firstRecord = false;
 46  0
                                 continue;
 47  
                         }
 48  0
                             sb.append( "    " );
 49  0
                             sb.append( ste.getClassName() ).append( '.' ).append( ste.getMethodName() );
 50  0
                             sb.append( " - line " ).append( ste.getLineNumber() );
 51  0
                             sb.append( '\n' );
 52  
                     }
 53  
             }
 54  0
                 return sb;
 55  
         }
 56  
 }