| Home >> All >> org >> alicebot >> server >> core >> [ util Javadoc ] |
Source code: org/alicebot/server/core/util/StackParser.java
1 // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov. 2 // Jad home page: http://www.geocities.com/kpdus/jad.html 3 // Decompiler options: packimports(3) 4 5 package org.alicebot.server.core.util; 6 7 import java.io.PrintWriter; 8 import java.io.StringWriter; 9 import java.util.StringTokenizer; 10 11 public class StackParser 12 { 13 14 private StackParser() 15 { 16 } 17 18 public static String getStackMethod(Throwable throwable, int i) 19 { 20 String s = null; 21 String s1 = getStackString(throwable); 22 int j; 23 for(j = 0; i-- >= 0 && j >= 0; j = s1.indexOf("at ", j + 3)); 24 if(j > 0) 25 { 26 int k = s1.indexOf('(', j); 27 if(k > 0) 28 s = s1.substring(j + 3, k); 29 } 30 return s; 31 } 32 33 public static String getStackMethod(int i) 34 { 35 i++; 36 Throwable throwable = (new Throwable()).fillInStackTrace(); 37 return getStackMethod(throwable, i); 38 } 39 40 public static String getStackMethodBefore(String s, boolean flag) 41 { 42 int i = 1; 43 String s1; 44 for(s1 = getStackMethod(i); s1.indexOf(s) != -1 && s1 != null; s1 = getStackMethod(++i)); 45 if(flag) 46 { 47 int j = s1.lastIndexOf('.', s1.lastIndexOf('.') - 1); 48 if(j != -1) 49 return s1.substring(j + 1); 50 else 51 return s1; 52 } else 53 { 54 return s1; 55 } 56 } 57 58 public static String getStackString(Throwable throwable) 59 { 60 StringWriter stringwriter = new StringWriter(); 61 throwable.printStackTrace(new PrintWriter(stringwriter)); 62 return stringwriter.toString(); 63 } 64 65 public static StringTokenizer getStackTraceFor(Throwable throwable) 66 { 67 return new StringTokenizer(getStackString(throwable), System.getProperty("line.separator")); 68 } 69 70 private static final String AT = "at "; 71 }