Class AppendConstArgumentAction
- java.lang.Object
-
- net.sourceforge.argparse4j.impl.action.AppendConstArgumentAction
-
- All Implemented Interfaces:
ArgumentAction
public class AppendConstArgumentAction extends java.lang.Object implements 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 tonull.) The list is of typeList. This action is typically useful when multiple arguments need to store constants to the same list. Ifattrscontains non-List object for keyArgument.getDest(), it will be overwritten by the List containingvalue.consumeArgument()always returnsfalse.
-
-
Constructor Summary
Constructors Constructor Description AppendConstArgumentAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanconsumeArgument()Returnstrueif this action consumes argument.voidonAttach(Argument arg)Called when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).voidrun(ArgumentParser parser, Argument arg, java.util.Map<java.lang.String,java.lang.Object> attrs, java.lang.String flag, java.lang.Object value)Executes this action.
-
-
-
Method Detail
-
run
public void run(ArgumentParser parser, Argument arg, java.util.Map<java.lang.String,java.lang.Object> attrs, java.lang.String flag, java.lang.Object value) throws ArgumentParserException
Description copied from interface:ArgumentActionExecutes this action.
If the objects derived from
RuntimeExceptionare thrown in this method because of invalid input from command line, subclass must catch these exceptions and wrap them inArgumentParserExceptionand give simple error message to explain what happened briefly.- Specified by:
runin 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 ifargis an optional arguments.nullifargis 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:ArgumentActionReturnstrueif this action consumes argument. Otherwise returnsfalse.- Specified by:
consumeArgumentin interfaceArgumentAction- Returns:
trueorfalse.
-
onAttach
public void onAttach(Argument arg)
Description copied from interface:ArgumentActionCalled when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).- Specified by:
onAttachin interfaceArgumentAction- Parameters:
arg-Argumentobject to which this object is added.
-
-