@@ -153,21 +153,6 @@ public Builder setStripLeadingAndTrailingQuotes(final Boolean stripLeadingAndTra
153153 }
154154 }
155155
156- /**
157- * Creates a new {@link Builder} to create an {@link DefaultParser} using descriptive
158- * methods.
159- *
160- * @return a new {@link Builder} instance
161- * @since 1.5.0
162- */
163- public static Builder builder () {
164- return new Builder ();
165- }
166-
167- static int indexOfEqual (final String token ) {
168- return token .indexOf (Char .EQUAL );
169- }
170-
171156 /**
172157 * Enum representing possible actions that may be done when "non option" is discovered during parsing.
173158 *
@@ -194,6 +179,21 @@ public enum NonOptionAction {
194179 THROW ;
195180 }
196181
182+ /**
183+ * Creates a new {@link Builder} to create an {@link DefaultParser} using descriptive
184+ * methods.
185+ *
186+ * @return a new {@link Builder} instance
187+ * @since 1.5.0
188+ */
189+ public static Builder builder () {
190+ return new Builder ();
191+ }
192+
193+ static int indexOfEqual (final String token ) {
194+ return token .indexOf (Char .EQUAL );
195+ }
196+
197197 /** The command-line instance. */
198198 protected CommandLine cmd ;
199199
@@ -308,6 +308,16 @@ private DefaultParser(final boolean allowPartialMatching, final Boolean stripLea
308308 this .deprecatedHandler = deprecatedHandler ;
309309 }
310310
311+ /**
312+ * Adds token to command line {@link CommandLine#addArg(String)}.
313+ *
314+ * @param token the unrecognized option/argument.
315+ * @since 1.10.0
316+ */
317+ protected void addArg (final String token ) {
318+ cmd .addArg (token );
319+ }
320+
311321 /**
312322 * Throws a {@link MissingArgumentException} if the current option didn't receive the number of arguments expected.
313323 */
@@ -633,16 +643,6 @@ protected void handleUnknownToken(final String token) throws ParseException {
633643 }
634644 }
635645
636- /**
637- * Adds token to command line {@link CommandLine#addArg(String)}.
638- *
639- * @param token the unrecognized option/argument.
640- * @since 1.10.0
641- */
642- protected void addArg (final String token ) {
643- cmd .addArg (token );
644- }
645-
646646 /**
647647 * Tests if the token is a valid argument.
648648 *
@@ -726,6 +726,43 @@ private boolean isShortOption(final String token) {
726726 return !optName .isEmpty () && options .hasShortOption (String .valueOf (optName .charAt (0 )));
727727 }
728728
729+ /**
730+ * Parses the arguments according to the specified options and properties.
731+ *
732+ * @param options the specified Options
733+ * @param properties command line option name-value pairs
734+ * @param nonOptionAction see {@link NonOptionAction}.
735+ * @param arguments the command line arguments
736+ *
737+ * @return the list of atomic option and value tokens
738+ * @throws ParseException if there are any problems encountered while parsing the command line tokens.
739+ * @since 1.10.0
740+ */
741+ public CommandLine parse (final Options options , final Properties properties , final NonOptionAction nonOptionAction , final String ... arguments )
742+ throws ParseException {
743+ this .options = options ;
744+ this .nonOptionAction = nonOptionAction ;
745+ skipParsing = false ;
746+ currentOption = null ;
747+ expectedOpts = new ArrayList <>(options .getRequiredOptions ());
748+ // clear the data from the groups
749+ for (final OptionGroup group : options .getOptionGroups ()) {
750+ group .setSelected (null );
751+ }
752+ cmd = CommandLine .builder ().setDeprecatedHandler (deprecatedHandler ).get ();
753+ if (arguments != null ) {
754+ for (final String argument : arguments ) {
755+ handleToken (argument );
756+ }
757+ }
758+ // check the arguments of the last option
759+ checkRequiredArgs ();
760+ // add the default options
761+ handleProperties (properties );
762+ checkRequiredOptions ();
763+ return cmd ;
764+ }
765+
729766 @ Override
730767 public CommandLine parse (final Options options , final String [] arguments ) throws ParseException {
731768 return parse (options , arguments , null );
@@ -771,43 +808,6 @@ public CommandLine parse(final Options options, final String[] arguments, final
771808 return parse (options , properties , stopAtNonOption ? NonOptionAction .STOP : NonOptionAction .THROW , arguments );
772809 }
773810
774- /**
775- * Parses the arguments according to the specified options and properties.
776- *
777- * @param options the specified Options
778- * @param properties command line option name-value pairs
779- * @param nonOptionAction see {@link NonOptionAction}.
780- * @param arguments the command line arguments
781- *
782- * @return the list of atomic option and value tokens
783- * @throws ParseException if there are any problems encountered while parsing the command line tokens.
784- * @since 1.10.0
785- */
786- public CommandLine parse (final Options options , final Properties properties , final NonOptionAction nonOptionAction , final String ... arguments )
787- throws ParseException {
788- this .options = options ;
789- this .nonOptionAction = nonOptionAction ;
790- skipParsing = false ;
791- currentOption = null ;
792- expectedOpts = new ArrayList <>(options .getRequiredOptions ());
793- // clear the data from the groups
794- for (final OptionGroup group : options .getOptionGroups ()) {
795- group .setSelected (null );
796- }
797- cmd = CommandLine .builder ().setDeprecatedHandler (deprecatedHandler ).get ();
798- if (arguments != null ) {
799- for (final String argument : arguments ) {
800- handleToken (argument );
801- }
802- }
803- // check the arguments of the last option
804- checkRequiredArgs ();
805- // add the default options
806- handleProperties (properties );
807- checkRequiredOptions ();
808- return cmd ;
809- }
810-
811811 /**
812812 * Strips balanced leading and trailing quotes if the stripLeadingAndTrailingQuotes is set
813813 * If stripLeadingAndTrailingQuotes is null, then do not strip
0 commit comments