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