private String incorrectDataTypeMessage(ArrayList<String> argList) {
    String errorMessage = this.usageMessage();

    if (incorrectArgumentType.equals("positional")) {
      PositionalArgument currentArg = positionalArgumentList.get(incorrectDataTypeIndex);
      errorMessage +=
          "\n"
              + programName
              + ".java: error: argument "
              + currentArg.getName()
              + ": invalid "
              + currentArg.getType()
              + " value: "
              + argList.get(incorrectDataTypeIndex);
      return errorMessage;
    } else {
      NamedArgument currentArg = namedArgumentList.get(incorrectDataTypeIndex);
      errorMessage +=
          "\n"
              + programName
              + ".java: error: argument "
              + currentArg.getName()
              + ": invalid "
              + currentArg.getType()
              + " value: "
              + incorrectArgValueForSpecifiedDataType;
      return errorMessage;
    }
  }
 private String usageMessage() {
   String message = "usage: java " + programName + " required:";
   for (int i = 0; i < positionalArgumentList.size(); i++) {
     PositionalArgument currentArg = positionalArgumentList.get(i);
     message += " " + currentArg.getName();
   }
   return message;
 }
 /**
  * Returns the positional argument with the specified string name
  *
  * @param argName the name of the positional argument to return
  * @return the positional argument with the specified name
  */
 public PositionalArgument getPositionalArgument(String argName) {
   PositionalArgument returnArg = null;
   for (int i = 0; i < positionalArgumentList.size(); i++) {
     PositionalArgument currentArg = positionalArgumentList.get(i);
     if (currentArg.getName().equals(argName)) {
       returnArg = currentArg;
     }
   }
   return returnArg;
 }
  private void parsePositionalArgumentValues(List<PositionalArgument> posArgList)
      throws IncorrectArgumentValueException {
    for (int i = 0; i < posArgList.size(); i++) {
      PositionalArgument currentArg = posArgList.get(i);
      String errorArg = currentArg.getName();
      String[] valueSet = currentArg.getValueSet();
      if (!valueSet[0].equals("")) {
        Boolean valueSetContainsArgValue = false;
        String errorValue = "";
        for (int j = 0; j < valueSet.length; j++) {
          if (currentArg.getType().equals("integer")) {
            int intValue = (Integer) currentArg.getValue();
            if (valueSet[j].equals(Integer.toString(intValue))) {
              valueSetContainsArgValue = true;
            }
            errorValue = Integer.toString(intValue);
          } else if (currentArg.getType().equals("float")) {
            float floatValue = (Float) currentArg.getValue();
            if (valueSet[j].equals(Float.toString(floatValue))) {
              valueSetContainsArgValue = true;
            }
            errorValue = Float.toString(floatValue);
          } else if (currentArg.getType().equals("string")) {
            String stringValue = (String) currentArg.getValue();
            if (valueSet[j].equals(stringValue)) {
              valueSetContainsArgValue = true;
            }
            errorValue = stringValue;
          }
          /*else{
          	Boolean boolValue = (Boolean)currentArg.getValue();
          	if(valueSet[j].equals(Boolean.toString(boolValue))){
          		valueSetContainsArgValue = true;
          	}
          	errorValue = Boolean.toString(boolValue);
          }*/

        }
        if (!valueSetContainsArgValue) {
          throw new IncorrectArgumentValueException(
              incorrectArgumentValueMessage(errorArg, errorValue));
        }
      }
    }
  }
  private String helpMessage() {
    String helpMessage = this.usageMessage();

    /*for(int i = 0; i < namedArgumentList.size(); i++){
    	NamedArgument namedArg = namedArgumentList.get(i);
    	helpMessage += " [" + namedArg.getName() + "]";
    }*/
    helpMessage += "\n" + programDescription + "\npositional arguments:";

    for (int i = 0; i < positionalArgumentList.size(); i++) {
      PositionalArgument currentArg = positionalArgumentList.get(i);
      helpMessage +=
          "\n["
              + currentArg.getName()
              + "] ("
              + currentArg.getType()
              + ") "
              + currentArg.getDescription();
    }

    helpMessage += "\nnamed arguments:";

    for (int i = 0; i < namedArgumentList.size(); i++) {
      NamedArgument currentArg = namedArgumentList.get(i);
      helpMessage +=
          "\n[--"
              + currentArg.getName()
              + "] [-"
              + currentArg.getShortFormName()
              + "] ("
              + currentArg.getType()
              + ") "
              + currentArg.getDescription()
              + " (optional)";
    }

    return helpMessage;
  }
  private String incorrectNumberOfArgsMessage(ArrayList<String> argList) {
    int numOfArgs = positionalArgumentList.size();
    if (argList.size() < numOfArgs) {
      String message = this.usageMessage();

      message += "\n" + programName + ".java: error: the following arguments are required:";

      for (int j = argList.size(); j < numOfArgs; j++) {
        PositionalArgument currentArg = positionalArgumentList.get(j);
        message += " " + currentArg.getName();
      }

      return message;
    } else {
      String message = this.usageMessage();

      message += "\n" + programName + ".java: error: unrecognized arguments:";

      for (int j = numOfArgs; j < argList.size(); j++) {
        message += " " + argList.get(j);
      }
      return message;
    }
  }
  /**
   * Writes argument parser information to the specified XML file. The program name, program
   * description, positional arguments, and named arguments are saved in the file in standard XML
   * format. It also saves each aspect of the arguments such as argument name, description,
   * dataType, defaultValue, and possible value set.
   *
   * @param fileName the XML file to which all information will be written
   */
  public void writeToXMLFile(String fileName) {
    File outputFile = new File(fileName);
    try {
      PrintWriter outputFileWriter = new PrintWriter(outputFile);
      outputFileWriter.println("<?xml version=" + "\"1.0\"?>");
      outputFileWriter.println("<program>");
      outputFileWriter.println("<name>" + getProgramName() + "</name>");
      outputFileWriter.println("<description>" + getProgramDescription() + "</description>");
      outputFileWriter.println("<arguments>");

      for (int i = 0; i < positionalArgumentList.size(); i++) {
        PositionalArgument posArg = positionalArgumentList.get(i);
        outputFileWriter.println("<positional>");
        outputFileWriter.println("<name>" + posArg.getName() + "</name>");
        outputFileWriter.println("<type>" + posArg.getType() + "</type>");
        outputFileWriter.println("<description>" + posArg.getDescription() + "</description>");
        outputFileWriter.println(
            "<position>"
                + (posArg.getPosition() + 1)
                + "</position>"); // prints position starting at 1
        String[] valueSet = posArg.getValueSet();
        if (!valueSet[0].equals("")) {
          String line = "<valueset>";

          line += valueSet[0];
          for (int j = 1; j < valueSet.length; j++) {
            line += "," + valueSet[j];
          }
          line += "</valueset>";
          outputFileWriter.println(line);
        }
        // outputFileWriter.println(line);
        outputFileWriter.println("</positional>");
      }

      for (int j = 0; j < namedArgumentList.size(); j++) {
        NamedArgument namedArg = namedArgumentList.get(j);
        outputFileWriter.println("<named>");
        outputFileWriter.println("<name>" + namedArg.getName() + "</name>");
        outputFileWriter.println("<shortname>" + namedArg.getShortFormName() + "</shortname>");
        outputFileWriter.println("<type>" + namedArg.getType() + "</type>");
        outputFileWriter.println("<description>" + namedArg.getDescription() + "</description>");
        outputFileWriter.println("<default>" + namedArg.getDefaultValue() + "</default>");
        String[] valueSet = namedArg.getValueSet();
        if (!valueSet[0].equals("")) {
          String line = "<valueset>";
          line += valueSet[0];
          for (int k = 1; k < valueSet.length; k++) {
            line += "," + valueSet[k];
          }
          line += "</valueset>";
          outputFileWriter.println(line);
        }
        outputFileWriter.println("</named>");
      }

      outputFileWriter.println("</arguments>");
      outputFileWriter.println("</program>");

      outputFileWriter.close();
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }
  }