Skip to content

Commit ff2af01

Browse files
committed
Javadoc and comment
1 parent 48460cf commit ff2af01

1 file changed

Lines changed: 36 additions & 35 deletions

File tree

src/main/java/org/apache/commons/cli/DefaultParser.java

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private Builder() {
7474
/**
7575
* Builds an DefaultParser with the values declared by this {@link Builder}.
7676
*
77-
* @return the new {@link DefaultParser}
77+
* @return the new {@link DefaultParser}.
7878
* @since 1.5.0
7979
* @deprecated Use {@link #get()}.
8080
*/
@@ -86,7 +86,7 @@ public DefaultParser build() {
8686
/**
8787
* Builds an DefaultParser with the values declared by this {@link Builder}.
8888
*
89-
* @return the new {@link DefaultParser}
89+
* @return the new {@link DefaultParser}.
9090
* @since 1.10.0
9191
*/
9292
@Override
@@ -112,8 +112,8 @@ public DefaultParser get() {
112112
* If "partial matching" is turned on, {@code -de} only matches the {@code "debug"} option. However, with
113113
* "partial matching" disabled, {@code -de} would enable both {@code debug} as well as {@code extract}
114114
*
115-
* @param allowPartialMatching whether to allow partial matching of long options
116-
* @return this builder, to allow method chaining
115+
* @param allowPartialMatching whether to allow partial matching of long options.
116+
* @return {@code this} instance..
117117
* @since 1.5.0
118118
*/
119119
public Builder setAllowPartialMatching(final boolean allowPartialMatching) {
@@ -145,7 +145,7 @@ public Builder setDeprecatedHandler(final Consumer<Option> deprecatedHandler) {
145145
* kept in other cases, which is the historic behavior.
146146
*
147147
* @param stripLeadingAndTrailingQuotes whether balanced leading and trailing double quotes should be stripped from option arguments.
148-
* @return this builder, to allow method chaining
148+
* @return {@code this} instance.
149149
* @since 1.5.0
150150
*/
151151
public Builder setStripLeadingAndTrailingQuotes(final Boolean stripLeadingAndTrailingQuotes) {
@@ -344,7 +344,7 @@ protected void checkRequiredOptions() throws MissingOptionException {
344344
}
345345

346346
/**
347-
* Searches for a prefix that is the long name of an option (-Xmx512m)
347+
* Searches for a prefix that is the long name of an option (-Xmx512m).
348348
*
349349
* @param token
350350
*/
@@ -365,8 +365,8 @@ private String getLongPrefix(final String token) {
365365
/**
366366
* Gets a list of matching option strings for the given token, depending on the selected partial matching policy.
367367
*
368-
* @param token the token (may contain leading dashes)
369-
* @return the list of matching option strings or an empty list if no matching option could be found
368+
* @param token the token (may contain leading dashes).
369+
* @return the list of matching option strings or an empty list if no matching option could be found.
370370
*/
371371
private List<String> getMatchingLongOptions(final String token) {
372372
if (allowPartialMatching) {
@@ -417,10 +417,11 @@ protected void handleConcatenatedOptions(final String token) throws ParseExcepti
417417

418418
/**
419419
* Handles the following tokens:
420-
*
420+
* <pre>
421421
* --L --L=V --L V --l
422+
* </pre>
422423
*
423-
* @param token the command line token to handle
424+
* @param token the command line token to handle.
424425
*/
425426
private void handleLongOption(final String token) throws ParseException {
426427
if (indexOfEqual(token) == -1) {
@@ -432,10 +433,11 @@ private void handleLongOption(final String token) throws ParseException {
432433

433434
/**
434435
* Handles the following tokens:
435-
*
436+
* <pre>
436437
* --L=V -L=V --l=V -l=V
438+
* </pre>
437439
*
438-
* @param token the command line token to handle
440+
* @param token the command line token to handle.
439441
*/
440442
private void handleLongOptionWithEqual(final String token) throws ParseException {
441443
final int pos = indexOfEqual(token);
@@ -462,9 +464,11 @@ private void handleLongOptionWithEqual(final String token) throws ParseException
462464
/**
463465
* Handles the following tokens:
464466
*
467+
* <pre>
465468
* --L -L --l -l
469+
* </pre>
466470
*
467-
* @param token the command line token to handle
471+
* @param token the command line token to handle.
468472
*/
469473
private void handleLongOptionWithoutEqual(final String token) throws ParseException {
470474
final List<String> matchingOpts = getMatchingLongOptions(token);
@@ -525,12 +529,13 @@ private void handleProperties(final Properties properties) throws ParseException
525529

526530
/**
527531
* Handles the following tokens:
528-
*
532+
* <pre>
529533
* -S -SV -S V -S=V -S1S2 -S1S2 V -SV1=V2
530534
*
531535
* -L -LV -L V -L=V -l
536+
* </pre>
532537
*
533-
* @param hyphenToken the command line token to handle
538+
* @param hyphenToken the command line token to handle.
534539
*/
535540
private void handleShortAndLongOption(final String hyphenToken) throws ParseException {
536541
final String token = Util.stripLeadingHyphens(hyphenToken);
@@ -598,7 +603,7 @@ private void handleShortAndLongOption(final String hyphenToken) throws ParseExce
598603
/**
599604
* Handles any command line token.
600605
*
601-
* @param token the command line token to handle
606+
* @param token the command line token to handle.
602607
* @throws ParseException
603608
*/
604609
private void handleToken(final String token) throws ParseException {
@@ -628,8 +633,8 @@ private void handleToken(final String token) throws ParseException {
628633
* token is added to the arguments of the command line. If the stopAtNonOption flag is set, this stops the parsing and
629634
* the remaining tokens are added as-is in the arguments of the command line.
630635
*
631-
* @param token the command line token to handle
632-
* @throws ParseException if parsing should fail
636+
* @param token the command line token to handle.
637+
* @throws ParseException if parsing should fail.
633638
* @since 1.10.0
634639
*/
635640
protected void handleUnknownToken(final String token) throws ParseException {
@@ -735,7 +740,7 @@ private boolean isShortOption(final String token) {
735740
* @param nonOptionAction see {@link NonOptionAction}.
736741
* @param arguments the command line arguments
737742
*
738-
* @return the list of atomic option and value tokens
743+
* @return the list of atomic option and value tokens.
739744
* @throws ParseException if there are any problems encountered while parsing the command line tokens.
740745
* @since 1.10.0
741746
*/
@@ -780,10 +785,10 @@ public CommandLine parse(final Options options, final String[] arguments, final
780785
/**
781786
* Parses the arguments according to the specified options and properties.
782787
*
783-
* @param options the specified Options
784-
* @param arguments the command line arguments
785-
* @param properties command line option name-value pairs
786-
* @return the list of atomic option and value tokens
788+
* @param options the specified Options.
789+
* @param arguments the command line arguments.
790+
* @param properties command line option name-value pairs.
791+
* @return the list of atomic option and value tokens.
787792
* @throws ParseException if there are any problems encountered while parsing the command line tokens.
788793
*/
789794
public CommandLine parse(final Options options, final String[] arguments, final Properties properties) throws ParseException {
@@ -793,14 +798,13 @@ public CommandLine parse(final Options options, final String[] arguments, final
793798
/**
794799
* Parses the arguments according to the specified options and properties.
795800
*
796-
* @param options the specified Options
797-
* @param arguments the command line arguments
798-
* @param properties command line option name-value pairs
801+
* @param options the specified Options.
802+
* @param arguments the command line arguments.
803+
* @param properties command line option name-value pairs.
799804
* @param stopAtNonOption if {@code true} an unrecognized argument stops the parsing and the remaining arguments
800805
* are added to the {@link CommandLine}s args list. If {@code false} an unrecognized argument triggers a
801806
* ParseException.
802-
*
803-
* @return the list of atomic option and value tokens
807+
* @return the list of atomic option and value tokens.
804808
* @throws ParseException if there are any problems encountered while parsing the command line tokens.
805809
* @see #parse(Options, Properties, NonOptionAction, String[])
806810
*/
@@ -813,8 +817,8 @@ public CommandLine parse(final Options options, final String[] arguments, final
813817
* Strips balanced leading and trailing quotes if the stripLeadingAndTrailingQuotes is set
814818
* If stripLeadingAndTrailingQuotes is null, then do not strip
815819
*
816-
* @param token a string
817-
* @return token with the quotes stripped (if set)
820+
* @param token a string.
821+
* @return token with the quotes stripped (if set).
818822
*/
819823
private String stripLeadingAndTrailingQuotesDefaultOff(final String token) {
820824
if (stripLeadingAndTrailingQuotes != null && stripLeadingAndTrailingQuotes) {
@@ -827,8 +831,8 @@ private String stripLeadingAndTrailingQuotesDefaultOff(final String token) {
827831
* Strips balanced leading and trailing quotes if the stripLeadingAndTrailingQuotes is set
828832
* If stripLeadingAndTrailingQuotes is null, then do not strip
829833
*
830-
* @param token a string
831-
* @return token with the quotes stripped (if set)
834+
* @param token a string.
835+
* @return token with the quotes stripped (if set).
832836
*/
833837
private String stripLeadingAndTrailingQuotesDefaultOn(final String token) {
834838
if (stripLeadingAndTrailingQuotes == null || stripLeadingAndTrailingQuotes) {
@@ -846,15 +850,12 @@ private void updateRequiredOptions(final Option option) throws AlreadySelectedEx
846850
if (option.isRequired()) {
847851
expectedOpts.remove(option.getKey());
848852
}
849-
850853
// if the option is in an OptionGroup make that option the selected option of the group
851854
if (options.getOptionGroup(option) != null) {
852855
final OptionGroup group = options.getOptionGroup(option);
853-
854856
if (group.isRequired()) {
855857
expectedOpts.remove(group);
856858
}
857-
858859
group.setSelected(option);
859860
}
860861
}

0 commit comments

Comments
 (0)