Package org.kohsuke.args4j.spi
Class StringArrayOptionHandler
- java.lang.Object
-
- org.kohsuke.args4j.spi.OptionHandler<java.lang.String>
-
- org.kohsuke.args4j.spi.StringArrayOptionHandler
-
public class StringArrayOptionHandler extends OptionHandler<java.lang.String>
An
OptionHandler
for greedily mapping a list of tokens into a collection ofString
s (such asString[]
,List<String>
, etc.).How it works:
Example for parameter
-s
, which is typeString[]
:java -jar aaa.jar -s banan hruska jablko java -jar aaa.jar -s banan "hruska jablko" java -jar aaa.jar -s "banan hruska jablko" java -jar aaa.jar -s banan hruska jablko -l 4 -r java -jar aaa.jar -t 222 -s banan hruska jablko -r
All of them result in a single string array that contains three tokens:
banan
,hruska
, andjablko
.This
OptionHandler
scans for parameter which begins with -. If found, it will stop.- Author:
- PlainText,LuVar
-
-
Field Summary
-
Fields inherited from class org.kohsuke.args4j.spi.OptionHandler
option, owner, setter
-
-
Constructor Summary
Constructors Constructor Description StringArrayOptionHandler(CmdLineParser parser, OptionDef option, Setter<java.lang.String> setter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDefaultMetaVariable()
Returns"STRING[]"
.int
parseArguments(Parameters params)
Tries to parseString[]
argument fromParameters
.-
Methods inherited from class org.kohsuke.args4j.spi.OptionHandler
getMetaVariable, getNameAndMeta, getNameAndMeta, print, printDefaultValue
-
-
-
-
Constructor Detail
-
StringArrayOptionHandler
public StringArrayOptionHandler(CmdLineParser parser, OptionDef option, Setter<java.lang.String> setter)
-
-
Method Detail
-
getDefaultMetaVariable
public java.lang.String getDefaultMetaVariable()
Returns"STRING[]"
.- Specified by:
getDefaultMetaVariable
in classOptionHandler<java.lang.String>
- Returns:
- return "STRING[]";
-
parseArguments
public int parseArguments(Parameters params) throws CmdLineException
Tries to parseString[]
argument fromParameters
.- Specified by:
parseArguments
in classOptionHandler<java.lang.String>
- Parameters:
params
- The rest of the arguments. This method can use this object to access the arguments of the option if necessary. The object is valid only during the method call.- Returns:
- The number of arguments consumed. (For example, returns
0
if this option doesn't take any parameters.) - Throws:
CmdLineException
-
-