|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.python.core.ArgParser
public class ArgParser
A utility class for handling mixed positional and keyword arguments. A typical usage:
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 Summary | |
---|---|
ArgParser(String funcname,
PyObject[] args,
String[] kws,
String p0)
Create an ArgParser with one method argument |
|
ArgParser(String funcname,
PyObject[] args,
String[] kws,
String[] paramnames)
Create an ArgParser with three method argument |
|
ArgParser(String funcname,
PyObject[] args,
String[] kws,
String[] paramnames,
int minargs)
|
|
ArgParser(String funcname,
PyObject[] args,
String[] kws,
String[] paramnames,
int minargs,
boolean takesZeroArgs)
|
|
ArgParser(String funcname,
PyObject[] args,
String[] kws,
String p0,
String p1)
Create an ArgParser with two method argument |
|
ArgParser(String funcname,
PyObject[] args,
String[] kws,
String p0,
String p1,
String p2)
Create an ArgParser with three method argument |
Method Summary | |
---|---|
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. |
String |
getString(int pos)
Return a required argument as a String. |
String |
getString(int pos,
String def)
Return an optional argument as a String. |
void |
noKeywords()
Ensure no keyword arguments were passed, raising a TypeError if so. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArgParser(String funcname, PyObject[] args, String[] kws, String p0)
funcname
- Name of the method. 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 method definition.public ArgParser(String funcname, PyObject[] args, String[] kws, String p0, String p1)
funcname
- Name of the method. 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 method definition.p1
- The second expected argument in the method definition.public ArgParser(String funcname, PyObject[] args, String[] kws, String p0, String p1, String p2)
funcname
- Name of the method. 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 method definition.p1
- The second expected argument in the method definition.p2
- The third expected argument in the method definition.public ArgParser(String funcname, PyObject[] args, String[] kws, String[] paramnames)
funcname
- Name of the method. 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 method definition.public ArgParser(String funcname, PyObject[] args, String[] kws, String[] paramnames, int minargs)
public ArgParser(String funcname, PyObject[] args, String[] kws, String[] paramnames, int minargs, boolean takesZeroArgs)
Method Detail |
---|
public String getString(int pos)
pos
- The position of the .. First argument is numbered 0.public String getString(int pos, 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 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 argument
public PyObject getList(int pos)
pos
- The position of the argument. First argument is numbered 0.public void noKeywords()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |