1 18 19 package org.objectweb.jac.aspects.gui; 20 21 import java.util.Arrays ; 22 import org.objectweb.jac.core.NameRepository; 23 import org.objectweb.jac.core.rtti.AbstractMethodItem; 24 import org.objectweb.jac.util.Strings; 25 26 30 public class Callback { 31 AbstractMethodItem method; 32 Object [] parameters; 33 String objectName; 34 36 public Callback(String objectName,AbstractMethodItem method, Object [] parameters) { 37 if (Strings.isEmpty(objectName) && !method.isStatic()) 38 throw new RuntimeException ("Method "+method+" is not static; An object must be provided"); 39 this.objectName = objectName; 40 this.method = method; 41 this.parameters = parameters; 42 } 43 45 public AbstractMethodItem getMethod() { 46 return method; 47 } 48 50 public Object [] getParameters() { 51 return parameters; 52 } 53 public String getObjectName() { 54 return objectName; 55 } 56 Object object; 57 public Object getObject() { 58 if (object==null && objectName!=null) { 59 object = NameRepository.get().getObject(objectName); 60 } 61 return object; 62 } 63 64 public void invoke(DisplayContext context, View source) { 65 EventHandler.get().onInvoke( 66 context, 67 new InvokeEvent(source,getObject(),method,parameters)); 68 } 69 70 public String toString() { 71 return "Callback@"+Integer.toHexString(System.identityHashCode(this))+ 72 " "+objectName+"."+method.getName()+ 73 "("+(parameters!=null?Arrays.asList(parameters).toString():"")+")"; 74 } 75 } 76 | Popular Tags |