## org.python.core
Class ArgParser

    java.lang.Object
      |
      +--org.python.core.ArgParser

public class ArgParser
extends java.lang.Object

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(java.lang.String funcname, PyObject[] args, java.lang.String[] kws, java.lang.String p0)` Create an ArgParser with one method argument
`ArgParser(java.lang.String funcname, PyObject[] args, java.lang.String[] kws, java.lang.String[] paramnames)` Create an ArgParser with three method argument
`ArgParser(java.lang.String funcname, PyObject[] args, java.lang.String[] kws, java.lang.String p0, java.lang.String p1)` Create an ArgParser with two method argument
`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 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 optiona argument as a PyObject.
`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.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ArgParser

    public ArgParser(java.lang.String funcname,
                     PyObject[] args,
                     java.lang.String[] kws,
                     java.lang.String p0)

  Create an ArgParser with one method argument

Parameters:
  `funcname` - Name of the method. Used in error messages.
  `args` - The actual call arguments supplied in the call.
  `p0` - The expected argument in the method definition.

### ArgParser

    public ArgParser(java.lang.String funcname,
                     PyObject[] args,
                     java.lang.String[] kws,
                     java.lang.String p0,
                     java.lang.String p1)

  Create an ArgParser with two method argument

Parameters:
  `funcname` - Name of the method. Used in error messages.
  `args` - The actual call arguments supplied in the call.
  `p0` - The first expected argument in the method definition.
  `p1` - The second expected argument in the method definition.

### ArgParser

    public 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 with three method argument

Parameters:
  `funcname` - Name of the method. Used in error messages.
  `args` - The actual call arguments 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.

### ArgParser

    public ArgParser(java.lang.String funcname,
                     PyObject[] args,
                     java.lang.String[] kws,
                     java.lang.String[] paramnames)

  Create an ArgParser with three method argument

Parameters:
  `funcname` - Name of the method. Used in error messages.
  `args` - The actual call arguments supplied in the call.
  `paramnames` - The list of expected argument in the method definition.

Method Detail

### getString

    public java.lang.String getString(int pos)

  Return a required argument as a String.

  Parameters:
    `pos` - The position of the argument. First argument is numbered 0.

### getString

    public java.lang.String getString(int pos,
                                      java.lang.String def)

  Return an optional argument as a String.

  Parameters:
    `pos` - The position of the argument. First argument is numbered 0.

### getInt

    public int getInt(int pos)

  Return a required argument as an int.

  Parameters:
    `pos` - The position of the argument. First argument is numbered 0.

### getInt

    public int getInt(int pos,
                      int def)

  Return an optional argument as an int.

  Parameters:
    `pos` - The position of the argument. First argument is numbered 0.

### getPyObject

    public PyObject getPyObject(int pos)

  Return a required argument as a PyObject.

  Parameters:
    `pos` - The position of the argument. First argument is numbered 0.

### getPyObject

    public PyObject getPyObject(int pos,
                                PyObject def)

  Return an optiona argument as a PyObject.

  Parameters:
    `pos` - The position of the argument. First argument is numbered 0.

### getList

    public PyObject getList(int pos)

  Return the remaining arguments as a tuple.

  Parameters:
    `pos` - The position of the argument. First argument is numbered 0.

Jython homepage