public class ArgParser
extends java.lang.Object
public MatchObject search(PyObject[] args, String[] kws) {
ArgParser ap = new ArgParser("search", args, kws,
"pattern", "pos", "endpos");
String string = ap.getString(0);
int start = ap.getInt(1, 0);
int end = ap.getInt(2, string.length());
...
| Constructor and Description |
|---|
ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String p0)
Create an ArgParser for a one-argument function.
|
ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String[] paramnames)
Create an ArgParser for a multi-argument function.
|
ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String[] paramnames,
int minargs) |
ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String[] paramnames,
int minargs,
boolean takesZeroArgs) |
ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String p0,
java.lang.String p1)
Create an ArgParser for a two-argument function.
|
ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String p0,
java.lang.String p1,
java.lang.String p2)
Create an ArgParser for a three-argument function.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getIndex(int pos)
Return an required argument as an index.
|
int |
getIndex(int pos,
int def)
Return an optional argument as an index.
|
int |
getInt(int pos)
Return a required argument as an int.
|
int |
getInt(int pos,
int def)
Return an optional argument as an int.
|
PyObject |
getList(int pos)
Return the remaining arguments as a tuple.
|
PyObject |
getPyObject(int pos)
Return a required argument as a PyObject.
|
PyObject |
getPyObject(int pos,
PyObject def)
Return an optional argument as a PyObject.
|
PyObject |
getPyObjectByType(int pos,
PyType type)
Return a required argument as a PyObject, ensuring the object is of the specified type.
|
PyObject |
getPyObjectByType(int pos,
PyType type,
PyObject def)
Return an optional argument as a PyObject, or return the default value provided, which may
be
null. |
java.lang.String |
getString(int pos)
Return a required argument as a String.
|
java.lang.String |
getString(int pos,
java.lang.String def)
Return an optional argument as a String.
|
void |
noKeywords()
Ensure no keyword arguments were passed, raising a TypeError if
so.
|
public ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String p0)
funcname - Name of the function. Used in error messages.args - The actual call arguments supplied in the call.kws - The actual keyword names supplied in the call.p0 - The expected argument in the function definition.public ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String p0,
java.lang.String p1)
funcname - Name of the function. Used in error messages.args - The actual call arguments supplied in the call.kws - The actual keyword names supplied in the call.p0 - The first expected argument in the function definition.p1 - The second expected argument in the function definition.public ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String p0,
java.lang.String p1,
java.lang.String p2)
funcname - Name of the function. Used in error messages.args - The actual call arguments supplied in the call.kws - The actual keyword names supplied in the call.p0 - The first expected argument in the function definition.p1 - The second expected argument in the function definition.p2 - The third expected argument in the function definition.public ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String[] paramnames)
funcname - Name of the function. Used in error messages.args - The actual call arguments supplied in the call.kws - The actual keyword names supplied in the call.paramnames - The list of expected argument in the function definition.public ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String[] paramnames,
int minargs)
public ArgParser(java.lang.String funcname,
PyObject[] args,
java.lang.String[] kws,
java.lang.String[] paramnames,
int minargs,
boolean takesZeroArgs)
public java.lang.String getString(int pos)
pos - The position of the .. First argument is numbered 0.public java.lang.String getString(int pos,
java.lang.String def)
pos - The position of the argument. First argument is numbered 0.public int getInt(int pos)
pos - The position of the argument. First argument is numbered 0.public int getInt(int pos,
int def)
pos - The position of the argument. First argument is numbered 0.public int getIndex(int pos)
pos - The position of the argument. First argument is numbered 0.public int getIndex(int pos,
int def)
pos - The position of the argument. First argument is numbered 0.public PyObject getPyObject(int pos)
pos - The position of the argument. First argument is numbered 0.public PyObject getPyObject(int pos, PyObject def)
pos - The position of the argument. First argument is numbered 0.public PyObject getPyObjectByType(int pos, PyType type)
pos - the position of the argument. First argument is numbered 0type - the desired PyType of the argumentpublic PyObject getPyObjectByType(int pos, PyType type, PyObject def)
null. If the returned value is not null, it must be of the
specified type.pos - the position of the argument. First argument is numbered 0type - the desired PyType of the argumentdef - to return if the argument at pos was not given (null allowed)public PyObject getList(int pos)
pos - The position of the argument. First argument is numbered 0.public void noKeywords()