public class CommandFormat
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
CommandFormat.DuplicatedOptionException |
Used when a duplicated option is supplied to a command.
|
static class |
CommandFormat.IllegalNumberOfArgumentsException |
Used when the arguments exceed their bounds
|
static class |
CommandFormat.NotEnoughArgumentsException |
Used when too few arguments are supplied to a command
|
static class |
CommandFormat.TooManyArgumentsException |
Used when too many arguments are supplied to a command
|
static class |
CommandFormat.UnknownOptionException |
Used when an unsupported option is supplied to a command
|
| Constructor | Description |
|---|---|
CommandFormat(int min,
int max,
java.lang.String... possibleOpt) |
Simple parsing of command line arguments
|
CommandFormat(java.lang.String name,
int min,
int max,
java.lang.String... possibleOpt) |
Deprecated.
use replacement since name is an unused parameter
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addOptionWithValue(java.lang.String option) |
add option with value
|
boolean |
getOpt(java.lang.String option) |
Return if the option is set or not
|
java.util.Set<java.lang.String> |
getOpts() |
Returns all the options that are set
|
java.lang.String |
getOptValue(java.lang.String option) |
get the option's value
|
java.util.List<java.lang.String> |
parse(java.lang.String[] args,
int pos) |
Parse parameters starting from the given position
Consider using the variant that directly takes a List
|
void |
parse(java.util.List<java.lang.String> args) |
Parse parameters from the given list of args.
|
@Deprecated
public CommandFormat(java.lang.String name,
int min,
int max,
java.lang.String... possibleOpt)
name - of command, but never usedmin - see replacementmax - see replacementpossibleOpt - see replacementCommandFormat(int, int, String...)public CommandFormat(int min,
int max,
java.lang.String... possibleOpt)
min - minimum arguments requiredmax - maximum arguments permittedpossibleOpt - list of the allowed switchespublic void addOptionWithValue(java.lang.String option)
option - option namepublic java.util.List<java.lang.String> parse(java.lang.String[] args,
int pos)
args - an array of input argumentspos - the position at which starts to parsepublic void parse(java.util.List<java.lang.String> args)
args - as a list of input argumentspublic boolean getOpt(java.lang.String option)
option - String representation of an optionpublic java.lang.String getOptValue(java.lang.String option)
option - option namepublic java.util.Set<java.lang.String> getOpts()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.