| java.lang.Object com.ibm.icu.dev.tool.UOption
UOption | public class UOption (Code) | | A command-line option. A UOption specifies the name of an option
and whether or not it takes an argument. It is a mutable object
that later contains the option argument, if any, and a boolean
flag stating whether the option was seen or not.
The static method parseArgs() takes an array of command-line
arguments and an array of UOptions and parses the command-line
arguments.
This deliberately resembles the icu4c file uoption.[ch].
|
Inner Class :public interface Fn | |
NO_ARG | final public static int NO_ARG(Code) | | |
OPTIONAL_ARG | final public static int OPTIONAL_ARG(Code) | | |
REQUIRES_ARG | final public static int REQUIRES_ARG(Code) | | |
doesOccur | public boolean doesOccur(Code) | | |
optionFn | public Fn optionFn(Code) | | |
shortName | public char shortName(Code) | | |
DEF | public static UOption DEF(String aLongName, char aShortName, int hasArgument)(Code) | | Create a UOption with the given attributes.
Synonym for create(), for C compatibility.
|
HELP_QUESTION_MARK | public static UOption HELP_QUESTION_MARK()(Code) | | |
create | public static UOption create(String aLongName, char aShortName, int hasArgument)(Code) | | Create a UOption with the given attributes.
|
parseArgs | public static int parseArgs(String argv, int start, UOption options)(Code) | | Java Command line argument parser.
This function takes the argv[] command line and a description of
the program's options in form of an array of UOption structures.
Each UOption defines a long and a short name (a string and a character)
for options like "--foo" and "-f".
Each option is marked with whether it does not take an argument,
requires one, or optionally takes one. The argument may follow in
the same argv[] entry for short options, or it may always follow
in the next argv[] entry.
An argument is in the next argv[] entry for both long and short name
options, except it is taken from directly behind the short name in
its own argv[] entry if there are characters following the option letter.
An argument in its own argv[] entry must not begin with a '-'
unless it is only the '-' itself. There is no restriction of the
argument format if it is part of the short name options's argv[] entry.
The argument is stored in the value field of the corresponding
UOption entry, and the doesOccur field is set to 1 if the option
is found at all.
Short name options without arguments can be collapsed into a single
argv[] entry. After an option letter takes an argument, following
letters will be taken as its argument.
If the same option is found several times, then the last
argument value will be stored in the value field.
For each option, a function can be called. This could be used
for options that occur multiple times and all arguments are to
be collected.
All options are removed from the argv[] array itself. If the parser
is successful, then it returns the number of remaining non-option
strings. (Unlike C, the Java argv[] array does NOT contain
the program name in argv[0].)
An option "--" ends option processing; everything after this
remains in the argv[] array.
An option string "-" alone is treated as a non-option.
If an option is not recognized or an argument missing, then
the parser returns with the negative index of the argv[] entry
where the error was detected.
Parameters: argv - this parameter is modified Parameters: start - the first argument in argv[] to examine. Must be0..argv.length-1. Arguments from 0..start-1 are ignored. Parameters: options - this parameter is modified the number of unprocessed arguments in argv[], includingarguments 0..start-1. |
setDefault | public UOption setDefault(String s)(Code) | | Allows the default to be set in an option list.
Parameters: s - this |
|
|