01: // Copyright (c) Corporation for National Research Initiatives
02: package org.python.core;
03:
04: import java.lang.reflect.*;
05:
06: public class PyBeanEvent extends PyObject {
07: public Method addMethod;
08: public Class eventClass;
09: public String __name__;
10:
11: public PyBeanEvent(String name, Class eventClass, Method addMethod) {
12: __name__ = name.intern();
13: this .addMethod = addMethod;
14: this .eventClass = eventClass;
15: }
16:
17: public PyObject _doget(PyObject container) {
18: throw Py.TypeError("write only attribute");
19: }
20:
21: boolean _jdontdel() {
22: throw Py.TypeError("can't delete this attribute");
23: }
24:
25: public boolean _doset(PyObject self, PyObject value) {
26: Object jself = Py.tojava(self, addMethod.getDeclaringClass());
27: Object jvalue = Py.tojava(value, eventClass);
28:
29: try {
30: addMethod.invoke(jself, new Object[] { jvalue });
31: } catch (Exception e) {
32: throw Py.JavaError(e);
33: }
34: return true;
35: }
36:
37: public String toString() {
38: return "<beanEvent " + __name__ + " for event "
39: + eventClass.toString() + " " + Py.idstr(this ) + ">";
40: }
41: }
|