Class OptionBuilder

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int argCount
      Deprecated.
      The number of arguments
      private static java.lang.String argName
      Deprecated.
      Argument name
      private static java.lang.String description
      Deprecated.
      Option description
      private static OptionBuilder INSTANCE
      Deprecated.
      Option builder instance
      private static java.lang.String longOption
      Deprecated.
      Long option
      private static boolean optionalArg
      Deprecated.
      Option can have an optional argument value
      private static boolean required
      Deprecated.
      Is required?
      private static java.lang.Class<?> type
      Deprecated.
      Option type
      private static char valueSeparator
      Deprecated.
      Value separator for argument value
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private OptionBuilder()
      Deprecated.
      private constructor to prevent instances being created
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static Option create()
      Deprecated.
      Creates an Option using the current settings
      static Option create​(char opt)
      Deprecated.
      Creates an Option using the current settings and with the specified Option char.
      static Option create​(java.lang.String opt)
      Deprecated.
      Creates an Option using the current settings and with the specified Option char.
      static OptionBuilder hasArg()
      Deprecated.
      The next Option created will require an argument value.
      static OptionBuilder hasArg​(boolean hasArg)
      Deprecated.
      The next Option created will require an argument value if hasArg is true.
      static OptionBuilder hasArgs()
      Deprecated.
      The next Option created can have unlimited argument values.
      static OptionBuilder hasArgs​(int num)
      Deprecated.
      The next Option created can have num argument values.
      static OptionBuilder hasOptionalArg()
      Deprecated.
      The next Option can have an optional argument.
      static OptionBuilder hasOptionalArgs()
      Deprecated.
      The next Option can have an unlimited number of optional arguments.
      static OptionBuilder hasOptionalArgs​(int numArgs)
      Deprecated.
      The next Option can have the specified number of optional arguments.
      static OptionBuilder isRequired()
      Deprecated.
      The next Option created will be required.
      static OptionBuilder isRequired​(boolean newRequired)
      Deprecated.
      The next Option created will be required if required is true.
      private static void reset()
      Deprecated.
      Resets the member variables to their default values.
      static OptionBuilder withArgName​(java.lang.String name)
      Deprecated.
      The next Option created will have the specified argument value name.
      static OptionBuilder withDescription​(java.lang.String newDescription)
      Deprecated.
      The next Option created will have the specified description
      static OptionBuilder withLongOpt​(java.lang.String newLongopt)
      Deprecated.
      The next Option created will have the following long option value.
      static OptionBuilder withType​(java.lang.Class<?> newType)
      Deprecated.
      The next Option created will have a value that will be an instance of type.
      static OptionBuilder withType​(java.lang.Object newType)
      Deprecated.
      since 1.3, use withType(Class) instead
      static OptionBuilder withValueSeparator()
      Deprecated.
      The next Option created uses '=' as a means to separate argument values.
      static OptionBuilder withValueSeparator​(char sep)
      Deprecated.
      The next Option created uses sep as a means to separate argument values.
      • Methods inherited from class java.lang.Object

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

      • longOption

        private static java.lang.String longOption
        Deprecated.
        Long option
      • description

        private static java.lang.String description
        Deprecated.
        Option description
      • argName

        private static java.lang.String argName
        Deprecated.
        Argument name
      • required

        private static boolean required
        Deprecated.
        Is required?
      • argCount

        private static int argCount
        Deprecated.
        The number of arguments
      • type

        private static java.lang.Class<?> type
        Deprecated.
        Option type
      • optionalArg

        private static boolean optionalArg
        Deprecated.
        Option can have an optional argument value
      • valueSeparator

        private static char valueSeparator
        Deprecated.
        Value separator for argument value
      • INSTANCE

        private static final OptionBuilder INSTANCE
        Deprecated.
        Option builder instance
    • Constructor Detail

      • OptionBuilder

        private OptionBuilder()
        Deprecated.
        private constructor to prevent instances being created
    • Method Detail

      • create

        public static Option create()
                             throws java.lang.IllegalArgumentException
        Deprecated.
        Creates an Option using the current settings
        Returns:
        the Option instance
        Throws:
        java.lang.IllegalArgumentException - if longOpt has not been set.
      • create

        public static Option create​(char opt)
                             throws java.lang.IllegalArgumentException
        Deprecated.
        Creates an Option using the current settings and with the specified Option char.
        Parameters:
        opt - the character representation of the Option
        Returns:
        the Option instance
        Throws:
        java.lang.IllegalArgumentException - if opt is not a valid character. See Option.
      • create

        public static Option create​(java.lang.String opt)
                             throws java.lang.IllegalArgumentException
        Deprecated.
        Creates an Option using the current settings and with the specified Option char.
        Parameters:
        opt - the java.lang.String representation of the Option
        Returns:
        the Option instance
        Throws:
        java.lang.IllegalArgumentException - if opt is not a valid character. See Option.
      • hasArg

        public static OptionBuilder hasArg()
        Deprecated.
        The next Option created will require an argument value.
        Returns:
        the OptionBuilder instance
      • hasArg

        public static OptionBuilder hasArg​(boolean hasArg)
        Deprecated.
        The next Option created will require an argument value if hasArg is true.
        Parameters:
        hasArg - if true then the Option has an argument value
        Returns:
        the OptionBuilder instance
      • hasArgs

        public static OptionBuilder hasArgs()
        Deprecated.
        The next Option created can have unlimited argument values.
        Returns:
        the OptionBuilder instance
      • hasArgs

        public static OptionBuilder hasArgs​(int num)
        Deprecated.
        The next Option created can have num argument values.
        Parameters:
        num - the number of args that the option can have
        Returns:
        the OptionBuilder instance
      • hasOptionalArg

        public static OptionBuilder hasOptionalArg()
        Deprecated.
        The next Option can have an optional argument.
        Returns:
        the OptionBuilder instance
      • hasOptionalArgs

        public static OptionBuilder hasOptionalArgs()
        Deprecated.
        The next Option can have an unlimited number of optional arguments.
        Returns:
        the OptionBuilder instance
      • hasOptionalArgs

        public static OptionBuilder hasOptionalArgs​(int numArgs)
        Deprecated.
        The next Option can have the specified number of optional arguments.
        Parameters:
        numArgs - - the maximum number of optional arguments the next Option created can have.
        Returns:
        the OptionBuilder instance
      • isRequired

        public static OptionBuilder isRequired()
        Deprecated.
        The next Option created will be required.
        Returns:
        the OptionBuilder instance
      • isRequired

        public static OptionBuilder isRequired​(boolean newRequired)
        Deprecated.
        The next Option created will be required if required is true.
        Parameters:
        newRequired - if true then the Option is required
        Returns:
        the OptionBuilder instance
      • reset

        private static void reset()
        Deprecated.
        Resets the member variables to their default values.
      • withArgName

        public static OptionBuilder withArgName​(java.lang.String name)
        Deprecated.
        The next Option created will have the specified argument value name.
        Parameters:
        name - the name for the argument value
        Returns:
        the OptionBuilder instance
      • withDescription

        public static OptionBuilder withDescription​(java.lang.String newDescription)
        Deprecated.
        The next Option created will have the specified description
        Parameters:
        newDescription - a description of the Option's purpose
        Returns:
        the OptionBuilder instance
      • withLongOpt

        public static OptionBuilder withLongOpt​(java.lang.String newLongopt)
        Deprecated.
        The next Option created will have the following long option value.
        Parameters:
        newLongopt - the long option value
        Returns:
        the OptionBuilder instance
      • withType

        public static OptionBuilder withType​(java.lang.Class<?> newType)
        Deprecated.
        The next Option created will have a value that will be an instance of type.
        Parameters:
        newType - the type of the Options argument value
        Returns:
        the OptionBuilder instance
        Since:
        1.3
      • withType

        @Deprecated
        public static OptionBuilder withType​(java.lang.Object newType)
        Deprecated.
        since 1.3, use withType(Class) instead
        The next Option created will have a value that will be an instance of type.

        Note: this method is kept for binary compatibility and the input type is supposed to be a Class object.

        Parameters:
        newType - the type of the Options argument value
        Returns:
        the OptionBuilder instance
      • withValueSeparator

        public static OptionBuilder withValueSeparator()
        Deprecated.
        The next Option created uses '=' as a means to separate argument values. Example:
         Option opt = OptionBuilder.withValueSeparator().create('D');
        
         CommandLine line = parser.parse(args);
         String propertyName = opt.getValue(0);
         String propertyValue = opt.getValue(1);
         
        Returns:
        the OptionBuilder instance
      • withValueSeparator

        public static OptionBuilder withValueSeparator​(char sep)
        Deprecated.
        The next Option created uses sep as a means to separate argument values.

        Example:

         Option opt = OptionBuilder.withValueSeparator('=').create('D');
        
         String args = "-Dkey=value";
         CommandLine line = parser.parse(args);
         String propertyName = opt.getValue(0); // will be "key"
         String propertyValue = opt.getValue(1); // will be "value"
         
        Parameters:
        sep - The value separator to be used for the argument values.
        Returns:
        the OptionBuilder instance