本文整理匯總了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;
}