1 6 7 package fr.emn.info.eaop.event; 8 9 import java.util.*; 10 import java.lang.reflect.*; 11 import java.io.*; 12 13 19 public class MethodReturn extends Event { 20 21 public Object receiver; 22 public Method method; 23 public Object [] args; 24 public Object returnValue; 25 public int stackLevel; 26 27 public MethodReturn(Thread thread, Object returnValue, 28 Object receiver, Method method, Object [] args) { 29 super(thread); 30 this.receiver = receiver; 31 this.method = method; 32 this.args = args; 33 this.returnValue = returnValue; 34 this.stackLevel = 0; 37 StringWriter stringWriter = new StringWriter(); 38 PrintWriter printWriter = new PrintWriter(stringWriter, true); 39 new Exception ().printStackTrace(printWriter); 40 String string = stringWriter.toString(); 41 int pos = 0; 42 while ((pos = string.indexOf('\n', pos + 1)) > -1) { 43 this.stackLevel++; 44 } 45 } 46 public String toString() { 47 String result = "MethodReturn "; 48 result += returnValue; 49 result += this.toString2(); 50 return result; 51 } 52 public String toString2() { 53 String result = receiver + "." + method.getName() + "("; 54 for (int i=0; i<args.length; i++) { 55 result += args[i] + ","; 56 } 57 result += ")"; 58 result += super.toString(); 59 return result; 60 } 61 } 62 | Popular Tags |