1 package org.python.core; 3 import java.lang.reflect.*; 4 5 public class PyBeanEvent extends PyObject { 6 public Method addMethod; 7 public Class eventClass; 8 public String __name__; 9 10 public PyBeanEvent(String name, Class eventClass, Method addMethod) { 11 __name__ = name.intern(); 12 this.addMethod = addMethod; 13 this.eventClass = eventClass; 14 } 15 16 public PyObject _doget(PyObject container) { 17 throw Py.TypeError("write only attribute"); 18 } 19 20 boolean _jdontdel() { 21 throw Py.TypeError("can't delete this attribute"); 22 } 23 24 public boolean _doset(PyObject self, PyObject value) { 25 Object jself = Py.tojava(self, addMethod.getDeclaringClass()); 26 Object jvalue = Py.tojava(value, eventClass); 27 28 try { 29 addMethod.invoke(jself, new Object [] {jvalue}); 30 } catch (Exception e) { 31 throw Py.JavaError(e); 32 } 33 return true; 34 } 35 36 public String toString() { 37 return "<beanEvent "+__name__+" for event "+ 38 eventClass.toString()+" "+Py.idstr(this)+">"; 39 } 40 } 41 | Popular Tags |