Class CommandFormat

java.lang.Object
org.apache.hadoop.fs.shell.CommandFormat

public class CommandFormat extends Object
Parse the args of a command and check the format of args.
  • Constructor Details

    • CommandFormat

      @Deprecated public CommandFormat(String name, int min, int max, String... possibleOpt)
      Deprecated.
      use replacement since name is an unused parameter
      Parameters:
      name - of command, but never used
      min - see replacement
      max - see replacement
      possibleOpt - see replacement
      See Also:
    • CommandFormat

      public CommandFormat(int min, int max, String... possibleOpt)
      Simple parsing of command line arguments
      Parameters:
      min - minimum arguments required
      max - maximum arguments permitted
      possibleOpt - list of the allowed switches
  • Method Details

    • addOptionWithValue

      public void addOptionWithValue(String option)
      add option with value
      Parameters:
      option - option name
    • parse

      public List<String> parse(String[] args, int pos)
      Parse parameters starting from the given position Consider using the variant that directly takes a List
      Parameters:
      args - an array of input arguments
      pos - the position at which starts to parse
      Returns:
      a list of parameters
    • parse

      public void parse(List<String> args)
      Parse parameters from the given list of args. The list is destructively modified to remove the options.
      Parameters:
      args - as a list of input arguments
    • getOpt

      public boolean getOpt(String option)
      Return if the option is set or not
      Parameters:
      option - String representation of an option
      Returns:
      true is the option is set; false otherwise
    • getOptValue

      public String getOptValue(String option)
      get the option's value
      Parameters:
      option - option name
      Returns:
      option value if option exists, but no value assigned, return "" if option not exists, return null
    • getOpts

      public Set<String> getOpts()
      Returns all the options that are set
      Returns:
      Set<String> of the enabled options