private void setLongFormNamedArgValues(String[] args) throws NumberFormatException { for (int i = 0; i < args.length; i++) { String[] tempNamedArg = new String[2]; if (args[i].startsWith("--")) { tempNamedArg = args[i].split("--"); for (int j = 0; j < namedArgumentList.size(); j++) { incorrectDataTypeIndex = j; incorrectArgumentType = "named"; NamedArgument currentArg = namedArgumentList.get(j); if (currentArg.getName().equals(tempNamedArg[1])) { if (!currentArg.getType().equals("boolean")) { incorrectArgValueForSpecifiedDataType = args[i + 1]; if (currentArg.getType().equals("integer")) { int argValue = Integer.parseInt(args[i + 1]); currentArg.setValue(args[i + 1]); } else if (currentArg.getType().equals("float")) { float argValue = Float.parseFloat(args[i + 1]); currentArg.setValue(args[i + 1]); } else if (currentArg.getType().equals("string")) { currentArg.setValue(args[i + 1]); } } else { currentArg.setValue("true"); } } } } } }
private void setShortFormNamedArgValues(String[] args) throws NumberFormatException { for (int i = 0; i < args.length; i++) { String[] tempNamedArg = new String[2]; if (args[i].startsWith("-")) { tempNamedArg = args[i].split("-"); for (int k = 0; k < namedArgumentList.size(); k++) { incorrectDataTypeIndex = k; incorrectArgumentType = "named"; NamedArgument currentNamedArg = namedArgumentList.get(k); if (tempNamedArg[1].length() == 1) { // single char if (Character.toString(currentNamedArg.getShortFormName()).equals(tempNamedArg[1])) { if (!currentNamedArg.getType().equals("boolean")) { incorrectArgValueForSpecifiedDataType = args[i + 1]; if (currentNamedArg.getType().equals("integer")) { int argValue = Integer.parseInt(args[i + 1]); currentNamedArg.setValue(args[i + 1]); } else if (currentNamedArg.getType().equals("float")) { float argValue = Float.parseFloat(args[i + 1]); currentNamedArg.setValue(args[i + 1]); } else if (currentNamedArg.getType().equals("string")) { currentNamedArg.setValue(args[i + 1]); } } else { currentNamedArg.setValue("true"); } } } else { // multiple flags in one specification for (int j = 0; j < tempNamedArg[1].length(); j++) { if (currentNamedArg.getShortFormName() == tempNamedArg[1].charAt(j)) { currentNamedArg.setValue("true"); } } } } } } }