public class InputLine extends Object
getArg(int)
) or as an integer (from getIntArg(int)
.
Supplying an empty command line will throw a CommandNotFoundException
if you try to get it,
so check that the command line is not empty.
Created by Jeff Gaynor
on 5/17/13 at 11:10 AM
Modifier and Type | Field and Description |
---|---|
static String |
COMMAND_DELIMITER |
protected List<String> |
parsedInput |
Modifier | Constructor and Description |
---|---|
protected |
InputLine() |
|
InputLine(Vector v) |
Modifier and Type | Method and Description |
---|---|
String[] |
argsToStringArray()
This returns this as a string
|
Vector |
argsToVector()
returns the arguments as a vector.
|
String |
format() |
String |
getArg(int index)
Remember that the zero-th argument is the command, so that the arguments properly
begin at index = 1.
|
int |
getArgCount()
Returns the number of arguments for this input line.
|
List<String> |
getArgs() |
String |
getCommand()
This returns the zero-th input.
|
int |
getIntArg(int index) |
String |
getLastArg() |
String |
getNextArgFor(String key)
This will find the index for the "key" and return the very next argument.
|
boolean |
hasArg(String arg)
Check if the input line has the given argument.
|
boolean |
hasArgs()
If this command line has arguments at all.
|
int |
indexOf(String arg)
Returns the index of the target in the input line or a -1 if it does not occur.
|
boolean |
isEmpty()
Returns true if this command line was created with an empty string.
|
void |
removeSwitch(String value)
Remove a value.
|
void |
removeSwitchAndValue(String value)
Use for switches with value, e.g.
|
int |
size() |
String |
toString() |
public static final String COMMAND_DELIMITER
public InputLine(Vector v)
protected InputLine()
public String[] argsToStringArray()
public Vector argsToVector()
public void removeSwitchAndValue(String value)
removeSwitch(String)
value
- public void removeSwitch(String value)
removeSwitchAndValue(String)
value
- public String format()
public String getCommand()
public String getLastArg()
public String getArg(int index)
index
- public int getIntArg(int index)
public boolean isEmpty()
public int size()
public boolean hasArg(String arg)
arg
- public boolean hasArgs()
public int indexOf(String arg)
arg
- public String getNextArgFor(String key)
myfunc -x foo -y fnord -blargThen
getNextArgFor("-x");would return "foo". On the other hand
getNextArgFor("-blarg");would return a null, since there is no possible argument for it.
key
- public int getArgCount()
Copyright © 2019. All Rights Reserved.