本文整理汇总了Java中org.python.core.PyObject.__finditem__方法的典型用法代码示例。如果您正苦于以下问题:Java PyObject.__finditem__方法的具体用法?Java PyObject.__finditem__怎么用?Java PyObject.__finditem__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.python.core.PyObject
的用法示例。
在下文中一共展示了PyObject.__finditem__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildren
import org.python.core.PyObject; //导入方法依赖的package包/类
@Override
public ArrayList<PyObjectAdapter> getChildren(Object object) {
if (!(object instanceof PyInstance))
throw new IllegalArgumentException("object is not instance of PyInstance");
PyInstance pyInstance = (PyInstance)object;
PyList keys = null;
if (pyInstance.__dict__ instanceof PyDictionary)
keys = ((PyDictionary)pyInstance.__dict__).keys();
if (pyInstance.__dict__ instanceof PyStringMap)
keys = ((PyStringMap)pyInstance.__dict__).keys();
if (keys == null)
return null;
final PyObject pyDict = pyInstance.__dict__;
int count = keys.__len__();
ArrayList<PyObjectAdapter> list = new ArrayList<PyObjectAdapter>(count);
PyObject obj;
for (int i = 0; i < count; ++i){
final PyObject key = keys.__getitem__(i);
Object name = (String)key.__tojava__(String.class);
if ((name == Py.NoConversion) || (!(name instanceof String))) continue;
obj = pyDict.__finditem__(key);
list.add(
new PyObjectAdapter(
(String)name,
new PyObjectPlace(){
private PyObject myPlace = key;
@Override
public void set(PyObject newValue) {
pyDict.__setitem__(myPlace, newValue);
}
@Override
public PyObject get(){
try{
return pyDict.__finditem__(myPlace);
} catch (Exception e){
return null;
}
}
}
)
);
}
return list;
}