src.org.python.antlr.ast.alias 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.
// Autogenerated AST node
package org.python.antlr.ast;
import org.antlr.runtime.CommonToken;
import org.antlr.runtime.Token;
import org.python.antlr.AST;
import org.python.antlr.PythonTree;
import org.python.antlr.adapter.AstAdapters;
import org.python.antlr.base.excepthandler;
import org.python.antlr.base.expr;
import org.python.antlr.base.mod;
import org.python.antlr.base.slice;
import org.python.antlr.base.stmt;
import org.python.core.ArgParser;
import org.python.core.AstList;
import org.python.core.Py;
import org.python.core.PyObject;
import org.python.core.PyString;
import org.python.core.PyType;
import org.python.expose.ExposedGet;
import org.python.expose.ExposedMethod;
import org.python.expose.ExposedNew;
import org.python.expose.ExposedSet;
import org.python.expose.ExposedType;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@ExposedType(name = "_ast.alias", base = AST.class)
public class alias extends PythonTree {
public static final PyType TYPE = PyType.fromClass(alias.class);
private String name;
public String getInternalName() {
return name;
}
@ExposedGet(name = "name")
public PyObject getName() {
if (name == null) return Py.None;
return new PyString(name);
}
@ExposedSet(name = "name")
public void setName(PyObject name) {
this.name = AstAdapters.py2identifier(name);
}
private java.util.List nameNodes;
public java.util.List getInternalNameNodes() {
return nameNodes;
}
private String asname;
public String getInternalAsname() {
return asname;
}
@ExposedGet(name = "asname")
public PyObject getAsname() {
if (asname == null) return Py.None;
return new PyString(asname);
}
@ExposedSet(name = "asname")
public void setAsname(PyObject asname) {
this.asname = AstAdapters.py2identifier(asname);
}
private Name asnameNode;
public Name getInternalAsnameNode() {
return asnameNode;
}
private final static PyString[] fields =
new PyString[] {new PyString("name"), new PyString("asname")};
@ExposedGet(name = "_fields")
public PyString[] get_fields() { return fields; }
private final static PyString[] attributes = new PyString[0];
@ExposedGet(name = "_attributes")
public PyString[] get_attributes() { return attributes; }
public alias(PyType subType) {
super(subType);
}
public alias() {
this(TYPE);
}
@ExposedNew
@ExposedMethod
public void alias___init__(PyObject[] args, String[] keywords) {
ArgParser ap = new ArgParser("alias", args, keywords, new String[]
{"name", "asname"}, 2, true);
setName(ap.getPyObject(0, Py.None));
setAsname(ap.getPyObject(1, Py.None));
}
public alias(PyObject name, PyObject asname) {
setName(name);
setAsname(asname);
}
public alias(Token token, String name, String asname) {
super(token);
this.name = name;
this.asname = asname;
}
// [import] name [as asname]
public alias(Name name, Name asname) {
this(java.util.Arrays.asList(new Name[]{name}), asname);
}
// [import] ...foo.bar.baz [as asname]
public alias(java.util.List nameNodes, Name asname) {
this.nameNodes = nameNodes;
this.name = dottedNameListToString(nameNodes);
if (asname != null) {
this.asnameNode = asname;
this.asname = asname.getInternalId();
}
}
public alias(Integer ttype, Token token, String name, String asname) {
super(ttype, token);
this.name = name;
this.asname = asname;
}
public alias(PythonTree tree, String name, String asname) {
super(tree);
this.name = name;
this.asname = asname;
}
@ExposedGet(name = "repr")
public String toString() {
return "alias";
}
public String toStringTree() {
StringBuffer sb = new StringBuffer("alias(");
sb.append("name=");
sb.append(dumpThis(name));
sb.append(",");
sb.append("asname=");
sb.append(dumpThis(asname));
sb.append(",");
sb.append(")");
return sb.toString();
}
public R accept(VisitorIF visitor) throws Exception {
traverse(visitor);
return null;
}
public void traverse(VisitorIF> visitor) throws Exception {
}
}