org.kohsuke.args4j
Class CmdLineParser.CmdLineImpl
java.lang.Object
org.kohsuke.args4j.CmdLineParser.CmdLineImpl
- All Implemented Interfaces:
- CmdLineOption.Parameters
- Enclosing class:
- CmdLineParser
private class CmdLineParser.CmdLineImpl
- extends java.lang.Object
- implements CmdLineOption.Parameters
Essentially a pointer over a String
array.
Can move forward, can look ahead.
Field Summary |
private java.lang.String[] |
args
|
private int |
pos
|
Method Summary |
private java.lang.String |
getCurrentToken()
|
int |
getIntParameter(int idx)
The convenience method of
Integer.parseInt(getParameter(idx))
with proper error handling. |
java.lang.String |
getOptionName()
Gets the recognized option name. |
java.lang.String |
getParameter(int idx)
Gets the additional parameter to this option. |
private boolean |
hasMore()
|
private void |
proceed(int n)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
args
private final java.lang.String[] args
pos
private int pos
CmdLineParser.CmdLineImpl
CmdLineParser.CmdLineImpl(java.lang.String[] args)
hasMore
private boolean hasMore()
getCurrentToken
private java.lang.String getCurrentToken()
proceed
private void proceed(int n)
getOptionName
public java.lang.String getOptionName()
- Description copied from interface:
CmdLineOption.Parameters
- Gets the recognized option name.
- Specified by:
getOptionName
in interface CmdLineOption.Parameters
- Returns:
- This option name has been passed to the
CmdLineOption.accepts(String)
method and
the method has returned true
.
getParameter
public java.lang.String getParameter(int idx)
throws CmdLineException
- Description copied from interface:
CmdLineOption.Parameters
- Gets the additional parameter to this option.
- Specified by:
getParameter
in interface CmdLineOption.Parameters
- Parameters:
idx
- specifying 0 will retrieve the token next to the option.
For example, if the command line looks like "-o abc -d x",
then getParameter(0)
for "-o" returns "abc"
and getParameter(1)
will return "-d".
- Returns:
- Always return non-null valid String. If an attempt is
made to access a non-existent index, this method throws
appropriate
CmdLineException
.
- Throws:
CmdLineException
getIntParameter
public int getIntParameter(int idx)
throws CmdLineException
- Description copied from interface:
CmdLineOption.Parameters
- The convenience method of
Integer.parseInt(getParameter(idx))
with proper error handling.
- Specified by:
getIntParameter
in interface CmdLineOption.Parameters
- Throws:
CmdLineException
- If the parameter is not an integer, it throws an
approrpiate CmdLineException
.
Copyright © 2003 Kohsuke Kawaguchi. All Rights Reserved.