KickJava   Java API By Example, From Geeks To Geeks.

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


1 // Copyright (c) Corporation for National Research Initiatives
2
package org.python.core;
3 import java.util.Vector JavaDoc;
4
5 public class PyCompoundCallable extends PyObject {
6     private Vector JavaDoc callables;
7     private PySystemState systemState;
8
9     public PyCompoundCallable () {
10         callables = new Vector JavaDoc();
11         systemState = Py.getSystemState();
12     }
13
14     public void append(PyObject callable) {
15         callables.addElement(callable);
16     }
17
18     public void clear() {
19         callables.removeAllElements();
20     }
21
22     public PyObject __call__(PyObject[] args, String JavaDoc[] keywords) {
23         // Set the system state to handle callbacks from java threads
24
Py.setSystemState(systemState);
25         int n = callables.size();
26         //System.out.println("callable: "+n);
27
for (int i=0; i<n; i++) {
28             ((PyObject)callables.elementAt(i)).__call__(args, keywords);
29         }
30         return Py.None;
31     }
32
33     public String JavaDoc toString() {
34         return "<CompoundCallable with "+callables.size()+" callables>";
35     }
36 }
37
Popular Tags