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 ConstructorCall extends Event { 20 21 public Object receiver; 22 public Constructor constructor; 23 public Object [] args; 24 25 29 public Object returnValue; 30 31 public int stackLevel; 32 33 public ConstructorCall(Thread thread, 34 Object receiver, 35 Constructor constructor, 36 Object [] args) { 37 super(thread); 38 this.receiver = receiver; 39 this.constructor = constructor; 40 this.args = args; 41 this.stackLevel = 0; 44 StringWriter stringWriter = new StringWriter(); 45 PrintWriter printWriter = new PrintWriter(stringWriter, true); 46 new Exception ().printStackTrace(printWriter); 47 String string = stringWriter.toString(); 48 int pos = 0; 49 while ((pos = string.indexOf('\n', pos + 1)) > -1) { 50 this.stackLevel++; 51 } 52 } 53 54 public String toString() { 55 String result = "ConstructorCall " + this.toString2(); 56 return result; 57 } 58 59 public String toString2() { 60 String result = receiver + "." + constructor.getName() + "("; 61 62 for (int i=0; i<args.length; i++) { 63 result += args[i] + ","; 64 } 65 66 result += ")"; 67 result += super.toString(); 68 return result; 69 } 70 } 71 72 | Popular Tags |