public class CommandArgsBase extends Object
Modifier and Type | Field and Description |
---|---|
protected CommandsMessages |
messages |
Constructor and Description |
---|
CommandArgsBase(CommandsMessages messages,
CommandArgsParser parser) |
Modifier and Type | Method and Description |
---|---|
List<String> |
asList()
Returns all arguments as a list.
|
List<String> |
asList(int index)
Returns all arguments starting from index as a list.
|
List<String> |
asList(int index,
int endIndex)
Returns all arguments from index to endIndex
as a list.
|
Iterable<Character> |
flags()
Returns an iterable over all boolean flags.
|
String |
get(char flag)
Get the given argument flag value.
|
<T extends Enum<T>> |
get(char flag,
Class<T> enumClass)
Get the
EnumArg value corresponding to
the given enum class for the given flag. |
<T extends CommandArg<?>> |
get(char flag,
CommandArgFactory<T> factory)
Get the
CommandArg corresponding to
the given factory for the given argument flag. |
String |
get(char flag,
String def)
Get the given argument flag value or
the default if omitted.
|
String |
get(int index)
Get the argument at the given position.
|
<T extends Enum<T>> |
get(int index,
Class<T> enumClass)
Get the
EnumArg value corresponding to
the given enum class for the given index. |
<T extends CommandArg<?>> |
get(int index,
CommandArgFactory<T> factory)
Get the
CommandArg corresponding to
the given factory for the given index. |
String |
get(int index,
int rawEndIndex)
Get the string containing all arguments from index
to endIndex separated by a whitespace.
|
String |
get(int index,
int endIndex,
String def)
Get the string containing all arguments from index
to endIndex separated by a whitespace or the given default.
|
String |
get(int index,
String def)
Get the argument at the given position or
the default if argument is omitted.
|
<T extends Enum<T>> |
getList(char flag,
Class<T> klass)
|
<T extends Enum<T>> |
getList(char flag,
Class<T> klass,
String separator)
|
<V,T extends CommandArg<V>> |
getList(char flag,
CommandArgFactory<T> factory)
Get the
ListArg wrapping the CommandArg
corresponding to the given factory for the given flag. |
<V,T extends CommandArg<V>> |
getList(char flag,
CommandArgFactory<T> factory,
String separator)
Get the
ListArg wrapping the CommandArg
corresponding to the given factory for the given flag
using the given separator. |
<T extends Enum<T>> |
getList(int index,
Class<T> klass)
|
<T extends Enum<T>> |
getList(int index,
Class<T> klass,
String separator)
|
<V,T extends CommandArg<V>> |
getList(int index,
CommandArgFactory<T> factory)
Get the
ListArg wrapping the CommandArg
corresponding to the given factory for the given index. |
<V,T extends CommandArg<V>> |
getList(int index,
CommandArgFactory<T> factory,
String separator)
Get the
ListArg wrapping the CommandArg
corresponding to the given factory for the given index
using the given separator. |
protected String |
getOrNull(char flag) |
protected String |
getOrNull(int index) |
boolean |
hasArgFlag(char character)
Checks if the commands has the given argument
flag.
|
boolean |
hasFlag(char character)
Checks if the commands has the given boolean
flag.
|
boolean |
hasFlags()
Checks if the command has flags either
boolean flag or argument flag.
|
Iterator<String> |
iterator()
Iterator over all arguments
(does not include argument flags).
|
int |
length()
Returns the number of argument.
|
protected final CommandsMessages messages
public CommandArgsBase(CommandsMessages messages, CommandArgsParser parser)
public boolean hasFlags()
public boolean hasFlag(char character)
public boolean hasArgFlag(char character)
public int length()
public String get(int index, String def)
public String get(char flag, String def)
public <T extends CommandArg<?>> T get(int index, CommandArgFactory<T> factory)
CommandArg
corresponding to
the given factory for the given index.public <T extends CommandArg<?>> T get(char flag, CommandArgFactory<T> factory)
CommandArg
corresponding to
the given factory for the given argument flag.public <T extends Enum<T>> EnumArg<T> get(int index, Class<T> enumClass)
EnumArg
value corresponding to
the given enum class for the given index.public <T extends Enum<T>> EnumArg<T> get(char flag, Class<T> enumClass)
EnumArg
value corresponding to
the given enum class for the given flag.public <V,T extends CommandArg<V>> ListArg<V,T> getList(int index, CommandArgFactory<T> factory)
ListArg
wrapping the CommandArg
corresponding to the given factory for the given index.public <V,T extends CommandArg<V>> ListArg<V,T> getList(int index, CommandArgFactory<T> factory, String separator)
ListArg
wrapping the CommandArg
corresponding to the given factory for the given index
using the given separator.public <V,T extends CommandArg<V>> ListArg<V,T> getList(char flag, CommandArgFactory<T> factory)
ListArg
wrapping the CommandArg
corresponding to the given factory for the given flag.public <V,T extends CommandArg<V>> ListArg<V,T> getList(char flag, CommandArgFactory<T> factory, String separator)
ListArg
wrapping the CommandArg
corresponding to the given factory for the given flag
using the given separator.public <T extends Enum<T>> ListArg<T,EnumArg<T>> getList(int index, Class<T> klass, String separator)
public <T extends Enum<T>> ListArg<T,EnumArg<T>> getList(char flag, Class<T> klass, String separator)
public String get(int index, int rawEndIndex)
public String get(int index, int endIndex, String def)
public List<String> asList(int index, int endIndex)
Copyright © 2012. All Rights Reserved.