Class AppendConstArgumentAction
java.lang.Object
net.sourceforge.argparse4j.impl.action.AppendConstArgumentAction
- All Implemented Interfaces:
ArgumentAction
Argument action to store a list.
This action appends the value specified by Argument.setConst(Object)
to the list. (Note that the const value defaults to null
.) The list
is of type List
. This action is typically useful when
multiple arguments need to store constants to the same list. If attrs
contains non-List object for key Argument.getDest()
, it will be
overwritten by the List containing value
. consumeArgument()
always returns false
.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if this action consumes argument.void
Called when ArgumentAction is added toArgument
usingArgument.action(ArgumentAction)
.void
Executes this action.
-
Constructor Details
-
AppendConstArgumentAction
public AppendConstArgumentAction()
-
-
Method Details
-
run
public void run(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value) throws ArgumentParserExceptionDescription copied from interface:ArgumentAction
Executes this action.
If the objects derived from
RuntimeException
are thrown in this method because of invalid input from command line, subclass must catch these exceptions and wrap them inArgumentParserException
and give simple error message to explain what happened briefly.- Specified by:
run
in interfaceArgumentAction
- Parameters:
parser
- The parser.arg
- The argument this action attached to.attrs
- Map to store attributes.flag
- The actual option flag in command line ifarg
is an optional arguments.null
ifarg
is a positional argument.value
- The attribute value. This may be null if this action does not consume any arguments.- Throws:
ArgumentParserException
- If error occurred.
-
consumeArgument
public boolean consumeArgument()Description copied from interface:ArgumentAction
Returnstrue
if this action consumes argument. Otherwise returnsfalse
.- Specified by:
consumeArgument
in interfaceArgumentAction
- Returns:
true
orfalse
.
-
onAttach
Description copied from interface:ArgumentAction
Called when ArgumentAction is added toArgument
usingArgument.action(ArgumentAction)
.- Specified by:
onAttach
in interfaceArgumentAction
- Parameters:
arg
-Argument
object to which this object is added.
-