Class Options.FlagOptionDef

java.lang.Object
com.portal.common.Options.OptionDef
com.portal.common.Options.FlagOptionDef
Enclosing class:
Options

protected class Options.FlagOptionDef extends Options.OptionDef
Definition of a flag option. This is an option that will be true if it appears on the command line and false if it does not appear on the command line.
  • Constructor Details

    • FlagOptionDef

      public FlagOptionDef(String name, String desc)
      Construct a flag option. This is an option that will be true if it appears on the command line and false if it does not appear on the command line.

      Parameters:
      name - The name of the option. The name should include the leading "-" (i.e. "-verbose").
      desc - The description of the option.
  • Method Details

    • validateOption

      public void validateOption(ArrayList values) throws CommandLineParser.OptionDataException
      Ensure that the option does not have any values. The appearance of the option on the command line implies a value of true.

      Overrides:
      validateOption in class Options.OptionDef
      Parameters:
      values - An array that contains the values that were specified on the command line for the option. If no values were specified then the array will be empty.
      Throws:
      CommandLineParser.OptionDataException - One or more values followed this option.
    • getString

      public String getString(String[] values, int i) throws CommandLineParser.OptionDataException
      Return the ith value for the option as a boolean. For a FlagOption this method only makes senses for an index of zero.

      Overrides:
      getString in class Options.OptionDef
      Parameters:
      values - The array of values retrieved from the command line for the option.
      i - The index of the value to return. The index is zero relative (i.e. a value of zero implies the first value). This method only makes senses for an index of zero.
      Returns:
      If the index is zero, true will be returned if the option exist (otherwise false). If the index is not zero then an OptionDataException will be thrown.
      Throws:
      CommandLineParser.OptionDataException - The value for i is not zero.