src.org.python.antlr.adapter.ExcepthandlerAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython-standalone Show documentation
Show all versions of jython-standalone Show documentation
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
package org.python.antlr.adapter;
import java.util.ArrayList;
import java.util.List;
import org.python.antlr.ast.ExceptHandler;
import org.python.core.Py;
import org.python.core.PyObject;
public class ExcepthandlerAdapter implements AstAdapter {
public Object py2ast(PyObject o) {
if (o instanceof ExceptHandler) {
return o;
}
return null;
}
public PyObject ast2py(Object o) {
if (o == null) {
return Py.None;
}
return (PyObject)o;
}
public List iter2ast(PyObject iter) {
List excepthandlers = new ArrayList();
if (iter != Py.None) {
for(Object o : (Iterable)iter) {
excepthandlers.add((ExceptHandler)py2ast((PyObject)o));
}
}
return excepthandlers;
}
}