Class CommandLine

    • Constructor Detail

      • CommandLine

        protected CommandLine()
        Creates a command line.
    • Method Detail

      • hasOption

        public boolean hasOption​(Option opt)
        Query to see if an option has been set.
        Parameters:
        opt - the option to check.
        Returns:
        true if set, false if not.
        Since:
        1.5
      • hasOption

        public boolean hasOption​(String opt)
        Query to see if an option has been set.
        Parameters:
        opt - Short name of the option.
        Returns:
        true if set, false if not.
      • hasOption

        public boolean hasOption​(char opt)
        Query to see if an option has been set.
        Parameters:
        opt - character name of the option.
        Returns:
        true if set, false if not.
      • getOptionObject

        @Deprecated
        public Object getOptionObject​(String opt)
        Deprecated.
        due to System.err message. Instead use getParsedOptionValue(String)
        Return the Object type of this Option.
        Parameters:
        opt - the name of the option.
        Returns:
        the type of this Option.
      • getParsedOptionValue

        public Object getParsedOptionValue​(char opt)
                                    throws ParseException
        Return a version of this Option converted to a particular type.
        Parameters:
        opt - the name of the option.
        Returns:
        the value parsed into a particular object.
        Throws:
        ParseException - if there are problems turning the option value into the desired type
        Since:
        1.5
        See Also:
        PatternOptionBuilder
      • getOptionObject

        public Object getOptionObject​(char opt)
        Deprecated.
        due to System.err message. Instead use getParsedOptionValue(char)
        Return the Object type of this Option.
        Parameters:
        opt - the name of the option.
        Returns:
        the type of opt.
      • getOptionValue

        public String getOptionValue​(Option option)
        Retrieve the first argument, if any, of this option.
        Parameters:
        option - the name of the option.
        Returns:
        Value of the argument if option is set, and has an argument, otherwise null.
        Since:
        1.5
      • getOptionValue

        public String getOptionValue​(String opt)
        Retrieve the first argument, if any, of this option.
        Parameters:
        opt - the name of the option.
        Returns:
        Value of the argument if option is set, and has an argument, otherwise null.
      • getOptionValue

        public String getOptionValue​(char opt)
        Retrieve the first argument, if any, of this option.
        Parameters:
        opt - the character name of the option.
        Returns:
        Value of the argument if option is set, and has an argument, otherwise null.
      • getOptionValues

        public String[] getOptionValues​(Option option)
        Retrieves the array of values, if any, of an option.
        Parameters:
        option - string name of the option.
        Returns:
        Values of the argument if option is set, and has an argument, otherwise null.
        Since:
        1.5
      • getOptionValues

        public String[] getOptionValues​(String opt)
        Retrieves the array of values, if any, of an option.
        Parameters:
        opt - string name of the option.
        Returns:
        Values of the argument if option is set, and has an argument, otherwise null.
      • getOptionValues

        public String[] getOptionValues​(char opt)
        Retrieves the array of values, if any, of an option.
        Parameters:
        opt - character name of the option.
        Returns:
        Values of the argument if option is set, and has an argument, otherwise null.
      • getOptionValue

        public String getOptionValue​(Option option,
                                     String defaultValue)
        Retrieve the first argument, if any, of an option.
        Parameters:
        option - name of the option.
        defaultValue - is the default value to be returned if the option is not specified.
        Returns:
        Value of the argument if option is set, and has an argument, otherwise defaultValue.
        Since:
        1.5
      • getOptionValue

        public String getOptionValue​(String opt,
                                     String defaultValue)
        Retrieve the first argument, if any, of an option.
        Parameters:
        opt - name of the option.
        defaultValue - is the default value to be returned if the option is not specified.
        Returns:
        Value of the argument if option is set, and has an argument, otherwise defaultValue.
      • getOptionValue

        public String getOptionValue​(char opt,
                                     String defaultValue)
        Retrieve the argument, if any, of an option.
        Parameters:
        opt - character name of the option
        defaultValue - is the default value to be returned if the option is not specified.
        Returns:
        Value of the argument if option is set, and has an argument, otherwise defaultValue.
      • getOptionProperties

        public Properties getOptionProperties​(Option option)
        Retrieve the map of values associated to the option. This is convenient for options specifying Java properties like -Dparam1=value1 -Dparam2=value2. The first argument of the option is the key, and the 2nd argument is the value. If the option has only one argument (-Dfoo) it is considered as a boolean flag and the value is "true".
        Parameters:
        option - name of the option.
        Returns:
        The Properties mapped by the option, never null even if the option doesn't exists.
        Since:
        1.5
      • getOptionProperties

        public Properties getOptionProperties​(String opt)
        Retrieve the map of values associated to the option. This is convenient for options specifying Java properties like -Dparam1=value1 -Dparam2=value2. The first argument of the option is the key, and the 2nd argument is the value. If the option has only one argument (-Dfoo) it is considered as a boolean flag and the value is "true".
        Parameters:
        opt - name of the option.
        Returns:
        The Properties mapped by the option, never null even if the option doesn't exists.
        Since:
        1.2
      • getArgs

        public String[] getArgs()
        Retrieve any left-over non-recognized options and arguments
        Returns:
        remaining items passed in but not parsed as an array.
      • getArgList

        public List<StringgetArgList()
        Retrieve any left-over non-recognized options and arguments
        Returns:
        remaining items passed in but not parsed as a List.
      • addArg

        protected void addArg​(String arg)
        Add left-over unrecognized option/argument.
        Parameters:
        arg - the unrecognized option/argument.
      • addOption

        protected void addOption​(Option opt)
        Add an option to the command line. The values of the option are stored.
        Parameters:
        opt - the processed option.