test_class.file: herd-code/herd-core/src/test/java/org/finra/herd/core/ArgumentParserTest.java
test_class.identifier: ArgumentParserTest
test_class.superclass: extends AbstractCoreTest
test_case.body: @Test
      public void testGetStringValueAsBoolean() throws ParseException
      {
          ArgumentParser argParser = new ArgumentParser("");
          Option strOpt = argParser.addArgument("s", "str", true, "Some string input parameter to have a boolean value", false);
  
          final String shortStrOpt = String.format("-%s", strOpt.getOpt());
          final String longStrOpt = String.format("--%s", strOpt.getLongOpt());
  
          // Validate the default value - no option is specified.
          argParser.parseArguments(new String[] {});
          assertFalse(argParser.getStringValueAsBoolean(strOpt, false));
          assertTrue(argParser.getStringValueAsBoolean(strOpt, true));
  
          // Validate all "true" boolean values using both short an long options.
          for (String inputValue : Arrays
              .asList(CustomBooleanEditor.VALUE_TRUE, CustomBooleanEditor.VALUE_YES, CustomBooleanEditor.VALUE_ON, CustomBooleanEditor.VALUE_1))
          {
              argParser.parseArguments(new String[] {shortStrOpt, inputValue});
              assertTrue(argParser.getStringValueAsBoolean(strOpt, false));
              argParser.parseArguments(new String[] {longStrOpt, inputValue});
              assertTrue(argParser.getStringValueAsBoolean(strOpt, false));
          }
  
          // Validate all "false" boolean values.
          for (String inputValue : Arrays
              .asList(CustomBooleanEditor.VALUE_FALSE, CustomBooleanEditor.VALUE_NO, CustomBooleanEditor.VALUE_OFF, CustomBooleanEditor.VALUE_0))
          {
              argParser.parseArguments(new String[] {shortStrOpt, inputValue});
              assertFalse(argParser.getStringValueAsBoolean(strOpt, true));
          }
  
          // Try to parse an invalid boolean value.
          argParser.parseArguments(new String[] {shortStrOpt, INVALID_BOOLEAN_VALUE});
          try
          {
              argParser.getStringValueAsBoolean(strOpt, false);
              fail("Suppose to throw a ParseException when option has an invalid boolean value.");
          }
          catch (ParseException e)
          {
              assertEquals(String.format("Invalid boolean value [%s]", INVALID_BOOLEAN_VALUE), e.getMessage());
          }
      }
test_case.class_method_signature: ArgumentParserTest.testGetStringValueAsBoolean()
test_case.full_signature: @Test public void testGetStringValueAsBoolean()
test_case.identifier: testGetStringValueAsBoolean
test_case.invocations: addArgument format getOpt format getLongOpt parseArguments assertFalse getStringValueAsBoolean assertTrue getStringValueAsBoolean asList parseArguments assertTrue getStringValueAsBoolean parseArguments assertTrue getStringValueAsBoolean asList parseArguments assertFalse getStringValueAsBoolean parseArguments getStringValueAsBoolean fail assertEquals format getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetStringValueAsBoolean()
focal_class.declarator: applicationName
focal_class.modifier: protected
focal_class.original_string: protected String applicationName;
focal_class.type: String
focal_class.var_name: applicationName
focal_class.declarator: options
focal_class.modifier: protected
focal_class.original_string: protected Options options;
focal_class.type: Options
focal_class.var_name: options
focal_class.declarator: optionsIgnoreRequired
focal_class.modifier: protected
focal_class.original_string: protected Options optionsIgnoreRequired;
focal_class.type: Options
focal_class.var_name: optionsIgnoreRequired
focal_class.declarator: commandLine
focal_class.modifier: protected
focal_class.original_string: protected CommandLine commandLine;
focal_class.type: CommandLine
focal_class.var_name: commandLine
focal_class.file: herd-code/herd-core/src/main/java/org/finra/herd/core/ArgumentParser.java
focal_class.identifier: ArgumentParser
focal_class.class_method_signature: ArgumentParser.ArgumentParser(String applicationName)
focal_class.full_signature: public  ArgumentParser(String applicationName)
focal_class.identifier: ArgumentParser
focal_class.modifiers: public
focal_class.parameters: (String applicationName)
focal_class.signature:  ArgumentParser(String applicationName)
focal_class.class_method_signature: ArgumentParser.getApplicationName()
focal_class.full_signature: public String getApplicationName()
focal_class.identifier: getApplicationName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getApplicationName()
focal_class.class_method_signature: ArgumentParser.addArgument(Option option, boolean required)
focal_class.full_signature: public Option addArgument(Option option, boolean required)
focal_class.identifier: addArgument
focal_class.modifiers: public
focal_class.parameters: (Option option, boolean required)
focal_class.return: Option
focal_class.signature: Option addArgument(Option option, boolean required)
focal_class.class_method_signature: ArgumentParser.addArgument(String opt, String longOpt, boolean hasArg, String description, boolean required)
focal_class.full_signature: public Option addArgument(String opt, String longOpt, boolean hasArg, String description, boolean required)
focal_class.identifier: addArgument
focal_class.modifiers: public
focal_class.parameters: (String opt, String longOpt, boolean hasArg, String description, boolean required)
focal_class.return: Option
focal_class.signature: Option addArgument(String opt, String longOpt, boolean hasArg, String description, boolean required)
focal_class.class_method_signature: ArgumentParser.getConfiguredOptions()
focal_class.full_signature: public Collection getConfiguredOptions()
focal_class.identifier: getConfiguredOptions
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Collection
focal_class.signature: Collection getConfiguredOptions()
focal_class.class_method_signature: ArgumentParser.parseArguments(String[] args, boolean failOnMissingRequiredOptions)
focal_class.full_signature: public void parseArguments(String[] args, boolean failOnMissingRequiredOptions)
focal_class.identifier: parseArguments
focal_class.modifiers: public
focal_class.parameters: (String[] args, boolean failOnMissingRequiredOptions)
focal_class.return: void
focal_class.signature: void parseArguments(String[] args, boolean failOnMissingRequiredOptions)
focal_class.class_method_signature: ArgumentParser.parseArguments(String[] args)
focal_class.full_signature: public void parseArguments(String[] args)
focal_class.identifier: parseArguments
focal_class.modifiers: public
focal_class.parameters: (String[] args)
focal_class.return: void
focal_class.signature: void parseArguments(String[] args)
focal_class.class_method_signature: ArgumentParser.getUsageInformation()
focal_class.full_signature: public String getUsageInformation()
focal_class.identifier: getUsageInformation
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getUsageInformation()
focal_class.class_method_signature: ArgumentParser.getBooleanValue(Option option)
focal_class.full_signature: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public Boolean getBooleanValue(Option option)
focal_class.identifier: getBooleanValue
focal_class.modifiers: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public
focal_class.parameters: (Option option)
focal_class.return: Boolean
focal_class.signature: Boolean getBooleanValue(Option option)
focal_class.class_method_signature: ArgumentParser.getStringValueAsBoolean(Option option, Boolean defaultValue)
focal_class.full_signature: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public Boolean getStringValueAsBoolean(Option option, Boolean defaultValue)
focal_class.identifier: getStringValueAsBoolean
focal_class.modifiers: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public
focal_class.parameters: (Option option, Boolean defaultValue)
focal_class.return: Boolean
focal_class.signature: Boolean getStringValueAsBoolean(Option option, Boolean defaultValue)
focal_class.class_method_signature: ArgumentParser.getStringValue(Option option)
focal_class.full_signature: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public String getStringValue(Option option)
focal_class.identifier: getStringValue
focal_class.modifiers: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public
focal_class.parameters: (Option option)
focal_class.return: String
focal_class.signature: String getStringValue(Option option)
focal_class.class_method_signature: ArgumentParser.ensureCommandLineNotNull()
focal_class.full_signature: private void ensureCommandLineNotNull()
focal_class.identifier: ensureCommandLineNotNull
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void ensureCommandLineNotNull()
focal_class.class_method_signature: ArgumentParser.getStringValue(Option option, String defaultValue)
focal_class.full_signature: public String getStringValue(Option option, String defaultValue)
focal_class.identifier: getStringValue
focal_class.modifiers: public
focal_class.parameters: (Option option, String defaultValue)
focal_class.return: String
focal_class.signature: String getStringValue(Option option, String defaultValue)
focal_class.class_method_signature: ArgumentParser.getIntegerValue(Option option)
focal_class.full_signature: public Integer getIntegerValue(Option option)
focal_class.identifier: getIntegerValue
focal_class.modifiers: public
focal_class.parameters: (Option option)
focal_class.return: Integer
focal_class.signature: Integer getIntegerValue(Option option)
focal_class.class_method_signature: ArgumentParser.getIntegerValue(Option option, Integer defaultValue)
focal_class.full_signature: public Integer getIntegerValue(Option option, Integer defaultValue)
focal_class.identifier: getIntegerValue
focal_class.modifiers: public
focal_class.parameters: (Option option, Integer defaultValue)
focal_class.return: Integer
focal_class.signature: Integer getIntegerValue(Option option, Integer defaultValue)
focal_class.class_method_signature: ArgumentParser.getIntegerValue(Option option, Integer defaultValue, Integer minValue, Integer maxValue)
focal_class.full_signature: public Integer getIntegerValue(Option option, Integer defaultValue, Integer minValue, Integer maxValue)
focal_class.identifier: getIntegerValue
focal_class.modifiers: public
focal_class.parameters: (Option option, Integer defaultValue, Integer minValue, Integer maxValue)
focal_class.return: Integer
focal_class.signature: Integer getIntegerValue(Option option, Integer defaultValue, Integer minValue, Integer maxValue)
focal_class.class_method_signature: ArgumentParser.getFileValue(Option option)
focal_class.full_signature: public File getFileValue(Option option)
focal_class.identifier: getFileValue
focal_class.modifiers: public
focal_class.parameters: (Option option)
focal_class.return: File
focal_class.signature: File getFileValue(Option option)
focal_class.class_method_signature: ArgumentParser.getFileValue(Option option, File defaultValue)
focal_class.full_signature: public File getFileValue(Option option, File defaultValue)
focal_class.identifier: getFileValue
focal_class.modifiers: public
focal_class.parameters: (Option option, File defaultValue)
focal_class.return: File
focal_class.signature: File getFileValue(Option option, File defaultValue)
focal_method.body: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.")
      public Boolean getStringValueAsBoolean(Option option, Boolean defaultValue) throws ParseException
      {
          Boolean result;
  
          ensureCommandLineNotNull();
          String stringValue = getStringValue(option);
  
          if (StringUtils.isNotBlank(stringValue))
          {
              // Use custom boolean editor without allowed empty strings to convert the value of the argument to a boolean value.
              CustomBooleanEditor customBooleanEditor = new CustomBooleanEditor(false);
              try
              {
                  customBooleanEditor.setAsText(stringValue);
              }
              catch (IllegalArgumentException e)
              {
                  ParseException parseException = new ParseException(e.getMessage());
                  parseException.initCause(e);
                  throw parseException;
              }
              result = (Boolean) customBooleanEditor.getValue();
          }
          else
          {
              result = defaultValue;
          }
  
          return result;
      }
focal_method.class_method_signature: ArgumentParser.getStringValueAsBoolean(Option option, Boolean defaultValue)
focal_method.full_signature: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public Boolean getStringValueAsBoolean(Option option, Boolean defaultValue)
focal_method.identifier: getStringValueAsBoolean
focal_method.invocations: ensureCommandLineNotNull getStringValue isNotBlank setAsText getMessage initCause getValue
focal_method.modifiers: @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public
focal_method.parameters: (Option option, Boolean defaultValue)
focal_method.return: Boolean
focal_method.signature: Boolean getStringValueAsBoolean(Option option, Boolean defaultValue)