Package Apache.CLI



Class DefaultParser.Builder

  • Enclosing class:
    DefaultParser

    public static final class DefaultParser.Builder
    extends java.lang.Object
    This Class-File has been copied, directly from the Apache Commons Software Foundation. Other than the minor, cosmetic changes (mentioned in the second-list below), this file is perfectly identical to the original that may be found on the Apache Website: apache.org.

    1. The suggested license for using this file may be read here: Apache License
    2. The Source-Code Header for this file may be viewed here: Source-File Header
    3. Partial contents of the 'site/resources/images' directory: Resource Images

    Notes about changes that have been made as a result of the import process:

    • Within all files, the original Package-Name declaration has been changed:
      Original:   package org.apache.commons.cli;
      Updated:   package Apache.CLI;

    • All Classes and Class-Members (Methods, Fields, etc...) that were previously Annotated with the @Deprecated Annotation have been summarily removed.

    • Code Formattings and Styling has been heavily modified to conform to the Standard Java-HTML Indentation & Styling Choices. The code itself remains identical, with only a few squiggly-braces '{' and '}' being removed, for cosmetic reasons (and for lowering "Developer Stress" Levels)..
    A nested builder class to create DefaultParser instances using descriptive methods.

    Example usage:

    Example:
     DefaultParser parser = Option
          .builder()
          .setAllowPartialMatching(false)
          .setStripLeadingAndTrailingQuotes(false)
          .build();
    


    • Method Summary

       
      Convert 'this 'Builder Instance into a 'DefaultParser' Instance
      Modifier and Type Method
      DefaultParser build()
      Builds an DefaultParser with the values declared by this DefaultParser.Builder.
       
      Configure this Builder's Build-Settings
      Modifier and Type Method
      DefaultParser.Builder setAllowPartialMatching​(boolean allowPartialMatching)
      Sets if partial matching of long options is supported.
      DefaultParser.Builder setStripLeadingAndTrailingQuotes​(Boolean stripLeadingAndTrailingQuotes)
      Sets if balanced leading and trailing double quotes should be stripped from option arguments.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setAllowPartialMatching

        🡅  🡇     🗕  🗗  🗖
        public DefaultParser.Builder setAllowPartialMatching​
                    (boolean allowPartialMatching)
        
        Sets if partial matching of long options is supported.

        By "partial matching" we mean that given the following code:

        Example:
         final Options options = new Options();
         
         options.addOption(new Option("d", "debug", false, "Turn on debug."));
         options.addOption(new Option("e", "extract", false, "Turn on extract."));
         options.addOption(new Option("o", "option", true, "Turn on option with argument."));
        

        If "partial matching" is turned on, -de only matches the "debug" option. However, with "partial matching" disabled, -de would enable both debug as well as extract
        Parameters:
        allowPartialMatching - whether to allow partial matching of long options
        Returns:
        this builder, to allow method
        Code:
        Exact Method Body:
         this.allowPartialMatching = allowPartialMatching;
         return this;
        
      • setStripLeadingAndTrailingQuotes

        🡅     🗕  🗗  🗖
        public DefaultParser.Builder setStripLeadingAndTrailingQuotes​
                    (java.lang.Boolean stripLeadingAndTrailingQuotes)
        
        Sets if balanced leading and trailing double quotes should be stripped from option arguments.

        If "stripping of balanced leading and trailing double quotes from option arguments" is true, the outermost balanced double quotes of option arguments values will be removed. For example, -o '"x"' getValue() will return x, instead of "x"

        If "stripping of balanced leading and trailing double quotes from option arguments" is null, then quotes will be stripped from option values separated by space from the option, but kept in other cases, which is the historic behavior.
        Parameters:
        stripLeadingAndTrailingQuotes - whether balanced leading and trailing double quotes should be stripped from option arguments.
        Returns:
        this builder, to allow method chaining
        Code:
        Exact Method Body:
         this.stripLeadingAndTrailingQuotes = stripLeadingAndTrailingQuotes;
         return this;