KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > PyBeanEvent


1 // Copyright (c) Corporation for National Research Initiatives
2
package org.python.core;
3 import java.lang.reflect.*;
4
5 public class PyBeanEvent extends PyObject {
6     public Method addMethod;
7     public Class JavaDoc eventClass;
8     public String JavaDoc __name__;
9
10     public PyBeanEvent(String JavaDoc name, Class JavaDoc 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 JavaDoc jself = Py.tojava(self, addMethod.getDeclaringClass());
26         Object JavaDoc jvalue = Py.tojava(value, eventClass);
27
28         try {
29             addMethod.invoke(jself, new Object JavaDoc[] {jvalue});
30         } catch (Exception JavaDoc e) {
31             throw Py.JavaError(e);
32         }
33         return true;
34     }
35
36     public String JavaDoc toString() {
37         return "<beanEvent "+__name__+" for event "+
38             eventClass.toString()+" "+Py.idstr(this)+">";
39     }
40 }
41
Popular Tags