|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmegamek.common.util.AbstractCommandLineParser
public abstract class AbstractCommandLineParser
Very simple skeleton for the command line parser. Provides basic scanner
primitives and token types. Descendants should implement at least
start function
| Nested Class Summary | |
|---|---|
static class |
AbstractCommandLineParser.ParseException
Exception thrown in case of error |
| Field Summary | |
|---|---|
protected java.lang.String |
OPTION_PREFIX
Prefix of the option. |
protected static int |
TOK_EOF
End of input token |
protected static int |
TOK_LITERAL
Literal (any string that doesn not start with defice actually) |
protected static int |
TOK_OPTION
Option token |
| Constructor Summary | |
|---|---|
AbstractCommandLineParser(java.lang.String[] args)
Constructs new parser |
|
| Method Summary | |
|---|---|
protected void |
error(java.lang.String message)
Indicates the parse error |
protected java.lang.String |
getArgValue()
Returns current arg |
protected int |
getPosition()
Returns String value of the current token |
protected int |
getToken()
Returns current token |
protected java.lang.String |
getTokenValue()
Returns String value of the current token |
protected void |
nextArg()
|
protected void |
nextToken()
Reads the next available token. |
void |
parse()
Main entry point of the parser |
protected void |
setToken(int token)
Sets the current token |
protected void |
setTokenValue(java.lang.String tokenValue)
Sets the current token |
protected abstract void |
start()
Real entry point of parser |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String OPTION_PREFIX
protected static final int TOK_EOF
protected static final int TOK_OPTION
protected static final int TOK_LITERAL
| Constructor Detail |
|---|
public AbstractCommandLineParser(java.lang.String[] args)
args - array of arguments to parse| Method Detail |
|---|
public void parse()
throws AbstractCommandLineParser.ParseException
AbstractCommandLineParser.ParseExceptionprotected java.lang.String getArgValue()
protected int getToken()
protected void setToken(int token)
token - protected java.lang.String getTokenValue()
String value of the current token
protected void setTokenValue(java.lang.String tokenValue)
tokenValue - protected int getPosition()
String value of the current token
protected abstract void start()
throws AbstractCommandLineParser.ParseException
AbstractCommandLineParser.ParseExceptionprotected void nextToken()
protected void nextArg()
protected void error(java.lang.String message)
throws AbstractCommandLineParser.ParseException
message -
AbstractCommandLineParser.ParseException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||