| java.lang.Object org.jargp.ArgumentProcessor
ArgumentProcessor | public class ArgumentProcessor (Code) | | Command line parameter processing handler. Organizes all the parameter
information, including the data object to which parameter values defined
by the command line are stored. Provides specialized processing for the
argument strings, including recognizing the '-' character at the start of
an argument as indicating that the argument provides control information
(flags and possibly embedded values) as opposed to data.
author: Dennis M. Sosnoski version: 1.0 |
ArgumentProcessor | public ArgumentProcessor(ParameterSet set)(Code) | | Constructor from parameter set definition.
Parameters: set - head parameter set in possible chain of sets defined |
ArgumentProcessor | public ArgumentProcessor(ParameterDef[] defs)(Code) | | Constructor from array of parameter definitions.
Parameters: set - head parameter set in possible chain of sets defined |
addValue | void addValue(Object value, Field field)(Code) | | Add parameter value to list. Uses reflection to retrieve the list object
and add a value to those present in the list.
Parameters: value - value to be added to list Parameters: field - target list field throws: IllegalArgumentException - on error in adding parameter value |
getArgs | public StringTracker getArgs()(Code) | | Get argument list information. The caller can comsume arguments
from the list as needed.
argument list information |
getChars | CharTracker getChars()(Code) | | Get current control argument character information. The caller can
consume characters from the current argument as needed.
argument string tracking information |
getIndex | int getIndex()(Code) | | Get current argument position in list.
offset in argument list of current flag argument |
listParameters | public void listParameters(int width, PrintStream print)(Code) | | List known parameter definitions. This lists all known parameter
definitions in fixed maximum width format.
Parameters: width - maximum number of columns in listing Parameters: print - print stream destination for listing definitions |
processArgs | public Object processArgs(String[] args, Object target)(Code) | | Process argument list control information. Processes control flags
present in the supplied argument list, setting the associated parameter
values. Arguments not consumed in the control flag processing are
available for access using other methods after the return from this
call.
Parameters: args - command line argument string array Parameters: target - application object defining parameter fields throws: ArgumentErrorException - on error in data throws: IllegalArgumentException - on error in processing |
processArgs | public static int processArgs(String[] args, ParameterDef[] parms, Object target)(Code) | | Process argument list directly. Creates and initializes an instance of
this class, then processes control flags present in the supplied argument
list, setting the associated parameter values in the target object.
Arguments not consumed in the control flag processing are available for
access using other methods after the return from this call.
Parameters: args - command line argument string array Parameters: parm - data object for parameter values Parameters: target - application object defining parameter fields index of first command line argument not consumed by processing throws: ArgumentErrorException - on error in data throws: IllegalArgumentException - on error in processing |
reportArgumentError | public void reportArgumentError(char flag, String text)(Code) | | Report argument error. Generates an exception with information about
the argument causing the problem.
Parameters: flag - argument flag character Parameters: text - error message text throws: ArgumentErrorException - reporting the error |
setValue | void setValue(Object value, Field field)(Code) | | Set parameter value. Uses reflection to set a value within the
target data object.
Parameters: value - value to be set for parameter Parameters: field - target field for parameter value throws: IllegalArgumentException - on error in setting parameter value |
|
|