protected void parseParameter ( String parameter , CliParserState parserState , CliParameterConsumer parameterConsumer ) { if ( parserState . isOptionsComplete ( ) ) { // no more options (e.g. --foo), only arguments from here List < CliArgumentContainer > argumentList = this . cliState . getArguments ( parserState . requireCurrentMode ( this . cliState ) ) ; int argumentIndex = parserState . getArgumentIndex ( ) ; if ( argumentIndex >= argumentList . size ( ) ) { throw new NlsIllegalArgumentException ( parameter ) ; } else { parseArgument ( parserState , parameter , argumentList . get ( argumentIndex ) , parameterConsumer ) ; } } else { CliOptionContainer optionContainer = this . cliState . getOption ( parameter ) ; if ( optionContainer == null ) { // no option found for argument... parseParameterUndefinedOption ( parameter , parserState , parameterConsumer ) ; } else { // mode handling... String modeId = optionContainer . getOption ( ) . mode ( ) ; CliModeObject newMode = this . cliState . getMode ( modeId ) ; if ( newMode == null ) { // should never happen! newMode = new CliModeContainer ( modeId ) ; } if ( parserState . currentMode == null ) { parserState . setCurrentMode ( parameter , newMode ) ; } else if ( ! modeId . equals ( parserState . currentMode . getId ( ) ) ) { // mode already detected, but mode of current option differs... if ( newMode . isDescendantOf ( parserState . currentMode ) ) { // new mode extends current mode parserState . setCurrentMode ( parameter , newMode ) ; } else if ( ! newMode . isAncestorOf ( parserState . currentMode ) ) { // current mode does NOT extend new mode and vice versa // --> incompatible modes throw new CliOptionIncompatibleModesException ( parserState . modeOption , parameter ) ; } } parseOption ( parserState , parameter , optionContainer , parameterConsumer ) ; } } }
This method parses a single command - line argument .