public class CommandContext extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Set<Character> |
booleanFlags |
protected String |
command |
protected List<Integer> |
originalArgIndices |
protected String[] |
originalArgs |
protected List<String> |
parsedArgs |
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) |
| Modifier and Type | Method and Description |
|---|---|
int |
argsLength() |
String |
getCommand() |
double |
getDouble(int index) |
double |
getDouble(int index,
double def) |
String |
getFlag(char ch) |
String |
getFlag(char ch,
String def) |
double |
getFlagDouble(char ch) |
double |
getFlagDouble(char ch,
double def) |
int |
getFlagInteger(char ch) |
int |
getFlagInteger(char ch,
int def) |
Set<Character> |
getFlags() |
int |
getInteger(int index) |
int |
getInteger(int index,
int def) |
String |
getJoinedStrings(int initialIndex) |
String[] |
getPaddedSlice(int index,
int padding) |
String[] |
getParsedPaddedSlice(int index,
int padding) |
String[] |
getParsedSlice(int index) |
String[] |
getSlice(int index) |
String |
getString(int index) |
String |
getString(int index,
String def) |
Map<Character,String> |
getValueFlags() |
boolean |
hasFlag(char ch) |
boolean |
matches(String command) |
protected final String command
protected final String[] originalArgs
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) throws CommandException
args - An array with arguments. Empty strings outside quotes will be removed.valueFlags - A set containing all value flags. Pass null to disable value flag parsing.CommandException - This is thrown if flag fails for some reason.public String getCommand()
public boolean matches(String command)
public String getString(int index)
public String getJoinedStrings(int initialIndex)
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()
Copyright © 2010-2014. All Rights Reserved.