public class CommandContext extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Set<Character> |
booleanFlags |
protected String |
command |
protected CommandLocals |
locals |
protected List<Integer> |
originalArgIndices |
protected String[] |
originalArgs |
protected List<String> |
parsedArgs |
protected SuggestionContext |
suggestionContext |
protected Map<Character,String> |
valueFlags |
| Constructor and Description |
|---|
CommandContext(String args) |
CommandContext(String[] args) |
CommandContext(String[] args,
Set<Character> valueFlags) |
CommandContext(String[] args,
Set<Character> valueFlags,
boolean allowHangingFlag,
CommandLocals locals)
Parse the given array of arguments.
|
CommandContext(String args,
Set<Character> valueFlags) |
CommandContext(String args,
Set<Character> valueFlags,
boolean allowHangingFlag) |
protected final String command
protected final String[] originalArgs
protected final SuggestionContext suggestionContext
protected final CommandLocals locals
public CommandContext(String args) throws CommandException
CommandExceptionpublic CommandContext(String[] args) throws CommandException
CommandExceptionpublic CommandContext(String args, Set<Character> valueFlags) throws CommandException
CommandExceptionpublic CommandContext(String args, Set<Character> valueFlags, boolean allowHangingFlag) throws CommandException
CommandExceptionpublic CommandContext(String[] args, Set<Character> valueFlags) throws CommandException
CommandExceptionpublic CommandContext(String[] args, Set<Character> valueFlags, boolean allowHangingFlag, CommandLocals locals) throws CommandException
Empty arguments are removed from the list of arguments.
args - an array with argumentsvalueFlags - a set containing all value flags (pass null to disable value flag parsing)allowHangingFlag - true if hanging flags are allowedlocals - the locals, null to create empty oneCommandException - thrown on a parsing errorpublic SuggestionContext getSuggestionContext()
public String getCommand()
public boolean matches(String command)
public String getString(int index)
public String getJoinedStrings(int initialIndex)
public String getRemainingString(int start)
public String getString(int start, int end)
public int getInteger(int index)
throws NumberFormatException
NumberFormatExceptionpublic int getInteger(int index,
int def)
throws NumberFormatException
NumberFormatExceptionpublic double getDouble(int index)
throws NumberFormatException
NumberFormatExceptionpublic double getDouble(int index,
double def)
throws NumberFormatException
NumberFormatExceptionpublic String[] getSlice(int index)
public String[] getPaddedSlice(int index, int padding)
public String[] getParsedSlice(int index)
public String[] getParsedPaddedSlice(int index, int padding)
public boolean hasFlag(char ch)
public String getFlag(char ch)
public int getFlagInteger(char ch)
throws NumberFormatException
NumberFormatExceptionpublic int getFlagInteger(char ch,
int def)
throws NumberFormatException
NumberFormatExceptionpublic double getFlagDouble(char ch)
throws NumberFormatException
NumberFormatExceptionpublic double getFlagDouble(char ch,
double def)
throws NumberFormatException
NumberFormatExceptionpublic int argsLength()
public CommandLocals getLocals()
Copyright © 2010-2014. All Rights Reserved.